add args to some functions

- Text.to_pos_on_line
This commit is contained in:
Kartik K. Agaram 2022-07-08 15:45:45 -07:00
parent 9fb8f25030
commit abcc18002b
3 changed files with 5 additions and 6 deletions

View File

@ -353,7 +353,7 @@ function App.mousepressed(x,y, mouse_button)
Mousepress_shift = App.shift_down() Mousepress_shift = App.shift_down()
Selection1 = { Selection1 = {
line=line_index, line=line_index,
pos=Text.to_pos_on_line(line, x, y), pos=Text.to_pos_on_line(line, x, y, Margin_left, App.screen.width-Margin_right),
} }
--? print('selection', Selection1.line, Selection1.pos) --? print('selection', Selection1.line, Selection1.pos)
break break
@ -389,7 +389,7 @@ function App.mousereleased(x,y, button)
--? print('reset selection') --? print('reset selection')
Cursor1 = { Cursor1 = {
line=line_index, line=line_index,
pos=Text.to_pos_on_line(line, x, y), pos=Text.to_pos_on_line(line, x, y, Margin_left, App.screen.width-Margin_right),
} }
--? print('cursor', Cursor1.line, Cursor1.pos) --? print('cursor', Cursor1.line, Cursor1.pos)
if Mousepress_shift then if Mousepress_shift then

View File

@ -96,7 +96,7 @@ function Text.to_pos(x,y, left, right)
for line_index,line in ipairs(Lines) do for line_index,line in ipairs(Lines) do
if line.mode == 'text' then if line.mode == 'text' then
if Text.in_line(line, x,y, left, right) then if Text.in_line(line, x,y, left, right) then
return line_index, Text.to_pos_on_line(line, x,y) return line_index, Text.to_pos_on_line(line, x,y, left, right)
end end
end end
end end

View File

@ -672,8 +672,7 @@ function Text.in_line(line, x,y, left,right)
end end
-- convert mx,my in pixels to schema-1 coordinates -- convert mx,my in pixels to schema-1 coordinates
function Text.to_pos_on_line(line, mx, my) function Text.to_pos_on_line(line, mx, my, left, right)
--? print('Text.to_pos_on_line', mx, my, 'width', App.screen.width-Margin_right)
if line.fragments == nil then if line.fragments == nil then
Text.compute_fragments(line) Text.compute_fragments(line)
end end
@ -948,7 +947,7 @@ function Text.tweak_screen_top_and_cursor(left, right)
local line = Lines[Screen_bottom1.line] local line = Lines[Screen_bottom1.line]
Cursor1 = { Cursor1 = {
line=Screen_bottom1.line, line=Screen_bottom1.line,
pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5), pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5, left, right),
} }
end end
end end