diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-05-28 13:22:25 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-05-28 13:22:25 -0700 |
commit | 1df3d62a83f7d5dc09e82a4fdac31ce4d08da02b (patch) | |
tree | 816fee371211065277f38f7cd9607c73bebe6776 /edit | |
parent | 4f2adf06713eeec995d7811cd1d7a4dfe3cdda86 (diff) | |
download | mu-1df3d62a83f7d5dc09e82a4fdac31ce4d08da02b.tar.gz |
3884 - per-line scroll in edit/ app
Diffstat (limited to 'edit')
-rw-r--r-- | edit/003-shortcuts.mu | 61 | ||||
-rw-r--r-- | edit/012-editor-undo.mu | 2 |
2 files changed, 63 insertions, 0 deletions
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index 9aa6b95d..32d40823 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -2176,6 +2176,7 @@ after <scroll-down> [ # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline +# returns original if no next newline # beware: never return null pointer. def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ local-scope @@ -2555,6 +2556,7 @@ after <scroll-up> [ # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line +# returns original if no next newline # beware: never return null pointer def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ local-scope @@ -3489,3 +3491,62 @@ gxy .dxy . ] ] + +# ctrl-e - scroll up by one line +# todo: scenarios + +after <handle-special-character> [ + { + scroll-up?:bool <- equal c, 5/ctrl-e + break-unless scroll-up? + <move-cursor-begin> + do-render?:bool, editor <- line-up editor, screen-height + undo-coalesce-tag:num <- copy 5/line-up + <move-cursor-end> + return do-render? + } +] + +def line-up editor:&:editor, screen-height:num -> do-render?:bool, editor:&:editor [ + local-scope + load-ingredients + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + max:num <- subtract right, left + old-top:&:duplex-list:char <- get *editor, top-of-screen:offset + new-top:&:duplex-list:char <- before-start-of-next-line old-top, max + movement?:bool <- not-equal old-top, new-top + { + break-unless movement? + *editor <- put *editor, top-of-screen:offset, new-top + } + return movement? +] + +# ctrl-d - scroll down by one line +# todo: scenarios + +after <handle-special-character> [ + { + scroll-down?:bool <- equal c, 4/ctrl-d + break-unless scroll-down? + <move-cursor-begin> + do-render?:bool, editor <- line-down editor, screen-height + undo-coalesce-tag:num <- copy 6/line-down + <move-cursor-end> + return do-render? + } +] + +def line-down editor:&:editor, screen-height:num -> do-render?:bool, editor:&:editor [ + local-scope + load-ingredients + old-top:&:duplex-list:char <- get *editor, top-of-screen:offset + new-top:&:duplex-list:char <- before-previous-line old-top, editor + movement?:bool <- not-equal old-top, new-top + { + break-unless movement? + *editor <- put *editor, top-of-screen:offset, new-top + } + return movement? +] diff --git a/edit/012-editor-undo.mu b/edit/012-editor-undo.mu index 69e1c22b..b7f9e976 100644 --- a/edit/012-editor-undo.mu +++ b/edit/012-editor-undo.mu @@ -36,6 +36,8 @@ container move-operation [ # 2: right arrow # 3: up arrow # 4: down arrow + # 5: line up + # 6: line down ] container delete-operation [ |