about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2025-05-06 13:41:31 -0700
committerKartik K. Agaram <vc@akkartik.com>2025-05-06 14:14:55 -0700
commit11cd9123c15f9b9e76c359a8ac672c21f299811a (patch)
treee3a234e8df50ff96e1aa1f78eb612f3e1e6cc461
parentbac6c8ae8710099014236029d1fab1f71394a4c5 (diff)
downloadlines.love-main.tar.gz
plumb through all supported args in LÖVE handlers HEAD main
I just noticed that the is_touch arg in mouse handlers is extremely
useful for arbitrating between events on a mobile device. And I'd
totally forgotten about its existence X-(
-rw-r--r--drawing.lua6
-rw-r--r--edit.lua14
-rw-r--r--keychord.lua2
-rw-r--r--log_browser.lua6
-rw-r--r--main.lua28
-rw-r--r--run.lua16
-rw-r--r--source.lua24
-rw-r--r--source_edit.lua14
-rw-r--r--source_text.lua2
-rw-r--r--text.lua2
10 files changed, 57 insertions, 57 deletions
diff --git a/drawing.lua b/drawing.lua
index 92e3d5f..b74855a 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -221,7 +221,7 @@ function Drawing.in_drawing(State, line_index, x,y, left,right)
   return y >= starty and y < starty + Drawing.pixels(drawing.h, width) and x >= left and x < right
 end
 
-function Drawing.mouse_press(State, drawing_index, x,y, mouse_button)
+function Drawing.mouse_press(State, drawing_index, x,y, mouse_button, is_touch, presses)
   local drawing = State.lines[drawing_index]
   local starty = Text.starty(State, drawing_index)
   local cx = Drawing.coord(x-State.left, State.width)
@@ -300,7 +300,7 @@ function Drawing.relax_constraints(drawing, p)
   end
 end
 
-function Drawing.mouse_release(State, x,y, mouse_button)
+function Drawing.mouse_release(State, x,y, mouse_button, is_touch, presses)
   if State.current_drawing_mode == 'move' then
     State.current_drawing_mode = State.previous_drawing_mode
     State.previous_drawing_mode = nil
@@ -396,7 +396,7 @@ function Drawing.mouse_release(State, x,y, mouse_button)
   end
 end
 
-function Drawing.keychord_press(State, chord)
+function Drawing.keychord_press(State, chord, key, scancode, is_repeat)
   if chord == 'C-p' and not App.mouse_down(1) then
     State.current_drawing_mode = 'freehand'
   elseif App.mouse_down(1) and chord == 'l' then
diff --git a/edit.lua b/edit.lua
index 269d6ef..e29af9a 100644
--- a/edit.lua
+++ b/edit.lua
@@ -226,7 +226,7 @@ function edit.quit(State)
   end
 end
 
-function edit.mouse_press(State, x,y, mouse_button)
+function edit.mouse_press(State, x,y, mouse_button, is_touch, presses)
   if State.search_term then return end
   State.mouse_down = mouse_button
 --?   print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
@@ -273,7 +273,7 @@ function edit.mouse_press(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_press(State, line_index, x,y, mouse_button)
+        Drawing.mouse_press(State, line_index, x,y, mouse_button, is_touch, presses)
         return
       end
     end
@@ -286,12 +286,12 @@ function edit.mouse_press(State, x,y, mouse_button)
   State.selection1 = Text.final_text_loc_on_screen(State)
 end
 
-function edit.mouse_release(State, x,y, mouse_button)
+function edit.mouse_release(State, x,y, mouse_button, is_touch, presses)
   if State.search_term then return end
 --?   print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
   State.mouse_down = nil
   if State.lines.current_drawing then
-    Drawing.mouse_release(State, x,y, mouse_button)
+    Drawing.mouse_release(State, x,y, mouse_button, is_touch, presses)
     if Drawing.before then
       record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)})
       Drawing.before = nil
@@ -377,7 +377,7 @@ function edit.text_input(State, t)
   schedule_save(State)
 end
 
-function edit.keychord_press(State, chord, key)
+function edit.keychord_press(State, chord, key, scancode, is_repeat)
   if State.selection1.line and
       not State.lines.current_drawing and
       -- printable character created using shift key => delete selection
@@ -496,7 +496,7 @@ function edit.keychord_press(State, chord, key)
     local drawing_index, drawing = Drawing.current_drawing(State)
     if drawing_index then
       local before = snapshot(State, drawing_index)
-      Drawing.keychord_press(State, chord)
+      Drawing.keychord_press(State, chord, key, scancode, is_repeat)
       record_undo_event(State, {before=before, after=snapshot(State, drawing_index)})
       schedule_save(State)
     end
@@ -529,7 +529,7 @@ function edit.keychord_press(State, chord, key)
     end
     schedule_save(State)
   else
-    Text.keychord_press(State, chord)
+    Text.keychord_press(State, chord, key, scancode, is_repeat)
   end
 end
 
diff --git a/keychord.lua b/keychord.lua
index dfde615..5de899d 100644
--- a/keychord.lua
+++ b/keychord.lua
@@ -8,7 +8,7 @@ function App.keypressed(key, scancode, is_repeat)
     return
   end
   -- include the modifier(s) when the non-modifer is pressed
-  App.keychord_press(App.combine_modifiers(key), key)
+  App.keychord_press(App.combine_modifiers(key), key, scancode, is_repeat)
 end
 
 function App.combine_modifiers(key)
diff --git a/log_browser.lua b/log_browser.lua
index 6e7e6db..fae9d6d 100644
--- a/log_browser.lua
+++ b/log_browser.lua
@@ -183,7 +183,7 @@ end
 function log_browser.quit(State)
 end
 
-function log_browser.mouse_press(State, x,y, mouse_button)
+function log_browser.mouse_press(State, x,y, mouse_button, is_touch, presses)
   local line_index = log_browser.line_index(State, x,y)
   if line_index == nil then
     -- below lower margin
@@ -249,7 +249,7 @@ function log_browser.line_index(State, mx,my)
   end
 end
 
-function log_browser.mouse_release(State, x,y, mouse_button)
+function log_browser.mouse_release(State, x,y, mouse_button, is_touch, presses)
 end
 
 function log_browser.mouse_wheel_move(State, dx,dy)
@@ -267,7 +267,7 @@ end
 function log_browser.text_input(State, t)
 end
 
-function log_browser.keychord_press(State, chord, key)
+function log_browser.keychord_press(State, chord, key, scancode, is_repeat)
   -- move
   if chord == 'up' then
     log_browser.up(State)
diff --git a/main.lua b/main.lua
index 4cca3b4..4ff3146 100644
--- a/main.lua
+++ b/main.lua
@@ -115,15 +115,15 @@ function check_love_version_for_tests()
   end
 end
 
-function App.initialize(arg)
+function App.initialize(arg, unfiltered_arg)
   love.keyboard.setKeyRepeat(true)
 
   love.graphics.setBackgroundColor(1,1,1)
 
   if Current_app == 'run' then
-    run.initialize(arg)
+    run.initialize(arg, unfiltered_arg)
   elseif Current_app == 'source' then
-    source.initialize(arg)
+    source.initialize(arg, unfiltered_arg)
   elseif current_app_is_warning() then
   else
     assert(false, 'unknown app "'..Current_app..'"')
@@ -209,7 +209,7 @@ function App.update(dt)
   end
 end
 
-function App.keychord_press(chord, key)
+function App.keychord_press(chord, key, scancode, is_repeat)
   -- ignore events for some time after window in focus (mostly alt-tab)
   if Current_time < Last_focus_time + 0.01 then
     return
@@ -253,9 +253,9 @@ function App.keychord_press(chord, key)
     return
   end
   if Current_app == 'run' then
-    if run.keychord_press then run.keychord_press(chord, key) end
+    if run.keychord_press then run.keychord_press(chord, key, scancode, is_repeat) end
   elseif Current_app == 'source' then
-    if source.keychord_press then source.keychord_press(chord, key) end
+    if source.keychord_press then source.keychord_press(chord, key, scancode, is_repeat) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -295,24 +295,24 @@ function App.keyreleased(key, scancode)
   end
 end
 
-function App.mousepressed(x,y, mouse_button)
+function App.mousepressed(x,y, mouse_button, is_touch, presses)
   if current_app_is_warning() then return end
 --?   print('mouse press', x,y)
   if Current_app == 'run' then
-    if run.mouse_press then run.mouse_press(x,y, mouse_button) end
+    if run.mouse_press then run.mouse_press(x,y, mouse_button, is_touch, presses) end
   elseif Current_app == 'source' then
-    if source.mouse_press then source.mouse_press(x,y, mouse_button) end
+    if source.mouse_press then source.mouse_press(x,y, mouse_button, is_touch, presses) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
 end
 
-function App.mousereleased(x,y, mouse_button)
+function App.mousereleased(x,y, mouse_button, is_touch, presses)
   if current_app_is_warning() then return end
   if Current_app == 'run' then
-    if run.mouse_release then run.mouse_release(x,y, mouse_button) end
+    if run.mouse_release then run.mouse_release(x,y, mouse_button, is_touch, presses) end
   elseif Current_app == 'source' then
-    if source.mouse_release then source.mouse_release(x,y, mouse_button) end
+    if source.mouse_release then source.mouse_release(x,y, mouse_button, is_touch, presses) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
@@ -321,9 +321,9 @@ end
 function App.mousemoved(x,y, dx,dy, is_touch)
   if current_app_is_warning() then return end
   if Current_app == 'run' then
-    if run.mouse_move then run.mouse_move(dx,dy) end
+    if run.mouse_move then run.mouse_move(x,y, dx,dy, is_touch) end
   elseif Current_app == 'source' then
-    if source.mouse_move then source.mouse_move(dx,dy) end
+    if source.mouse_move then source.mouse_move(x,y, dx,dy, is_touch) end
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
diff --git a/run.lua b/run.lua
index 22be332..b1b6db2 100644
--- a/run.lua
+++ b/run.lua
@@ -11,7 +11,7 @@ function run.initialize_globals()
 end
 
 -- called only for real run
-function run.initialize(arg)
+function run.initialize(arg, unfiltered_arg)
   log_new('run')
   if Settings then
     run.load_settings()
@@ -100,7 +100,7 @@ function run.initialize_window_geometry()
   App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
 end
 
-function run.resize(w, h)
+function run.resize(w,h)
 --?   print(("Window resized to width: %d and height: %d."):format(w, h))
   App.screen.width, App.screen.height = w, h
   Text.redraw_all(Editor_state)
@@ -166,15 +166,15 @@ function absolutize(path)
   return path
 end
 
-function run.mouse_press(x,y, mouse_button)
+function run.mouse_press(x,y, mouse_button, is_touch, presses)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   love.keyboard.setTextInput(true)  -- bring up keyboard on touch screen
-  return edit.mouse_press(Editor_state, x,y, mouse_button)
+  return edit.mouse_press(Editor_state, x,y, mouse_button, is_touch, presses)
 end
 
-function run.mouse_release(x,y, mouse_button)
+function run.mouse_release(x,y, mouse_button, is_touch, presses)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.mouse_release(Editor_state, x,y, mouse_button)
+  return edit.mouse_release(Editor_state, x,y, mouse_button, is_touch, presses)
 end
 
 function run.mouse_wheel_move(dx,dy)
@@ -187,9 +187,9 @@ function run.text_input(t)
   return edit.text_input(Editor_state, t)
 end
 
-function run.keychord_press(chord, key)
+function run.keychord_press(chord, key, scancode, is_repeat)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
-  return edit.keychord_press(Editor_state, chord, key)
+  return edit.keychord_press(Editor_state, chord, key, scancode, is_repeat)
 end
 
 function run.key_release(key, scancode)
diff --git a/source.lua b/source.lua
index 1acef7f..f27a44f 100644
--- a/source.lua
+++ b/source.lua
@@ -56,7 +56,7 @@ function source.initialize_globals()
 end
 
 -- called only for real run
-function source.initialize()
+function source.initialize(arg, unfiltered_arg)
   log_new('source')
   if Settings and Settings.source then
     source.load_settings()
@@ -173,7 +173,7 @@ function source.initialize_window_geometry()
   App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
 end
 
-function source.resize(w, h)
+function source.resize(w,h)
 --?   print(("Window resized to width: %d and height: %d."):format(w, h))
   App.screen.width, App.screen.height = w, h
   Text.redraw_all(Editor_state)
@@ -283,7 +283,7 @@ function source.settings()
   }
 end
 
-function source.mouse_press(x,y, mouse_button)
+function source.mouse_press(x,y, mouse_button, is_touch, presses)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   love.keyboard.setTextInput(true)  -- bring up keyboard on touch screen
 --?   print('mouse click', x, y)
@@ -291,7 +291,7 @@ function source.mouse_press(x,y, mouse_button)
 --?   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_press(Editor_state, x,y, mouse_button)
+    edit.mouse_press(Editor_state, x,y, mouse_button, is_touch, presses)
     return
   end
   if x < Editor_state.right + Margin_right then
@@ -300,23 +300,23 @@ function source.mouse_press(x,y, mouse_button)
       Focus = 'edit'
       return
     end
-    edit.mouse_press(Editor_state, x,y, mouse_button)
+    edit.mouse_press(Editor_state, x,y, mouse_button, is_touch, presses)
   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_press(Log_browser_state, x,y, mouse_button)
+    log_browser.mouse_press(Log_browser_state, x,y, mouse_button, is_touch, presses)
   end
 end
 
-function source.mouse_release(x,y, mouse_button)
+function source.mouse_release(x,y, mouse_button, is_touch, presses)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   if Focus == 'edit' then
-    return edit.mouse_release(Editor_state, x,y, mouse_button)
+    return edit.mouse_release(Editor_state, x,y, mouse_button, is_touch, presses)
   else
-    return log_browser.mouse_release(Log_browser_state, x,y, mouse_button)
+    return log_browser.mouse_release(Log_browser_state, x,y, mouse_button, is_touch, presses)
   end
 end
 
@@ -342,7 +342,7 @@ function source.text_input(t)
   end
 end
 
-function source.keychord_press(chord, key)
+function source.keychord_press(chord, key, scancode, is_repeat)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
 --?   print('source keychord')
   if Show_file_navigator then
@@ -382,9 +382,9 @@ function source.keychord_press(chord, key)
     return
   end
   if Focus == 'edit' then
-    return edit.keychord_press(Editor_state, chord, key)
+    return edit.keychord_press(Editor_state, chord, key, scancode, is_repeat)
   else
-    return log_browser.keychord_press(Log_browser_state, chord, key)
+    return log_browser.keychord_press(Log_browser_state, chord, key, scancode, is_repeat)
   end
 end
 
diff --git a/source_edit.lua b/source_edit.lua
index 91bcb58..77487ea 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -232,7 +232,7 @@ function edit.quit(State)
   end
 end
 
-function edit.mouse_press(State, x,y, mouse_button)
+function edit.mouse_press(State, x,y, mouse_button, is_touch, presses)
   if State.search_term then return end
   State.mouse_down = mouse_button
 --?   print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
@@ -279,7 +279,7 @@ function edit.mouse_press(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_press(State, line_index, x,y, mouse_button)
+        Drawing.mouse_press(State, line_index, x,y, mouse_button, is_touch, presses)
         return
       end
     end
@@ -292,12 +292,12 @@ function edit.mouse_press(State, x,y, mouse_button)
   State.selection1 = Text.final_text_loc_on_screen(State)
 end
 
-function edit.mouse_release(State, x,y, mouse_button)
+function edit.mouse_release(State, x,y, mouse_button, is_touch, presses)
   if State.search_term then return end
 --?   print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
   State.mouse_down = nil
   if State.lines.current_drawing then
-    Drawing.mouse_release(State, x,y, mouse_button)
+    Drawing.mouse_release(State, x,y, mouse_button, is_touch, presses)
     if Drawing.before then
       record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)})
       Drawing.before = nil
@@ -383,7 +383,7 @@ function edit.text_input(State, t)
   schedule_save(State)
 end
 
-function edit.keychord_press(State, chord, key)
+function edit.keychord_press(State, chord, key, scancode, is_repeat)
   if State.selection1.line and
       not State.lines.current_drawing and
       -- printable character created using shift key => delete selection
@@ -502,7 +502,7 @@ function edit.keychord_press(State, chord, key)
     local drawing_index, drawing = Drawing.current_drawing(State)
     if drawing_index then
       local before = snapshot(State, drawing_index)
-      Drawing.keychord_press(State, chord)
+      Drawing.keychord_press(State, chord, key, scancode, is_repeat)
       record_undo_event(State, {before=before, after=snapshot(State, drawing_index)})
       schedule_save(State)
     end
@@ -535,7 +535,7 @@ function edit.keychord_press(State, chord, key)
     end
     schedule_save(State)
   else
-    Text.keychord_press(State, chord)
+    Text.keychord_press(State, chord, key, scancode, is_repeat)
   end
 end
 
diff --git a/source_text.lua b/source_text.lua
index 284ed00..c281acf 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -223,7 +223,7 @@ function Text.insert_at_cursor(State, t)
 end
 
 -- Don't handle any keys here that would trigger text_input above.
-function Text.keychord_press(State, chord)
+function Text.keychord_press(State, chord, key, scancode, is_repeat)
 --?   print('chord', chord, State.selection1.line, State.selection1.pos)
   --== shortcuts that mutate text
   if chord == 'return' then
diff --git a/text.lua b/text.lua
index 4c87ad8..270a286 100644
--- a/text.lua
+++ b/text.lua
@@ -149,7 +149,7 @@ function Text.insert_at_cursor(State, t)
 end
 
 -- Don't handle any keys here that would trigger text_input above.
-function Text.keychord_press(State, chord)
+function Text.keychord_press(State, chord, key, scancode, is_repeat)
 --?   print('chord', chord, State.selection1.line, State.selection1.pos)
   --== shortcuts that mutate text (must schedule_save)
   if chord == 'return' then