From 57deb762f033538a2d00fa9a2a8ae6e11729329d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 12 Jul 2024 21:01:13 -0700 Subject: [PATCH 1/4] register a new add-on tool Thanks eril! --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 690d94c..49a5535 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ here. and (non-editable) SVG. * https://git.sr.ht/~akkartik/lines2html.love exports lines.love files to html and inline SVG. +* https://codeberg.org/eril/lines2html.love provides the option to export + just the drawings to a directory. Also provides a CLI, which should be more + natural for many people. ## Feedback From c7c54a00b69eeffe1b21cc0db47a764089bdf8bc Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 16 Jul 2024 21:32:13 -0700 Subject: [PATCH 2/4] consistently schedule_save after all mutations --- edit.lua | 6 +++--- source_edit.lua | 6 +++--- source_text.lua | 8 ++++---- text.lua | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/edit.lua b/edit.lua index 987fa17..1d7f758 100644 --- a/edit.lua +++ b/edit.lua @@ -184,8 +184,8 @@ function edit.draw(State) if State.cursor1.line >= line_index then State.cursor1.line = State.cursor1.line+1 end - schedule_save(State) record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)}) + schedule_save(State) end, }) end @@ -295,11 +295,11 @@ function edit.mouse_release(State, x,y, mouse_button) State.mouse_down = nil if State.lines.current_drawing then Drawing.mouse_release(State, x,y, mouse_button) - schedule_save(State) if Drawing.before then record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)}) Drawing.before = nil end + schedule_save(State) else --? print_and_log('edit.mouse_release: no current drawing') if y < State.top then @@ -490,8 +490,8 @@ function edit.keychord_press(State, chord, key) if Text.cursor_out_of_screen(State) then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)}) + schedule_save(State) -- dispatch to drawing or text elseif App.mouse_down(1) or chord:sub(1,2) == 'C-' then local drawing_index, drawing = Drawing.current_drawing(State) diff --git a/source_edit.lua b/source_edit.lua index fd8e321..fead6c5 100644 --- a/source_edit.lua +++ b/source_edit.lua @@ -189,8 +189,8 @@ function edit.draw(State, hide_cursor, show_line_numbers) if State.cursor1.line >= line_index then State.cursor1.line = State.cursor1.line+1 end - schedule_save(State) record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)}) + schedule_save(State) end, }) end @@ -299,11 +299,11 @@ function edit.mouse_release(State, x,y, mouse_button) State.mouse_down = nil if State.lines.current_drawing then Drawing.mouse_release(State, x,y, mouse_button) - schedule_save(State) if Drawing.before then record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)}) Drawing.before = nil end + schedule_save(State) else --? print_and_log('edit.mouse_release: no current drawing') if y < State.top then @@ -491,8 +491,8 @@ function edit.keychord_press(State, chord, key) if Text.cursor_out_of_screen(State) then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)}) + schedule_save(State) -- dispatch to drawing or text elseif App.mouse_down(1) or chord:sub(1,2) == 'C-' then local drawing_index, drawing = Drawing.current_drawing(State) diff --git a/source_text.lua b/source_text.lua index 70bb610..9cc03ea 100644 --- a/source_text.lua +++ b/source_text.lua @@ -234,8 +234,8 @@ function Text.keychord_press(State, chord) if State.cursor_y > App.screen.height - State.line_height then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)}) + schedule_save(State) elseif chord == 'tab' then local before = snapshot(State, State.cursor1.line) --? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos) @@ -245,8 +245,8 @@ function Text.keychord_press(State, chord) Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) --? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) elseif chord == 'backspace' then if State.selection1.line then Text.delete_selection(State, State.left, State.right) @@ -293,8 +293,8 @@ function Text.keychord_press(State, chord) end Text.clear_screen_line_cache(State, State.cursor1.line) assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)) - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) elseif chord == 'delete' then if State.selection1.line then Text.delete_selection(State, State.left, State.right) @@ -327,8 +327,8 @@ function Text.keychord_press(State, chord) table.remove(State.line_cache, State.cursor1.line+1) end Text.clear_screen_line_cache(State, State.cursor1.line) - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) --== shortcuts that move the cursor elseif chord == 'left' then Text.left(State) diff --git a/text.lua b/text.lua index f7f6de1..4be5a09 100644 --- a/text.lua +++ b/text.lua @@ -151,7 +151,7 @@ end -- Don't handle any keys here that would trigger text_input above. function Text.keychord_press(State, chord) --? print('chord', chord, State.selection1.line, State.selection1.pos) - --== shortcuts that mutate text + --== shortcuts that mutate text (must schedule_save) if chord == 'return' then local before_line = State.cursor1.line local before = snapshot(State, before_line) @@ -160,8 +160,8 @@ function Text.keychord_press(State, chord) if State.cursor_y > App.screen.height - State.line_height then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)}) + schedule_save(State) elseif chord == 'tab' then local before = snapshot(State, State.cursor1.line) --? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos) @@ -171,8 +171,8 @@ function Text.keychord_press(State, chord) Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) --? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos) end - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) elseif chord == 'backspace' then if State.selection1.line then Text.delete_selection(State, State.left, State.right) @@ -219,8 +219,8 @@ function Text.keychord_press(State, chord) end Text.clear_screen_line_cache(State, State.cursor1.line) assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)) - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) elseif chord == 'delete' then if State.selection1.line then Text.delete_selection(State, State.left, State.right) @@ -253,8 +253,8 @@ function Text.keychord_press(State, chord) table.remove(State.line_cache, State.cursor1.line+1) end Text.clear_screen_line_cache(State, State.cursor1.line) - schedule_save(State) record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)}) + schedule_save(State) --== shortcuts that move the cursor elseif chord == 'left' then Text.left(State) From 1d3751fb823916bea290ec4503cbac2a0d43ac83 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 17 Jul 2024 14:21:23 -0700 Subject: [PATCH 3/4] clean up an unnecessary mutation Introduced in commit 3ffc2ed8f on 2022-06-19 and obviated in commit 6dfe954c02 on 2022-07-07. --- source_text.lua | 1 - text.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/source_text.lua b/source_text.lua index 9cc03ea..8d169a7 100644 --- a/source_text.lua +++ b/source_text.lua @@ -230,7 +230,6 @@ function Text.keychord_press(State, chord) local before_line = State.cursor1.line local before = snapshot(State, before_line) Text.insert_return(State) - State.selection1 = {} if State.cursor_y > App.screen.height - State.line_height then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end diff --git a/text.lua b/text.lua index 4be5a09..b073fbd 100644 --- a/text.lua +++ b/text.lua @@ -156,7 +156,6 @@ function Text.keychord_press(State, chord) local before_line = State.cursor1.line local before = snapshot(State, before_line) Text.insert_return(State) - State.selection1 = {} if State.cursor_y > App.screen.height - State.line_height then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end From fab72a2902efe3271b8bf586a31c8c8ab8c7c1e8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 17 Jul 2024 14:32:27 -0700 Subject: [PATCH 4/4] fix a comment --- source_text.lua | 2 +- text.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source_text.lua b/source_text.lua index 8d169a7..76e9045 100644 --- a/source_text.lua +++ b/source_text.lua @@ -198,7 +198,7 @@ function Text.text_input(State, t) if App.mouse_down(1) then return end if App.any_modifier_down() then if App.key_down(t) then - -- The modifiers didn't change the key. Handle it in keychord_pressed. + -- The modifiers didn't change the key. Handle it in keychord_press. return else -- Key mutated by the keyboard layout. Continue below. diff --git a/text.lua b/text.lua index b073fbd..ac07903 100644 --- a/text.lua +++ b/text.lua @@ -124,7 +124,7 @@ function Text.text_input(State, t) if App.mouse_down(1) then return end if App.any_modifier_down() then if App.key_down(t) then - -- The modifiers didn't change the key. Handle it in keychord_pressed. + -- The modifiers didn't change the key. Handle it in keychord_press. return else -- Key mutated by the keyboard layout. Continue below.