Browse Source

Add more text packages to `examples/all`

gingerBill 2 years ago
parent
commit
635842b322
2 changed files with 10 additions and 3 deletions
  1. 4 3
      core/text/edit/text_edit.odin
  2. 6 0
      examples/all/all_main.odin

+ 4 - 3
core/text/edit/text_edit.odin

@@ -113,15 +113,16 @@ set_text :: proc(s: ^State, text: string) {
 }
 }
 
 
 
 
-undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) {
+undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) -> mem.Allocator_Error {
 	text := string(s.builder.buf[:])
 	text := string(s.builder.buf[:])
-	item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator))
+	item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator) or_return)
 	item.selection = s.selection
 	item.selection = s.selection
 	item.len = len(text)
 	item.len = len(text)
 	#no_bounds_check {
 	#no_bounds_check {
 		runtime.copy(item.text[:len(text)], text)
 		runtime.copy(item.text[:len(text)], text)
 	}
 	}
-	append(undo, item)
+	append(undo, item) or_return
+	return nil
 }
 }
 
 
 undo :: proc(s: ^State, undo, redo: ^[dynamic]^Undo_State) {
 undo :: proc(s: ^State, undo, redo: ^[dynamic]^Undo_State) {

+ 6 - 0
examples/all/all_main.odin

@@ -108,6 +108,9 @@ import sync             "core:sync"
 import testing          "core:testing"
 import testing          "core:testing"
 import scanner          "core:text/scanner"
 import scanner          "core:text/scanner"
 import i18n             "core:text/i18n"
 import i18n             "core:text/i18n"
+import match            "core:text/match"
+import table            "core:text/table"
+import edit             "core:text/edit"
 import thread           "core:thread"
 import thread           "core:thread"
 import time             "core:time"
 import time             "core:time"
 
 
@@ -210,6 +213,9 @@ _ :: sync
 _ :: testing
 _ :: testing
 _ :: scanner
 _ :: scanner
 _ :: i18n
 _ :: i18n
+_ :: match
+_ :: table
+_ :: edit
 _ :: thread
 _ :: thread
 _ :: time
 _ :: time
 _ :: sysinfo
 _ :: sysinfo