about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-23 22:31:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-23 22:51:52 -0700
commit8d5ac5da75b853e833c7ad5f18ce468eebc2aa0b (patch)
treeb64b7a6d9abc8fa3559a5a36829f1c73c1af7b06 /main.lua
parentb3251b23b5af380a1c5eb4bb3d2699acb934879b (diff)
downloadtext.love-8d5ac5da75b853e833c7ad5f18ce468eebc2aa0b.tar.gz
keep one screen line of overlap on pagedown
I'm now extracting the concern of computing
line.screen_line_starting_pos out of Text.draw. Earlier
I had to make sure I ran through the whole line to compute
screen_line_starting_pos, but that had the side-effect of updating
Screen_bottom1.pos as well with lines that had never been rendered.

In this process I hit my first bug due to an accidental global. It
doesn't show up in the patch because I accidentally deleted a local
declaration. (I thought I didn't need screen_line_starting_pos anymore,
deleted everywhere, then brought it back everywhere from the bottom of
the function up, but forgot to put back the very first occurrence.)

The amount of yoyoing this caused between App.draw and Text.draw, I very
much have spaghetti on my hands.

Accidental globals are _terrible_ in a program with tests. Cross test
contamination X-(
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/main.lua b/main.lua
index 504d394..d313da9 100644
--- a/main.lua
+++ b/main.lua
@@ -235,7 +235,7 @@ function App.keychord_pressed(chord)
   elseif chord == 'pagedown' then
     Screen_top1.line = Screen_bottom1.line
     Screen_top1.pos = Screen_bottom1.pos
---?     print('setting top to', Screen_top1.line)
+--?     print('setting top to', Screen_top1.line, Screen_top1.pos)
     Cursor1.line = Screen_top1.line
     Cursor1.pos = Screen_top1.pos
     Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()