diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-06-10 14:02:35 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-06-10 14:19:02 -0700 |
commit | feedc512271d62dd4070fa8945385fb4c3242029 (patch) | |
tree | f60581b08c58efb71be2d935dde8f9b66b4e1fd8 /main.lua | |
parent | 41521518a320985926948d5e2bd217d7e3694eb6 (diff) | |
download | text.love-feedc512271d62dd4070fa8945385fb4c3242029.tar.gz |
faster paste
We don't need to perform the scroll calculations after inserting every single character from the clipboard.
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/main.lua b/main.lua index fc40f99..8013c8d 100644 --- a/main.lua +++ b/main.lua @@ -428,24 +428,22 @@ function App.keychord_pressed(chord) local before = snapshot(before_line) local clipboard_data = App.getClipboardText() local num_newlines = 0 -- hack 1 +--? print(Screen_top1.line, Screen_top1.pos, Cursor1.line, Cursor1.pos, Screen_bottom1.line, Screen_bottom1.pos) for _,code in utf8.codes(clipboard_data) do local c = utf8.char(code) if c == '\n' then Text.insert_return() - if (Cursor_y + Line_height) > App.screen.height then - Text.snap_cursor_to_bottom_of_screen() - end num_newlines = num_newlines+1 else ---? print(Screen_top1.line, Screen_top1.pos, Cursor1.line, Cursor1.pos, Screen_bottom1.line, Screen_bottom1.pos) Text.insert_at_cursor(c) - if Cursor_y >= App.screen.height - Line_height then - Text.populate_screen_line_starting_pos(Cursor1.line) - Text.snap_cursor_to_bottom_of_screen() ---? print('=>', Screen_top1.line, Screen_top1.pos, Cursor1.line, Cursor1.pos, Screen_bottom1.line, Screen_bottom1.pos) - end end end + App.draw() + if Cursor_y >= App.screen.height - Line_height then + Text.populate_screen_line_starting_pos(Cursor1.line) + Text.snap_cursor_to_bottom_of_screen() +--? print('=>', Screen_top1.line, Screen_top1.pos, Cursor1.line, Cursor1.pos, Screen_bottom1.line, Screen_bottom1.pos) + end -- hack 1: if we have too many newlines we definitely need to scroll for i=before_line,Cursor1.line do Lines[i].screen_line_starting_pos = nil |