From 9a42128eb406fe90ee768f20469352eabbd0314f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 17 May 2022 22:12:08 -0700 Subject: jump between lines on left/right Also skip past drawings. --- main.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.lua b/main.lua index 93a97a9..96f56c7 100644 --- a/main.lua +++ b/main.lua @@ -275,12 +275,34 @@ function keychord_pressed(chord) Cursor_pos = 1 end elseif chord == 'left' then + assert(Lines[Cursor_line].mode == 'text') if Cursor_pos > 1 then Cursor_pos = Cursor_pos-1 + else + local new_cursor_line = Cursor_line + while new_cursor_line > 1 do + new_cursor_line = new_cursor_line-1 + if Lines[new_cursor_line].mode == 'text' then + Cursor_line = new_cursor_line + Cursor_pos = #Lines[Cursor_line].data+1 + break + end + end end elseif chord == 'right' then + assert(Lines[Cursor_line].mode == 'text') if Cursor_pos <= #Lines[Cursor_line].data then Cursor_pos = Cursor_pos+1 + else + local new_cursor_line = Cursor_line + while new_cursor_line <= #Lines-1 do + new_cursor_line = new_cursor_line+1 + if Lines[new_cursor_line].mode == 'text' then + Cursor_line = new_cursor_line + Cursor_pos = 1 + break + end + end end elseif chord == 'home' then Cursor_pos = 1 -- cgit 1.4.1-2-gfad0