diff options
Diffstat (limited to 'sandbox/003-shortcuts.mu')
-rw-r--r-- | sandbox/003-shortcuts.mu | 90 |
1 files changed, 87 insertions, 3 deletions
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 41102275..e9d1a349 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -1012,9 +1012,7 @@ def move-to-previous-line editor:&:editor -> editor:&:editor [ curr:&:duplex-list:char <- copy before-cursor old:&:duplex-list:char <- copy curr { - c2:char <- get *curr, value:offset - at-newline?:bool <- equal c2, 10/newline - break-if at-newline? + break-unless cursor-column curr <- before-previous-screen-line curr, editor no-motion?:bool <- equal curr, old return-if no-motion? @@ -1164,6 +1162,92 @@ ghi] ] ] +scenario editor-moves-to-top-line-in-presence-of-wrapped-line [ + local-scope + assume-screen 10/width, 5/height + s:text <- new [abcde] + e:&:editor <- new-editor s, 0/left, 5/right + editor-render screen, e + screen-should-contain [ + . . + .abcd↩ . + .e . + .┈┈┈┈┈ . + ] + $clear-trace + assume-console [ + left-click 2, 0 + press up-arrow + ] + run [ + editor-event-loop screen, console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset + ] + memory-should-contain [ + 3 <- 1 + 4 <- 0 + ] + check-trace-count-for-label 0, [print-character] + assume-console [ + type [0] + ] + run [ + editor-event-loop screen, console, e + ] + screen-should-contain [ + . . + .0abc↩ . + .de . + .┈┈┈┈┈ . + ] +] + +scenario editor-moves-to-top-line-in-presence-of-wrapped-line-2 [ + local-scope + assume-screen 10/width, 5/height + s:text <- new [abc +defgh] + e:&:editor <- new-editor s, 0/left, 5/right + editor-render screen, e + screen-should-contain [ + . . + .abc . + .defg↩ . + .h . + .┈┈┈┈┈ . + ] + $clear-trace + assume-console [ + left-click 3, 0 + press up-arrow + press up-arrow + ] + run [ + editor-event-loop screen, console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset + ] + memory-should-contain [ + 3 <- 1 + 4 <- 0 + ] + check-trace-count-for-label 0, [print-character] + assume-console [ + type [0] + ] + run [ + editor-event-loop screen, console, e + ] + screen-should-contain [ + . . + .0abc . + .defg↩ . + .h . + .┈┈┈┈┈ . + ] +] + # down arrow scenario editor-moves-to-next-line-with-down-arrow [ |