mouse wheel support
This commit is contained in:
parent
609f0b2fc8
commit
99faf61abb
14
edit.lua
14
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
|
||||
|
|
|
@ -263,25 +263,27 @@ end
|
|||
function log_browser.mouse_release(State, x,y, mouse_button)
|
||||
end
|
||||
|
||||
function log_browser.mouse_wheel_move(State, dx,dy)
|
||||
if dy > 0 then
|
||||
for i=1,math.floor(dy) do
|
||||
log_browser.up(State)
|
||||
end
|
||||
else
|
||||
for i=1,math.floor(-dy) do
|
||||
log_browser.down(State)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function log_browser.text_input(State, t)
|
||||
end
|
||||
|
||||
function log_browser.keychord_press(State, chord, key)
|
||||
-- move
|
||||
if chord == 'up' then
|
||||
while State.screen_top1.line > 1 do
|
||||
State.screen_top1.line = State.screen_top1.line-1
|
||||
if should_show(State.lines[State.screen_top1.line]) then
|
||||
break
|
||||
end
|
||||
end
|
||||
log_browser.up(State)
|
||||
elseif chord == 'down' then
|
||||
while State.screen_top1.line < #State.lines do
|
||||
State.screen_top1.line = State.screen_top1.line+1
|
||||
if should_show(State.lines[State.screen_top1.line]) then
|
||||
break
|
||||
end
|
||||
end
|
||||
log_browser.down(State)
|
||||
elseif chord == 'pageup' then
|
||||
local y = 0
|
||||
while State.screen_top1.line > 1 and y < App.screen.height - 100 do
|
||||
|
@ -301,6 +303,24 @@ function log_browser.keychord_press(State, chord, key)
|
|||
end
|
||||
end
|
||||
|
||||
function log_browser.up(State)
|
||||
while State.screen_top1.line > 1 do
|
||||
State.screen_top1.line = State.screen_top1.line-1
|
||||
if should_show(State.lines[State.screen_top1.line]) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function log_browser.down(State)
|
||||
while State.screen_top1.line < #State.lines do
|
||||
State.screen_top1.line = State.screen_top1.line+1
|
||||
if should_show(State.lines[State.screen_top1.line]) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function log_browser.height(State, line_index)
|
||||
local line = State.lines[line_index]
|
||||
if line.data == nil then
|
||||
|
|
10
main.lua
10
main.lua
|
@ -250,6 +250,16 @@ function App.mousereleased(x,y, mouse_button)
|
|||
end
|
||||
end
|
||||
|
||||
function App.wheelmoved(dx,dy)
|
||||
if Current_app == 'run' then
|
||||
if run.mouse_wheel_move then run.mouse_wheel_move(dx,dy) end
|
||||
elseif Current_app == 'source' then
|
||||
if source.mouse_wheel_move then source.mouse_wheel_move(dx,dy) end
|
||||
else
|
||||
assert(false, 'unknown app "'..Current_app..'"')
|
||||
end
|
||||
end
|
||||
|
||||
function love.quit()
|
||||
if Current_app == 'run' then
|
||||
local source_settings = Settings.source
|
||||
|
|
5
run.lua
5
run.lua
|
@ -163,6 +163,11 @@ function run.mouse_release(x,y, mouse_button)
|
|||
return edit.mouse_release(Editor_state, x,y, mouse_button)
|
||||
end
|
||||
|
||||
function run.mouse_wheel_move(x,y)
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
return edit.mouse_wheel_move(Editor_state, x,y)
|
||||
end
|
||||
|
||||
function run.text_input(t)
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
return edit.text_input(Editor_state, t)
|
||||
|
|
|
@ -323,6 +323,15 @@ function source.mouse_release(x,y, mouse_button)
|
|||
end
|
||||
end
|
||||
|
||||
function source.mouse_wheel_move(dx,dy)
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
if Focus == 'edit' then
|
||||
return edit.mouse_wheel_move(Editor_state, dx,dy)
|
||||
else
|
||||
return log_browser.mouse_wheel_move(Log_browser_state, dx,dy)
|
||||
end
|
||||
end
|
||||
|
||||
function source.text_input(t)
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
if Show_file_navigator then
|
||||
|
|
|
@ -305,6 +305,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
|
||||
|
|
Loading…
Reference in New Issue