about summary refs log tree commit diff stats
path: root/source_text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-04-19 21:53:11 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-04-19 21:53:11 -0700
commit22071c9b71ad9b2256bd8302f2eeacdbbce5c01f (patch)
tree15bf5fa6db773601ffb381b2492f86ca1a90c822 /source_text.lua
parent658f96667b360ed5f7711ecd81a01635f0254837 (diff)
downloadlines.love-22071c9b71ad9b2256bd8302f2eeacdbbce5c01f.tar.gz
remove some support for long lines from source editor
A code editor is unlikely to need support for extremely long lines. And
that kind of scroll is jarring anyway in a code editor. We don't read
code like a novel, and less scroll per page implies more scrolling work.

I'd gotten rid of this functionality and the test for it [1] back in the
spokecone fork, but only took out the test when first pulling it into
the source editor.

[1] test_pagedown_often_shows_start_of_wrapping_line
Diffstat (limited to 'source_text.lua')
-rw-r--r--source_text.lua17
1 files changed, 4 insertions, 13 deletions
diff --git a/source_text.lua b/source_text.lua
index 178e0c4..e00a3fe 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -429,19 +429,7 @@ end
 
 function Text.pagedown(State)
 --?   print('pagedown')
-  -- If a line/paragraph gets to a page boundary, I often want to scroll
-  -- before I get to the bottom.
-  -- However, only do this if it makes forward progress.
-  local bot2 = Text.to2(State, State.screen_bottom1)
-  if bot2.screen_line > 1 then
-    bot2.screen_line = math.max(bot2.screen_line-10, 1)
-  end
-  local new_top1 = Text.to1(State, bot2)
-  if Text.lt1(State.screen_top1, new_top1) then
-    State.screen_top1 = new_top1
-  else
-    State.screen_top1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}
-  end
+  State.screen_top1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}
 --?   print('setting top to', State.screen_top1.line, State.screen_top1.pos)
   State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
   Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State)
@@ -688,6 +676,9 @@ function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necess
     y = y + Drawing_padding_height + Drawing.pixels(State.lines[State.cursor1.line].h, State.width)
     State.cursor1.line = State.cursor1.line + 1
   end
+  if State.cursor1.pos == nil then
+    State.cursor1.pos = 1
+  end
   -- hack: insert a text line at bottom of file if necessary
   if State.cursor1.line > #State.lines then
     assert(State.cursor1.line == #State.lines+1)