diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-06-25 01:48:56 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-06-25 01:48:56 -0700 |
commit | 5405a972e44259d65c374a3c9e583e026ad7cd8e (patch) | |
tree | 84842958f20e836c1c82163dcd7781785104051a /sandbox | |
parent | d5a492d384994af1c4840d51b3251f384af80e86 (diff) | |
download | mu-5405a972e44259d65c374a3c9e583e026ad7cd8e.tar.gz |
3954
As a blanket rule, down-arrow now stops scrolling once the bottom margin comes on screen. Now that we have page-wise scrolling with ctrl-f/b and line-wise scrolling with ctrl-s/x, we don't need to conflate scroll positioning with the arrow keys. And as a result, early students no longer have to struggle with accidentally scrolling part of the sandbox off the screen when there's tons of empty space available. `move-to-next-line` is still super messy and will need further rethinking, but this commit simplifies the codebase as a whole by eliminating a couple of historical accidents: a) We only introduced scrolling past the bottom of the screen to allow more sandboxes to come into view before we had scrolling for the sandbox side. b) We undid scrolling past the bottom in just the recipe side to allow errors to come into view. Since these historical details are now irrelevant, we no longer need separate logic for the recipe and sandbox sides, and we don't need to keep track of the recipe-bottom separate from the bottom margin of arbitrary editors.
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/003-shortcuts.mu | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 6fdd70b8..adee48a7 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -1348,38 +1348,43 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [ left:num <- get *editor, left:offset right:num <- get *editor, right:offset last-line:num <- subtract screen-height, 1 + bottom:num <- get *editor, bottom:offset + at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line + return-unless before-cursor + next:&:duplex-list:char <- next before-cursor + return-unless next already-at-bottom?:bool <- greater-or-equal cursor-row, last-line - # incorrect indent to help diff with edit/ # if cursor not at bottom, move it return-if already-at-bottom? - # scan to start of next line, then to right column or until end of line - max:num <- subtract right, left - next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max - # already at end of buffer? do nothing - no-motion?:bool <- equal next-line, before-cursor - return-if no-motion? - cursor-row <- add cursor-row, 1 - *editor <- put *editor, cursor-row:offset, cursor-row - before-cursor <- copy next-line - *editor <- put *editor, before-cursor:offset, before-cursor target-column:num <- copy cursor-column + # scan to start of next line + { + next:&:duplex-list:char <- next before-cursor + break-unless next + done?:bool <- greater-or-equal cursor-column, right + break-if done? + cursor-column <- add cursor-column, 1 + before-cursor <- copy next + c:char <- get *next, value:offset + at-newline?:bool <- equal c, 10/newline + break-if at-newline? + loop + } + return-unless next + cursor-row <- add cursor-row, 1 cursor-column <- copy left - *editor <- put *editor, cursor-column:offset, cursor-column { + next:&:duplex-list:char <- next before-cursor + break-unless next done?:bool <- greater-or-equal cursor-column, target-column break-if done? - curr:&:duplex-list:char <- next before-cursor - break-unless curr - currc:char <- get *curr, value:offset - at-newline?:bool <- equal currc, 10/newline - break-if at-newline? - # - before-cursor <- copy curr - *editor <- put *editor, before-cursor:offset, before-cursor cursor-column <- add cursor-column, 1 - *editor <- put *editor, cursor-column:offset, cursor-column + before-cursor <- copy next loop } + *editor <- put *editor, before-cursor:offset, before-cursor + *editor <- put *editor, cursor-column:offset, cursor-column + *editor <- put *editor, cursor-row:offset, cursor-row ] scenario editor-adjusts-column-at-next-line [ |