hoist f4-handling out of editor substrate
I'm not sure why I thought it was necessary to put it in there. The only difference in behavior from this commit: selecting text and hitting 'f4' used to delete the selected text before submitting. Now it no longer deletes. I've never relied on this. 'f4' needs no viewport book-keeping or A/B refreshing, so this should also be slightly less wasteful.
This commit is contained in:
parent
15832a1462
commit
9a610f3a13
|
@ -42,18 +42,22 @@ on.keychord_press = function(chord, key)
|
|||
Manifest_navigator.for_delete = true
|
||||
initialize_manifest_navigator()
|
||||
elseif Cursor_node then
|
||||
local old_top = {line=Cursor_node.editor.screen_top1.line, pos=Cursor_node.editor.screen_top1.pos}
|
||||
local old_definition_name = live.get_cmd_from_buffer(Cursor_node.editor.lines[1].data)
|
||||
edit.keychord_press(Cursor_node.editor, chord, key)
|
||||
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)
|
||||
end
|
||||
local definition_name = live.get_cmd_from_buffer(Cursor_node.editor.lines[1].data)
|
||||
maybe_update_key_in_definitions(old_definition_name, definition_name, Cursor_node)
|
||||
if chord == 'return' then
|
||||
A(--[[preserve screen_top of cursor node]] true)
|
||||
if chord == 'f4' then
|
||||
submit_definition(Cursor_node.editor)
|
||||
else
|
||||
B(--[[preserve screen_top of cursor node]] true)
|
||||
local old_top = {line=Cursor_node.editor.screen_top1.line, pos=Cursor_node.editor.screen_top1.pos}
|
||||
local old_definition_name = live.get_cmd_from_buffer(Cursor_node.editor.lines[1].data)
|
||||
edit.keychord_press(Cursor_node.editor, chord, key)
|
||||
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)
|
||||
end
|
||||
local definition_name = live.get_cmd_from_buffer(Cursor_node.editor.lines[1].data)
|
||||
maybe_update_key_in_definitions(old_definition_name, definition_name, Cursor_node)
|
||||
if chord == 'return' then
|
||||
A(--[[preserve screen_top of cursor node]] true)
|
||||
else
|
||||
B(--[[preserve screen_top of cursor node]] true)
|
||||
end
|
||||
end
|
||||
else
|
||||
if chord == 'up' then
|
||||
|
@ -88,4 +92,4 @@ on.keychord_press = function(chord, key)
|
|||
B()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
submit_definition = function(State)
|
||||
State.load_time_error = nil
|
||||
live.send_definition_to_app(State)
|
||||
while true do
|
||||
local response_string = live.receive_from_app()
|
||||
if response_string then
|
||||
Client_app_test_failures = json.decode(response_string)
|
||||
break
|
||||
end
|
||||
if live.receive_run_time_error_from_app() then
|
||||
break
|
||||
end
|
||||
love.timer.sleep(0.001)
|
||||
end
|
||||
if Load_time_error then
|
||||
State.load_time_error = Load_time_error
|
||||
Load_time_error = nil
|
||||
end
|
||||
if on.code_submit then on.code_submit(State) end
|
||||
end
|
22
edit.lua
22
edit.lua
|
@ -247,28 +247,8 @@ function edit.keychord_press(State, chord, key, readonly)
|
|||
chord ~= 'C-a' and chord ~= 'C-c' and chord ~= 'C-x' and chord ~= 'backspace' and chord ~= 'delete' and chord ~= 'C-z' and chord ~= 'C-y' and not App.is_cursor_movement(chord) then
|
||||
Text.delete_selection(State, State.left, State.right)
|
||||
end
|
||||
-- repl
|
||||
if chord == 'f4' then
|
||||
State.load_time_error = nil
|
||||
live.send_definition_to_app(State)
|
||||
while true do
|
||||
local response_string = live.receive_from_app()
|
||||
if response_string then
|
||||
Client_app_test_failures = json.decode(response_string)
|
||||
break
|
||||
end
|
||||
if live.receive_run_time_error_from_app() then
|
||||
break
|
||||
end
|
||||
love.timer.sleep(0.001)
|
||||
end
|
||||
if Load_time_error then
|
||||
State.load_time_error = Load_time_error
|
||||
Load_time_error = nil
|
||||
end
|
||||
if on.code_submit then on.code_submit(State) end
|
||||
-- search
|
||||
elseif State.search_term then
|
||||
if State.search_term then
|
||||
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
|
||||
if chord == 'escape' then
|
||||
State.search_term = nil
|
||||
|
|
Loading…
Reference in New Issue