diff options
-rw-r--r-- | edit.mu | 101 |
1 files changed, 90 insertions, 11 deletions
diff --git a/edit.mu b/edit.mu index c02777ad..a39b007e 100644 --- a/edit.mu +++ b/edit.mu @@ -2829,21 +2829,21 @@ after +scroll-down [ top-of-screen:address:address:duplex-list <- get-address *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset - width:number <- subtract right, left - *top-of-screen <- start-of-next-line *top-of-screen, width + max:number <- subtract right, left + *top-of-screen <- start-of-next-line *top-of-screen, max ] -# takes a pointer 'curr' into the doubly-linked list, scans ahead at most -# width positions until just past the next newline +# takes a pointer into the doubly-linked list, scans ahead at most 'max' +# positions until just past the next newline recipe start-of-next-line [ local-scope original:address:duplex-list <- next-ingredient - width:number <- next-ingredient + max:number <- next-ingredient count:number <- copy 0 curr:address:duplex-list <- copy original { reply-unless curr, original - done?:boolean <- greater-or-equal count, width + done?:boolean <- greater-or-equal count, max break-if done? c:character <- get *curr, value:offset at-newline?:boolean <- equal c, 10/newline @@ -2856,6 +2856,39 @@ recipe start-of-next-line [ reply curr ] +scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ + # screen has 1 line for menu + 3 lines + assume-screen 10/width, 4/height + # initialize editor with a long, wrapped line and more than a screen of + # other lines + 1:address:array:character <- new [abcdef +g +h +i] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right + screen-should-contain [ + . . + .abcd↩ . + .ef . + .g . + ] + # position cursor at last line, then try to move further down + assume-console [ + left-click 3, 0 + press 65516 # down-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .ef . + .g . + .h . + ] +] + # cursor-up can scroll if necessary scenario editor-can-scroll-up-using-arrow-keys [ @@ -2895,17 +2928,18 @@ after +scroll-up [ top-of-screen:address:address:duplex-list <- get-address *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset - width:number <- subtract right, left - *top-of-screen <- start-of-previous-line *top-of-screen, width + max:number <- subtract right, left + max <- subtract max, 1 # include wrapped line but without newline + *top-of-screen <- start-of-previous-line *top-of-screen, max ] -# takes a pointer into the doubly-linked list, scans back at most width +# takes a pointer into the doubly-linked list, scans back at most 'max' # positions to previous newline. Returns original pointer if falls off edge of # list. recipe start-of-previous-line [ local-scope original:address:duplex-list <- next-ingredient - width:number <- next-ingredient + max:number <- next-ingredient count:number <- copy 0 curr:address:duplex-list <- copy original reply-unless curr, original @@ -2915,7 +2949,7 @@ recipe start-of-previous-line [ # now skip before until previous newline { reply-unless curr, original - done?:boolean <- greater-or-equal count, width + done?:boolean <- greater-or-equal count, max break-if done? c:character <- get *curr, value:offset at-newline?:boolean <- equal c, 10/newline @@ -2928,6 +2962,51 @@ recipe start-of-previous-line [ reply curr ] +scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ + # screen has 1 line for menu + 3 lines + assume-screen 10/width, 4/height + # initialize editor with a long, wrapped line and more than a screen of + # other lines + 1:address:array:character <- new [abcdef +g +h +i] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right + screen-should-contain [ + . . + .abcd↩ . + .ef . + .g . + ] + # position cursor at top of second page, just below wrapped line + assume-console [ + press 65518 # page-down + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + screen-should-contain [ + . . + .g . + .h . + .i . + ] + # now move up one line + assume-console [ + press 65517 # up-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .ef . + .g . + .h . + ] +] + ## putting the environment together out of editors container programming-environment-data [ |