diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-29 23:39:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-29 23:39:58 -0700 |
commit | 0392bc2c9d2b08c3c309353ac42694b9cdf973e4 (patch) | |
tree | 13149b7f35bc1fe97143ce0dfbd8d2ee3915f9a7 | |
parent | 56d0c162088d80c97fc0c67b6d05be271ed1ccff (diff) | |
download | mu-0392bc2c9d2b08c3c309353ac42694b9cdf973e4.tar.gz |
1679
-rw-r--r-- | edit.mu | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/edit.mu b/edit.mu index e8c9017d..f5a06345 100644 --- a/edit.mu +++ b/edit.mu @@ -546,17 +546,24 @@ recipe handle-event [ cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1:literal reply } - # if at left margin, figure out how long the previous line is (there's - # guaranteed to be a previous line, since we're not at start of text) - # and position cursor after it - # before-cursor must currently be at a newline - prevc:character <- get before-cursor:address:address:duplex-list/deref/deref, value:offset - previous-character-must-be-newline:boolean <- equal prevc:character, 10:literal/newline - assert previous-character-must-be-newline:boolean, [aaa] - # compute length of previous line - end-of-line:number <- previous-line-length before-cursor:address:address:duplex-list/deref, d:address:duplex-list + # if at left margin, there's guaranteed to be a previous line, since we're + # not at start of text + { + # if before-cursor is at newline, figure out how long the previous line is + prevc:character <- get before-cursor:address:address:duplex-list/deref/deref, value:offset + previous-character-is-newline?:boolean <- equal prevc:character, 10:literal/newline + break-unless previous-character-is-newline?:boolean + # compute length of previous line + end-of-line:number <- previous-line-length before-cursor:address:address:duplex-list/deref, d:address:duplex-list + cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1:literal + cursor-column:address:number/deref <- copy end-of-line:number + reply + } + # if before-cursor is not at newline, we're just at a wrapped line + assert cursor-row:address:number/deref, [unimplemented: moving cursor above top of screen] cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1:literal - cursor-column:address:number/deref <- copy end-of-line:number + right:number <- get editor:address:editor-data/deref, right:offset + cursor-column:address:number/deref <- subtract right:number, 1:literal # leave room for wrap icon } ] @@ -1242,6 +1249,32 @@ d] ] ] +scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ + assume-screen 10:literal/width, 5:literal/height + # initialize editor with text containing an empty line + 1:address:array:character <- new [abcdef] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/top, 0:literal/left, 5:literal/right + screen-should-contain [ + .abcd↩ . + .ef . + . . + ] + # position cursor right after empty line + assume-console [ + left-click 1, 0 + press 65515 # left arrow + ] + run [ + event-loop screen:address, console:address, 2:address:editor-data + 3:number <- get 2:address:editor-data/deref, cursor-row:offset + 4:number <- get 2:address:editor-data/deref, cursor-column:offset + ] + memory-should-contain [ + 3 <- 0 # previous row + 4 <- 3 # end of wrapped line + ] +] + scenario point-at-multiple-editors [ assume-screen 10:literal/width, 5:literal/height # initialize an editor covering left half of screen |