From 2b3e09ca0fadcaaeac8d563aae1baeb7e7da3754 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 23 Dec 2022 17:16:19 -0800 Subject: make love event names consistent I want the words to be easy to read, and to use a consistent tense. update and focus seem more timeless; let's make everything like those. --- source_edit.lua | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source_edit.lua') diff --git a/source_edit.lua b/source_edit.lua index 8c1b37d..53fb232 100644 --- a/source_edit.lua +++ b/source_edit.lua @@ -227,7 +227,7 @@ function edit.mouse_pressed(State, x,y, mouse_button) -- sets cursor -- press and hold to start a selection: sets selection on press, cursor on release -- press and hold, then press shift: ignore shift - -- i.e. mouse_released should never look at shift state + -- i.e. mouse_release should never look at shift state State.old_cursor1 = State.cursor1 State.old_selection1 = State.selection1 State.mousepress_shift = App.shift_down() @@ -250,11 +250,11 @@ function edit.mouse_pressed(State, x,y, mouse_button) end end -function edit.mouse_released(State, x,y, mouse_button) +function edit.mouse_release(State, x,y, mouse_button) if State.search_term then return end --? print('release') if State.lines.current_drawing then - Drawing.mouse_released(State, x,y, mouse_button) + 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)}) @@ -287,7 +287,7 @@ function edit.mouse_released(State, x,y, mouse_button) end end -function edit.textinput(State, t) +function edit.text_input(State, t) if State.search_term then State.search_term = State.search_term..t State.search_text = nil @@ -302,13 +302,13 @@ function edit.textinput(State, t) local drawing_index, drawing = Drawing.current_drawing(State) if drawing_index == nil then for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll - Text.textinput(State, t) + Text.text_input(State, t) end end schedule_save(State) end -function edit.keychord_pressed(State, chord, key) +function edit.keychord_press(State, chord, key) if State.selection1.line and not State.lines.current_drawing and -- printable character created using shift key => delete selection @@ -461,7 +461,7 @@ function edit.keychord_pressed(State, chord, key) local drawing_index, drawing = Drawing.current_drawing(State) if drawing_index then local before = snapshot(State, drawing_index) - Drawing.keychord_pressed(State, chord) + Drawing.keychord_press(State, chord) record_undo_event(State, {before=before, after=snapshot(State, drawing_index)}) schedule_save(State) end @@ -493,7 +493,7 @@ function edit.keychord_pressed(State, chord, key) schedule_save(State) else for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll - Text.keychord_pressed(State, chord) + Text.keychord_press(State, chord) end end @@ -511,7 +511,7 @@ function edit.eradicate_locations_after_the_fold(State) end end -function edit.key_released(State, key, scancode) +function edit.key_release(State, key, scancode) end function edit.update_font_settings(State, font_height) @@ -539,21 +539,21 @@ function edit.initialize_test_state() 15) -- line height end --- all textinput events are also keypresses +-- all text_input events are also keypresses -- TODO: handle chords of multiple keys -function edit.run_after_textinput(State, t) - edit.keychord_pressed(State, t) - edit.textinput(State, t) - edit.key_released(State, t) +function edit.run_after_text_input(State, t) + edit.keychord_press(State, t) + edit.text_input(State, t) + edit.key_release(State, t) App.screen.contents = {} edit.update(State, 0) edit.draw(State) end --- not all keys are textinput +-- not all keys are text_input function edit.run_after_keychord(State, chord) - edit.keychord_pressed(State, chord) - edit.key_released(State, chord) + edit.keychord_press(State, chord) + edit.key_release(State, chord) App.screen.contents = {} edit.update(State, 0) edit.draw(State) @@ -563,7 +563,7 @@ function edit.run_after_mouse_click(State, x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) edit.mouse_pressed(State, x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) - edit.mouse_released(State, x,y, mouse_button) + edit.mouse_release(State, x,y, mouse_button) App.screen.contents = {} edit.update(State, 0) edit.draw(State) @@ -579,7 +579,7 @@ end function edit.run_after_mouse_release(State, x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) - edit.mouse_released(State, x,y, mouse_button) + edit.mouse_release(State, x,y, mouse_button) App.screen.contents = {} edit.update(State, 0) edit.draw(State) -- cgit 1.4.1-2-gfad0 From e0448d7d7f1f6ec7ff88b222f59abe88503437e6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 23 Dec 2022 19:26:05 -0800 Subject: consistent names in a few more places --- drawing.lua | 2 +- edit.lua | 8 ++++---- log_browser.lua | 2 +- main.lua | 4 ++-- source.lua | 8 ++++---- source_edit.lua | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source_edit.lua') diff --git a/drawing.lua b/drawing.lua index 3d9cd53..99193c6 100644 --- a/drawing.lua +++ b/drawing.lua @@ -218,7 +218,7 @@ function Drawing.in_drawing(drawing, line_cache, x,y, left,right) return y >= line_cache.starty and y < line_cache.starty + Drawing.pixels(drawing.h, width) and x >= left and x < right end -function Drawing.mouse_pressed(State, drawing_index, x,y, mouse_button) +function Drawing.mouse_press(State, drawing_index, x,y, mouse_button) local drawing = State.lines[drawing_index] local line_cache = State.line_cache[drawing_index] local cx = Drawing.coord(x-State.left, State.width) diff --git a/edit.lua b/edit.lua index ed5a79f..4d36780 100644 --- a/edit.lua +++ b/edit.lua @@ -195,7 +195,7 @@ function edit.quit(State) end end -function edit.mouse_pressed(State, x,y, mouse_button) +function edit.mouse_press(State, x,y, mouse_button) if State.search_term then return end --? print('press', State.selection1.line, State.selection1.pos) if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then @@ -231,7 +231,7 @@ function edit.mouse_pressed(State, x,y, mouse_button) State.lines.current_drawing_index = line_index State.lines.current_drawing = line Drawing.before = snapshot(State, line_index) - Drawing.mouse_pressed(State, line_index, x,y, mouse_button) + Drawing.mouse_press(State, line_index, x,y, mouse_button) break end end @@ -508,7 +508,7 @@ end function edit.run_after_mouse_click(State, x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) - edit.mouse_pressed(State, x,y, mouse_button) + edit.mouse_press(State, x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) edit.mouse_release(State, x,y, mouse_button) App.screen.contents = {} @@ -518,7 +518,7 @@ end function edit.run_after_mouse_press(State, x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) - edit.mouse_pressed(State, x,y, mouse_button) + edit.mouse_press(State, x,y, mouse_button) App.screen.contents = {} edit.update(State, 0) edit.draw(State) diff --git a/log_browser.lua b/log_browser.lua index eb6c120..76596f2 100644 --- a/log_browser.lua +++ b/log_browser.lua @@ -194,7 +194,7 @@ end function log_browser.quit(State) end -function log_browser.mouse_pressed(State, x,y, mouse_button) +function log_browser.mouse_press(State, x,y, mouse_button) local line_index = log_browser.line_index(State, x,y) if line_index == nil then -- below lower margin diff --git a/main.lua b/main.lua index c078f10..8270858 100644 --- a/main.lua +++ b/main.lua @@ -227,9 +227,9 @@ end function App.mousepressed(x,y, mouse_button) --? print('mouse press', x,y) if Current_app == 'run' then - if run.mouse_pressed then run.mouse_pressed(x,y, mouse_button) end + if run.mouse_pressed then run.mouse_press(x,y, mouse_button) end elseif Current_app == 'source' then - if source.mouse_pressed then source.mouse_pressed(x,y, mouse_button) end + if source.mouse_pressed then source.mouse_press(x,y, mouse_button) end else assert(false, 'unknown app "'..Current_app..'"') end diff --git a/source.lua b/source.lua index 0e1d478..f0022be 100644 --- a/source.lua +++ b/source.lua @@ -285,14 +285,14 @@ function source.settings() } end -function source.mouse_pressed(x,y, mouse_button) +function source.mouse_press(x,y, mouse_button) Cursor_time = 0 -- ensure cursor is visible immediately after it moves --? print('mouse click', x, y) --? print(Editor_state.left, Editor_state.right) --? print(Log_browser_state.left, Log_browser_state.right) if Show_file_navigator and y < Menu_status_bar_height + File_navigation.num_lines * Editor_state.line_height then -- send click to buttons - edit.mouse_pressed(Editor_state, x,y, mouse_button) + edit.mouse_press(Editor_state, x,y, mouse_button) return end if x < Editor_state.right + Margin_right then @@ -301,14 +301,14 @@ function source.mouse_pressed(x,y, mouse_button) Focus = 'edit' return end - edit.mouse_pressed(Editor_state, x,y, mouse_button) + edit.mouse_press(Editor_state, x,y, mouse_button) elseif Show_log_browser_side and Log_browser_state.left <= x and x < Log_browser_state.right then --? print('click on log_browser side') if Focus ~= 'log_browser' then Focus = 'log_browser' return end - log_browser.mouse_pressed(Log_browser_state, x,y, mouse_button) + log_browser.mouse_press(Log_browser_state, x,y, mouse_button) for _,line_cache in ipairs(Editor_state.line_cache) do line_cache.starty = nil end -- just in case we scroll end end diff --git a/source_edit.lua b/source_edit.lua index 53fb232..f9722eb 100644 --- a/source_edit.lua +++ b/source_edit.lua @@ -208,7 +208,7 @@ function edit.quit(State) end end -function edit.mouse_pressed(State, x,y, mouse_button) +function edit.mouse_press(State, x,y, mouse_button) if State.search_term then return end --? print('press') if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then @@ -243,7 +243,7 @@ function edit.mouse_pressed(State, x,y, mouse_button) State.lines.current_drawing_index = line_index State.lines.current_drawing = line Drawing.before = snapshot(State, line_index) - Drawing.mouse_pressed(State, line_index, x,y, mouse_button) + Drawing.mouse_press(State, line_index, x,y, mouse_button) break end end @@ -561,7 +561,7 @@ end function edit.run_after_mouse_click(State, x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) - edit.mouse_pressed(State, x,y, mouse_button) + edit.mouse_press(State, x,y, mouse_button) App.fake_mouse_release(x,y, mouse_button) edit.mouse_release(State, x,y, mouse_button) App.screen.contents = {} @@ -571,7 +571,7 @@ end function edit.run_after_mouse_press(State, x,y, mouse_button) App.fake_mouse_press(x,y, mouse_button) - edit.mouse_pressed(State, x,y, mouse_button) + edit.mouse_press(State, x,y, mouse_button) App.screen.contents = {} edit.update(State, 0) edit.draw(State) -- cgit 1.4.1-2-gfad0