diff options
-rw-r--r-- | text.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/text.lua b/text.lua index 4072311..d2c9466 100644 --- a/text.lua +++ b/text.lua @@ -529,13 +529,16 @@ end function Text.word_right() while true do - Text.right() + Text.right_without_scroll() if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then break end local offset = Text.offset(Lines[Cursor1.line].data, Cursor1.pos) if Lines[Cursor1.line].data:sub(offset,offset) == ' ' then -- TODO: other space characters break end end + if Text.cursor_past_screen_bottom() then + Text.snap_cursor_to_bottom_of_screen() + end end function Text.left() @@ -561,6 +564,13 @@ function Text.left() end function Text.right() + Text.right_without_scroll() + if Text.cursor_past_screen_bottom() then + Text.snap_cursor_to_bottom_of_screen() + end +end + +function Text.right_without_scroll() assert(Lines[Cursor1.line].mode == 'text') if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) then Cursor1.pos = Cursor1.pos+1 @@ -575,9 +585,6 @@ function Text.right() end end end - if Text.cursor_past_screen_bottom() then - Text.snap_cursor_to_bottom_of_screen() - end end function Text.pos_at_start_of_cursor_screen_line() @@ -620,6 +627,7 @@ function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necess end end +-- should never modify Cursor1 function Text.snap_cursor_to_bottom_of_screen() local top2 = Text.to2(Cursor1) top2.screen_pos = 1 -- start of screen line |