diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-25 00:47:59 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-25 00:54:47 -0700 |
commit | 6bd57d3b195de3a5e729cfc3f415bbe0fd721d23 (patch) | |
tree | 68abd790a217110732a1dd6e908e9ed5e24dbb5e | |
parent | b24b0144e33347a3947008c6b78852feb2478f81 (diff) | |
download | mu-6bd57d3b195de3a5e729cfc3f415bbe0fd721d23.tar.gz |
1653 - left arrow
-rw-r--r-- | edit.mu | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/edit.mu b/edit.mu index 3caacff2..36790d9f 100644 --- a/edit.mu +++ b/edit.mu @@ -323,6 +323,7 @@ recipe event-loop [ cursor-row:address:number <- get-address editor:address:editor-data/deref, cursor-row:offset cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset # arrows; update cursor-row and cursor-column, leave before-cursor to 'render' + # right arrow { next-character?:boolean <- equal k:address:number/deref, 65514:literal/right-arrow break-unless next-character?:boolean @@ -341,6 +342,15 @@ recipe event-loop [ # otherwise cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal } + # left arrow + { + prev-character?:boolean <- equal k:address:number/deref, 65515:literal/left-arrow + break-unless prev-character?:boolean + prev:address:duplex-list <- prev-duplex before-cursor:address:address:duplex-list/deref + break-unless prev:address:duplex-list + before-cursor:address:address:duplex-list/deref <- copy prev:address:duplex-list + cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1:literal + } +render render editor:address:editor-data loop @@ -537,6 +547,24 @@ d] ] ] +scenario editor-moves-cursor-left-with-key [ + assume-screen 10:literal/width, 5:literal/height + assume-console [ + left-click 0, 2 + press 65515 # left arrow + type [0] + ] + 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 [ + .a0bc . + . . + ] +] + ## helpers for drawing editor borders recipe draw-box [ |