about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-03-23 21:00:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-03-23 21:00:09 -0700
commit99faf61abbd90f3d5da40788adc43c2883beb470 (patch)
treec305911012de36605bbf62ccf0d2b5022c314922 /edit.lua
parent609f0b2fc850e9e6da8eb92b9d855c4e6ccf863b (diff)
downloadtext.love-99faf61abbd90f3d5da40788adc43c2883beb470.tar.gz
mouse wheel support
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/edit.lua b/edit.lua
index 60561bf..3f87551 100644
--- a/edit.lua
+++ b/edit.lua
@@ -304,6 +304,20 @@ function edit.mouse_release(State, x,y, mouse_button)
   end
 end
 
+function edit.mouse_wheel_move(State, dx,dy)
+  if dy > 0 then
+    State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
+    for i=1,math.floor(dy) do
+      Text.up(State)
+    end
+  else
+    State.cursor1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}
+    for i=1,math.floor(-dy) do
+      Text.down(State)
+    end
+  end
+end
+
 function edit.text_input(State, t)
   if State.search_term then
     State.search_term = State.search_term..t