diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2024-06-27 22:15:12 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2024-06-27 22:15:12 -0700 |
commit | 54addeb3b782125e7e0024347d6961efcbc4964c (patch) | |
tree | 4edac1fdbb778011b642a11f2c80ba9b98c3f4dd /text.lua | |
parent | dbd58e81755607de511845564ac3353eeb369ac2 (diff) | |
parent | 91a08eec2b39a38db9a6952a5701617da549d970 (diff) | |
download | view.love-54addeb3b782125e7e0024347d6961efcbc4964c.tar.gz |
Merge lines.love
Diffstat (limited to 'text.lua')
-rw-r--r-- | text.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/text.lua b/text.lua index 5814693..a43e782 100644 --- a/text.lua +++ b/text.lua @@ -255,12 +255,12 @@ function Text.keychord_press(State, chord) State.selection1 = {} elseif chord == 'S-left' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.left(State) elseif chord == 'S-right' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.right(State) -- C- hotkeys reserved for drawings, so we'll use M- @@ -272,12 +272,12 @@ function Text.keychord_press(State, chord) State.selection1 = {} elseif chord == 'M-S-left' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.word_left(State) elseif chord == 'M-S-right' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.word_right(State) elseif chord == 'home' then @@ -288,12 +288,12 @@ function Text.keychord_press(State, chord) State.selection1 = {} elseif chord == 'S-home' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.start_of_line(State) elseif chord == 'S-end' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.end_of_line(State) elseif chord == 'up' then @@ -304,12 +304,12 @@ function Text.keychord_press(State, chord) State.selection1 = {} elseif chord == 'S-up' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.up(State) elseif chord == 'S-down' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.down(State) elseif chord == 'pageup' then @@ -320,12 +320,12 @@ function Text.keychord_press(State, chord) State.selection1 = {} elseif chord == 'S-pageup' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.pageup(State) elseif chord == 'S-pagedown' then if State.selection1.line == nil then - State.selection1 = {line=State.cursor1.line, pos=State.cursor1.pos} + State.selection1 = deepcopy(State.cursor1) end Text.pagedown(State) end @@ -342,7 +342,7 @@ end function Text.pageup(State) State.screen_top1 = Text.previous_screen_top1(State) - State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos} + State.cursor1 = deepcopy(State.screen_top1) Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State) Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks end @@ -380,7 +380,7 @@ end function Text.pagedown(State) State.screen_top1 = Text.screen_bottom1(State) - State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos} + State.cursor1 = deepcopy(State.screen_top1) Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State) Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks end @@ -484,7 +484,7 @@ end function Text.start_of_line(State) State.cursor1.pos = 1 if Text.lt1(State.cursor1, State.screen_top1) then - State.screen_top1 = {line=State.cursor1.line, pos=State.cursor1.pos} -- copy + State.screen_top1 = deepcopy(State.cursor1) end end @@ -924,7 +924,7 @@ function Text.tweak_screen_top_and_cursor(State) -- make sure cursor is on screen local screen_bottom1 = Text.screen_bottom1(State) if Text.lt1(State.cursor1, State.screen_top1) then - State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos} + State.cursor1 = deepcopy(State.screen_top1) elseif State.cursor1.line >= screen_bottom1.line then if Text.cursor_out_of_screen(State) then State.cursor1 = Text.final_text_loc_on_screen(State) |