about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-10 14:38:39 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-10 14:38:39 -0700
commit0dd940024e05cd4ce9edcb41a9c5f8d0f799ee58 (patch)
tree1ca2de2bfe367b41206ca5ddabb0e1ea65d0766d /text.lua
parentd202e2ce9970599655b875c6d6e34253da03232b (diff)
downloadtext.love-0dd940024e05cd4ce9edcb41a9c5f8d0f799ee58.tar.gz
stop repeatedly checking for line wrapping
We have a regression since we started reclaiming love Text fragments
more aggressively in commit 69c5d844ccc. Pressing pageup no longer knows
about any line's screen lines. Not fixed yet.
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/text.lua b/text.lua
index 432a8d1..b2463ea 100644
--- a/text.lua
+++ b/text.lua
@@ -388,6 +388,7 @@ function Text.insert_return()
 end
 
 function Text.pageup()
+  print('pageup')
   -- duplicate some logic from love.draw
   local top2 = Text.to2(Screen_top1)
 --?   print(App.screen.height)
@@ -407,9 +408,11 @@ function Text.pageup()
   Cursor1.pos = Screen_top1.pos
   Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
 --?   print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos)
+  print('pageup end')
 end
 
 function Text.pagedown()
+  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.
@@ -430,6 +433,7 @@ function Text.pagedown()
   Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
 --?   print('top now', Screen_top1.line)
   Text.redraw_all()  -- if we're scrolling, reclaim all fragments to avoid memory leaks
+  print('pagedown end')
 end
 
 function Text.up()
@@ -880,6 +884,7 @@ function Text.populate_screen_line_starting_pos(line_index)
   if line.fragments == nil then
     Text.compute_fragments(line, Line_width)
   end
+  line.screen_line_starting_pos = {1}
   local x = 25
   local pos = 1
   for _, f in ipairs(line.fragments) do
@@ -889,12 +894,8 @@ function Text.populate_screen_line_starting_pos(line_index)
     local frag_width = App.width(frag_text)
     if x + frag_width > Line_width then
       x = 25
-      if line.screen_line_starting_pos == nil then
-        line.screen_line_starting_pos = {1, pos}
-      else
---?         print(' ', #line.screen_line_starting_pos, line.data)
-        table.insert(line.screen_line_starting_pos, pos)
-      end
+--?       print(' ', #line.screen_line_starting_pos, line.data)
+      table.insert(line.screen_line_starting_pos, pos)
     end
     x = x + frag_width
     local frag_len = utf8.len(frag)
@@ -903,7 +904,7 @@ function Text.populate_screen_line_starting_pos(line_index)
 end
 
 function Text.redraw_all()
---?   print('clearing fragments')
+  print('clearing fragments')
   for _,line in ipairs(Lines) do
     line.y = nil
     line.fragments = nil