Merge luaML.love

This commit is contained in:
Kartik K. Agaram 2023-10-28 01:21:50 -07:00
commit db1e163956
4 changed files with 9 additions and 21 deletions

View File

@ -6,25 +6,14 @@ on.text_input = function(t)
local old_top = {line=Cursor_node.editor.screen_top1.line, pos=Cursor_node.editor.screen_top1.pos}
local old_definition_name = live.get_definition_name_from_buffer(live.definition_to_string(Cursor_node.editor))
edit.text_input(Cursor_node.editor, t)
if not eq(Cursor_node.editor.screen_top1, old_top) then
Viewport.y = Cursor_node.y + y_of_schema1(Cursor_node.editor, Cursor_node.editor.screen_top1)
-- Most of the time, we update the screen_top of nodes from Viewport.y.
-- But here we went the other way.
-- It's very important to avoid creating a recurrence, to avoid running
-- both sides of this feedback loop in a single frame. These apps are
-- not very numerically precise (e.g. we force text lines to start at
-- integer pixels regardless of zoom, because that keeps text crisp),
-- and the computations of Viewport.y and node.top will almost certainly
-- not converge. The resulting bugs are extremely difficult to chase
-- down.
-- The optional skip_updating_screen_top_for arg ensures we don't run
-- the other side of the feedback loop.
A(--[[skip updating screen_top for]] Cursor_node)
return
end
pan_viewport_to_contain_cursor(Cursor_node)
local definition_name = live.get_definition_name_from_buffer(live.definition_to_string(Cursor_node.editor))
maybe_update_key_in_definitions(old_definition_name, definition_name, Cursor_node)
Cursor_node.bg = definition_background_color(definition_name)
B()
if eq(Cursor_node.editor.screen_top1, old_top) then
B()
else
A()
end
end
end

View File

@ -1,6 +1,5 @@
update_editor_box = function(node, skip_updating)
update_editor_box = function(node)
if node.editor == nil then return end
if node == skip_updating then return end
if node.editor.font_height ~= scale(20) then
edit.update_font_settings(node.editor, scale(20))
end

View File

@ -185,7 +185,7 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking.
For example, `string.sub` should never use a `_pos`, only an `_offset`.
* Some ADT/interface support would be helpful in keeping per-line state in
sync. Any change to line data should clear line `fragments` and
sync. Any change to line data should clear the derived line property
`screen_line_starting_pos`.
* Some inputs get processed in love.textinput and some in love.keypressed.

View File

@ -119,7 +119,7 @@ function love.run()
App.files = nativefs.getDirectoryItems
App.mkdir = nativefs.createDirectory
App.remove = nativefs.remove
App.source_dir = love.filesystem.getSource()..'/'
App.source_dir = love.filesystem.getSource()..'/' -- '/' should work even on Windows
App.current_dir = nativefs.getWorkingDirectory()..'/'
App.save_dir = love.filesystem.getSaveDirectory()..'/'
App.get_time = love.timer.getTime