From e1bc81408fc5097d5f0466e350a938147756921b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 17 May 2022 21:55:19 -0700 Subject: move --- main.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 16d743a..a8bd866 100644 --- a/main.lua +++ b/main.lua @@ -270,6 +270,19 @@ function keychord_pressed(chord) table.insert(Lines, Cursor_line+1, {mode='text', data=''}) Cursor_line = Cursor_line+1 Cursor_pos = 1 + elseif chord == 'left' then + if Cursor_pos > 1 then + Cursor_pos = Cursor_pos-1 + end + elseif chord == 'right' then + if Cursor_pos <= #Lines[Cursor_line].data then + Cursor_pos = Cursor_pos+1 + end + elseif chord == 'home' then + Cursor_pos = 1 + elseif chord == 'end' then + Cursor_pos = #Lines[Cursor_line].data+1 + -- transitioning between drawings and text elseif chord == 'backspace' then if Cursor_pos > 1 then local byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos-1) @@ -293,18 +306,6 @@ function keychord_pressed(chord) end Cursor_line = Cursor_line-1 end - elseif chord == 'left' then - if Cursor_pos > 1 then - Cursor_pos = Cursor_pos-1 - end - elseif chord == 'right' then - if Cursor_pos <= #Lines[Cursor_line].data then - Cursor_pos = Cursor_pos+1 - end - elseif chord == 'home' then - Cursor_pos = 1 - elseif chord == 'end' then - Cursor_pos = #Lines[Cursor_line].data+1 elseif chord == 'delete' then if Cursor_pos <= #Lines[Cursor_line].data then local byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos) @@ -318,7 +319,6 @@ function keychord_pressed(chord) -- no change to Cursor_pos end end - -- transitioning between drawings and text elseif chord == 'up' then assert(Lines[Cursor_line].mode == 'text') local new_cursor_line = Cursor_line -- cgit 1.4.1-2-gfad0