about summary refs log tree commit diff stats
path: root/edit.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-05 10:24:29 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-05 10:24:29 -0700
commitae70e5d7f7f3cb723884cdaee6edb440a2603165 (patch)
tree5f25a5fdbbe770b7bfc163be02ee09e5fb338307 /edit.mu
parentf34aac3639eece21dd522a8be34cbc7f45a26cdf (diff)
downloadmu-ae70e5d7f7f3cb723884cdaee6edb440a2603165.tar.gz
1710 - add notion of a menu bar
Of course, editors might begin below other editors; this is a stopgap
solution. Yagni, yagni, yagni.
Diffstat (limited to 'edit.mu')
-rw-r--r--edit.mu37
1 files changed, 36 insertions, 1 deletions
diff --git a/edit.mu b/edit.mu
index 90b745a3..51788c0b 100644
--- a/edit.mu
+++ b/edit.mu
@@ -669,7 +669,12 @@ 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
-  # always reset focus to start
+  # clicks on the menu bar shouldn't affect focus
+  click-row:number <- get t:touch-event, row:offset
+  top:number <- get editor:address:editor-data/deref, top:offset
+  too-far-up?:boolean <- lesser-than click-row:number, top:number
+  reply-if too-far-up?:boolean
+  # not on menu? reset focus then set it if necessary
   in-focus?:address:boolean <- get-address editor:address:editor-data/deref, in-focus?:offset
   in-focus?:address:boolean/deref <- copy 0:literal/true
   click-column:number <- get t:touch-event, column:offset
@@ -1722,6 +1727,36 @@ scenario editor-in-focus-keeps-cursor [
   ]
 ]
 
+scenario editor-in-focus-keeps-cursor-2 [
+  assume-screen 10:literal/width, 5:literal/height
+  # initialize an editor covering left half of screen - but not from the top
+  # row of screen
+  1:address:array:character <- new [abc]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1:literal/top, 0:literal/left, 5:literal/right
+  3:address:array:character <- new [def]
+  # chain new editor to it, covering the right half of the screen
+  4:address:address:editor-data <- get-address 2:address:editor-data/deref, next-editor:offset
+  4:address:address:editor-data/deref <- new-editor 3:address:array:character, screen:address, 1:literal/top, 5:literal/left, 10:literal/right
+  # initialize cursor on left editor
+  run [
+    reset-focus 2:address:editor-data
+  ]
+  # now click on top row of screen on the right side
+  assume-console [
+    left-click 0, 8
+    type [z]
+  ]
+  run [
+    event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  # cursor should still be at the left side
+  screen-should-contain [
+    .          .
+    .zabc def  .
+    .          .
+  ]
+]
+
 # set focus to first editor, reset it in later ones
 recipe reset-focus [
   default-space:address:array:location <- new location:type, 30:literal