Merge text0

This commit is contained in:
Kartik K. Agaram 2023-03-23 21:48:42 -07:00
commit 9390a4a418
3 changed files with 20 additions and 0 deletions

View File

@ -12,6 +12,7 @@ on = {
-- on.focus
-- on.mouse_press (see love.mousepressed)
-- on.mouse_release (see love.mousereleased)
-- on.mouse_wheel_move (see love.wheelmoved)
-- on.keychord_press (see keychord.lua in this repo)
-- on.text_input (see love.textinput)
-- on.key_release (see love.keyreleased)

View File

@ -205,6 +205,20 @@ function edit.mouse_release(State, x,y, mouse_button)
--? print('selection:', State.selection1.line, State.selection1.pos)
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
elseif dy < 0 then
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

View File

@ -139,6 +139,11 @@ function App.mousereleased(x,y, mouse_button)
if on.mouse_release then on.mouse_release(x,y, mouse_button) end
end
function App.wheelmoved(dx,dy)
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.mouse_wheel_move then on.mouse_wheel_move(dx,dy) end
end
function App.focus(in_focus)
if in_focus then
Last_focus_time = Current_time