parent
c0ea369607
commit
48b7de4fde
4
edit.lua
4
edit.lua
|
@ -200,7 +200,7 @@ function edit.mouse_pressed(State, x,y, mouse_button)
|
|||
|
||||
for line_index,line in ipairs(State.lines) do
|
||||
if line.mode == 'text' then
|
||||
if Text.in_line(State, line, x,y) then
|
||||
if Text.in_line(State, line_index, x,y) then
|
||||
-- delicate dance between cursor, selection and old cursor/selection
|
||||
-- scenarios:
|
||||
-- regular press+release: sets cursor, clears selection
|
||||
|
@ -245,7 +245,7 @@ function edit.mouse_released(State, x,y, mouse_button)
|
|||
else
|
||||
for line_index,line in ipairs(State.lines) do
|
||||
if line.mode == 'text' then
|
||||
if Text.in_line(State, line, x,y) then
|
||||
if Text.in_line(State, line_index, x,y) then
|
||||
--? print('reset selection')
|
||||
State.cursor1 = {
|
||||
line=line_index,
|
||||
|
|
|
@ -93,7 +93,7 @@ end
|
|||
function Text.to_pos(State, x,y)
|
||||
for line_index,line in ipairs(State.lines) do
|
||||
if line.mode == 'text' then
|
||||
if Text.in_line(State, line, x,y) then
|
||||
if Text.in_line(State, line_index, x,y) then
|
||||
return line_index, Text.to_pos_on_line(State, line, x,y)
|
||||
end
|
||||
end
|
||||
|
|
3
text.lua
3
text.lua
|
@ -693,7 +693,8 @@ function Text.snap_cursor_to_bottom_of_screen(State)
|
|||
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
|
||||
end
|
||||
|
||||
function Text.in_line(State, line, x,y)
|
||||
function Text.in_line(State, line_index, x,y)
|
||||
local line = State.lines[line_index]
|
||||
if line.starty == nil then return false end -- outside current page
|
||||
if x < State.left then return false end
|
||||
if y < line.starty then return false end
|
||||
|
|
Loading…
Reference in New Issue