about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--011load.cc2
-rw-r--r--041name.cc3
-rw-r--r--edit.mu34
3 files changed, 30 insertions, 9 deletions
diff --git a/011load.cc b/011load.cc
index 158e4b10..35a5daac 100644
--- a/011load.cc
+++ b/011load.cc
@@ -113,6 +113,8 @@ bool next_instruction(istream& in, instruction* curr) {
     ++p;  // skip <-
   }
 
+  if (p == words.end())
+    raise << "instruction prematurely ended with '<-'\n" << die();
   curr->name = *p;
   if (Recipe_number.find(*p) == Recipe_number.end()) {
     Recipe_number[*p] = Next_recipe_number++;
diff --git a/041name.cc b/041name.cc
index e2c1d940..f87b1868 100644
--- a/041name.cc
+++ b/041name.cc
@@ -225,7 +225,8 @@ if (inst.operation == Recipe_number["get"]
   // at least 2 args, and second arg is offset
   assert(SIZE(inst.ingredients) >= 2);
 //?   cout << inst.ingredients.at(1).to_string() << '\n'; //? 1
-  assert(is_literal(inst.ingredients.at(1)));
+  if (!is_literal(inst.ingredients.at(1)))
+    raise << inst.to_string() << ": expected literal; got " << inst.ingredients.at(1).to_string() << '\n' << die();
   if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
     // since first non-address in base type must be a container, we don't have to canonize
     type_number base_type = skip_addresses(inst.ingredients.at(0).types);
diff --git a/edit.mu b/edit.mu
index 4c63f1aa..64b68582 100644
--- a/edit.mu
+++ b/edit.mu
@@ -320,14 +320,13 @@ recipe move-cursor-in-editor [
   default-space:address:array:location <- new location:type, 30:literal
   editor:address:editor-data <- next-ingredient
   t:touch-event <- next-ingredient
-  row:address:number <- get-address editor:address:editor-data/deref, cursor-row:offset
-  row:address:number/deref <- get t:touch-event, row:offset
-  column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset
-  column:address:number/deref <- get t:touch-event, column:offset
-  # clear cursor pointer; will be set correctly during render
-  cursor:address:address:duplex-list <- get-address editor:address:editor-data/deref, before-cursor:offset
-  cursor:address:address:duplex-list/deref <- copy 0:literal
+  # update cursor
+  cursor-row:address:number <- get-address editor:address:editor-data/deref, cursor-row:offset
+  cursor-row:address:number/deref <- get t:touch-event, row:offset
+  cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset
+  cursor-column:address:number/deref <- get t:touch-event, column:offset
   render editor:address:editor-data
+  reply editor:address:editor-data/same-as-ingredient:0
 ]
 
 recipe insert-at-cursor [
@@ -339,6 +338,9 @@ recipe insert-at-cursor [
 #?   $print before-cursor:address:address:duplex-list/deref, [ ], d:address:duplex-list, [ 
 #? ] #? 1
   insert-duplex c:character, before-cursor:address:address:duplex-list/deref
+  # update cursor
+  cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset
+  cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal
   render editor:address:editor-data
   reply editor:address:editor-data/same-as-ingredient:0
 ]
@@ -379,7 +381,7 @@ scenario editor-handles-mouse-clicks [
   ]
 ]
 
-scenario editor-inserts-keys-at-cursor [
+scenario editor-inserts-characters-at-cursor [
   assume-screen 10:literal/width, 5:literal/height
   assume-console [
     type [0]
@@ -397,6 +399,22 @@ scenario editor-inserts-keys-at-cursor [
   ]
 ]
 
+scenario editor-moves-cursor-after-inserting-characters [
+  assume-screen 10:literal/width, 5:literal/height
+  assume-console [
+    type [01]
+  ]
+  run [
+    1:address:array:character <- new [abc]
+    2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/top, 0:literal/left, 5:literal/right
+    event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  screen-should-contain [
+    .01abc     .
+    .          .
+  ]
+]
+
 ## helpers for drawing editor borders
 
 recipe draw-box [
76' href='#n276'>276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303