backport a few more changes from driver.love

None of these should affect behavior.
This commit is contained in:
Kartik K. Agaram 2023-04-22 22:29:22 -07:00
parent 0e3f1f7732
commit c3de51769c
5 changed files with 28 additions and 23 deletions

View File

@ -1,3 +1,4 @@
vx = function(x) vx = function(sx)
return scale(x-Viewport.x) -- turn surface coordinates into viewport coordinates
end return scale(sx-Viewport.x)
end

View File

@ -1,3 +1,4 @@
vy = function(y) vy = function(sy)
return scale(y-Viewport.y) -- turn surface coordinates into viewport coordinates
end return scale(sy-Viewport.y)
end

View File

@ -5,9 +5,11 @@ on.mouse_press = function(x,y, mouse_button)
end end
local node = to_text(x,y) local node = to_text(x,y)
if node then if node then
-- position cursor in node
Cursor_node = node Cursor_node = node
edit.mouse_press(node.editor, x,y, mouse_button) edit.mouse_press(node.editor, x,y, mouse_button)
else return
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
end end
-- pan surface
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
end end

View File

@ -1,16 +1,16 @@
box_height = function(node) box_height = function(node)
-- return the height of a node. The result is scaled. -- return the height of a text editor node (explicit width). The result is unscaled.
local y = 0 local y = 0
for i=1,#node.editor.lines do for i=1,#node.editor.lines do
local line = node.editor.lines[i] local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {} node.editor.line_cache[i] = {}
end end
node.editor.line_cache[i].fragments = nil node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil node.editor.line_cache[i].screen_line_starting_pos = nil
Text.populate_screen_line_starting_pos(node.editor, i) Text.populate_screen_line_starting_pos(node.editor, i)
y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_pos y = y + 20*1.3*#node.editor.line_cache[i].screen_line_starting_pos
Text.clear_screen_line_cache(node.editor, i) Text.clear_screen_line_cache(node.editor, i)
end end
return y return y
end end

View File

@ -1,8 +1,9 @@
on.mouse_release = function(x,y, mouse_button) on.mouse_release = function(x,y, mouse_button)
if Pan then if Pan then
Pan = nil Pan = nil
A()
elseif Cursor_node then elseif Cursor_node then
Cursor_node.show_cursor = true Cursor_node.show_cursor = true
edit.mouse_release(Cursor_node.editor, x,y, mouse_button) edit.mouse_release(Cursor_node.editor, x,y, mouse_button)
end end
end end