Triggered by commit 62f8f2c498.
I'm not sure how to fix this, so I'm going to just document it in a couple of places for now. I also had to perform some low-level surgery going around the driver program.
WVKFFN6FAJVKUL6NGAOWSS33WFD63GPOPSLDQ7JT4WM27KV7H65QC
TGAAKKGGQZ6V6V25DGVHDXUXR74OYGG7RGRXVWKASDCONXZ63LYAC
FSDP53RPYP3MOPGRMOHQYISG24ZILVPKJC4X72S26TTQYSLDDSWQC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
VY24DRY6CZGUUURGPIYSL63HYTE22D573G5UX4MN55JORJ5GNW6AC
D4FEFHQCSILZFQ5VLWNXAIRZNUMCDNGJSM4UJ6T6FDMMIWYRYILQC
FS2ITYYHBLFT66YUC3ENPFYI2HOYHOVEPQIN7NQR6KF5MEK4NKZAC
ZTMRQZSWUL6FJRI4C4H37MR2IMV22DB6KRGEOUNYRWW5CTAVQFKAC
IDGP4BJZTKAD6ZO4RLAWYVN6IFCMIM76G6HJGPTE27K4D6CDBUHQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
CINOGX34U6PA3UZ6PXVIHH27KNNNHS26XOYNHPLO236HFQBG6I7QC
Y6O2RFHV5UGHFS3ZZEH5HPKN5I7SV74GEV47MTI4WGJPAINJMBZAC
2A3F3YUSKAKO7BKMYVZTEABRB2RPTVNY3H4KCO3NLPHUZPP7UL3QC
5OVKHVY6TJK53NCEUGSFBMHDENBJ25IEZNBWCI6QRCRLRKG5K7NAC
NVVHJWJEDPXPPRBBG3WBIXZJ3ZIHFWUOVQOZ25F2QY3VOQCZ5QWQC
WZZGVKSGCAEPDTHCT4IKNNAWDHUEATGOAT4FBLQUPF64CSJSNVJQC
* This app encourages a style of development that requires top-level
definitions to be decoupled from each other. No live functions load until
all definitions have been run. However top-level globals are initialized as
they're loaded. This makes a definition like this a very bad idea, assuming
`Foo` and `Bar` are top-level variables:
Foo = {
Bar
}
Don't assume that Bar will exist when Foo is defined. We don't currently
have any checks for this.
on.keychord_press = function(chord, key)
if Animating then return end
if Move then return end
if Manifest_navigator.reload then
load_manifest()
end
if chord == 'C-=' then
-- zoom in
Viewport.zoom = Viewport.zoom+0.1
B()
elseif chord == 'C--' then
-- zoom out
if (Viewport.zoom-0.1)*20 >= 1 then -- disallow font size of 0
Viewport.zoom = Viewport.zoom-0.1
B()
end
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
B()
elseif chord == 'C-q' then
live.send_to_app('QUIT')
elseif Manifest_navigator.show then
keychord_press_on_manifest_navigator(chord, key)
elseif chord == 'C-n' then
new_definition()
A()
elseif chord == 'C-l' then
Manifest_navigator.show = true
Manifest_navigator.for_delete = false
initialize_manifest_navigator()
elseif chord == 'C-d' then
Manifest_navigator.show = true
Manifest_navigator.for_delete = true
initialize_manifest_navigator()
elseif Cursor_node then
print('a', Cursor_node.editor.line_cache[1])
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)
B(--[[preserve screen_top of cursor node]] true)
else
if chord == 'up' then
Viewport.y = Viewport.y - scale(20)
B()
elseif chord == 'down' then
Viewport.y = Viewport.y + scale(20)
B()
elseif chord == 'left' then
Viewport.x = Viewport.x - scale(50)
B()
elseif chord == 'right' then
Viewport.x = Viewport.x + scale(50)
B()
elseif chord == 'pageup' then
Viewport.y = Viewport.y - App.screen.height/Viewport.zoom
B()
elseif chord == 'S-up' then
Viewport.y = Viewport.y - App.screen.height/Viewport.zoom
B()
elseif chord == 'pagedown' then
Viewport.y = Viewport.y + App.screen.height/Viewport.zoom
B()
elseif chord == 'S-down' then
Viewport.y = Viewport.y + App.screen.height/Viewport.zoom
B()
elseif chord == 'S-left' then
Viewport.x = Viewport.x - App.screen.width/Viewport.zoom
B()
elseif chord == 'S-right' then
Viewport.x = Viewport.x + App.screen.width/Viewport.zoom
B()
end
end
end
{"load_definition":716,"Manifest":769,"load_manifest":694,"get_manifest":768,"on.draw":565,"delete_definition":673,"Menu_background_color":611,"move_candidate_to_front_of_manifest":632,"on.load_settings":700,"Surface":422,"Menu_command_color":613,"text_input_on_manifest_navigator":634,"Menu_highlight_color":614,"vy":546,"table_and_array_both_empty":689,"Viewport":604,"manifest_navigator_candidates":638,"draw_manifest_navigator":677,"num_lines_for_manifest_navigator":676,"reset_manifest_navigator":772,"maybe_update_key_in_definitions":529,"load_from_iterator":670,"on.update":741,"get_definition_from_app":735,"font":353,"fw_app":"driver","sy":469,"manifest_navigator_down":635,"on":1,"initialize_manifest_navigator":773,"on_handle":547,"Manifest_navigator":495,"on_text":539,"on.mouse_press":722,"update_editor_box":711,"sx":544,"vx":545,"box_height":680,"schema1_of_y":667,"compute_layout":385,"on.key_release":720,"on.code_change":734,"y_of_schema1":364,"mouse_cursor":558,"Mouse_cursor":559,"add_hotkey_to_menu":616,"set_mouse_cursor":562,"Page":475,"draw_ticks":663,"on.mouse_release":721,"approximate":579,"tick_spec":660,"Menu_border_color":612,"scale":712,"on.text_input":521,"add_def_to_menu":640,"on.save_settings":742,"order_of_magnitude":573,"initialize_editor":678,"line_height":365,"Animating":770,"new_definition":767,"Cursor_node":172,"on.initialize":695,"draw_cursor":639,"A":713,"fw_parent":773,"manifest_navigator_up":628,"add_thick_line":400,"B":379,"copy_shape":396,"approximate_up":658,"manifest_coord":636,"on.keychord_press":774,"draw_menu_bar":641,"on.code_submit":766,"Ticks_font":669,"keychord_press_on_manifest_navigator":765,"Definitions":503,"manifest_index":637}
{"load_definition":716,"Manifest":769,"load_manifest":694,"get_manifest":768,"on.draw":565,"delete_definition":673,"Menu_background_color":611,"move_candidate_to_front_of_manifest":632,"on.load_settings":700,"Surface":422,"Menu_command_color":613,"text_input_on_manifest_navigator":634,"Menu_highlight_color":614,"vy":546,"table_and_array_both_empty":689,"Viewport":604,"manifest_navigator_candidates":638,"draw_manifest_navigator":677,"num_lines_for_manifest_navigator":676,"reset_manifest_navigator":772,"maybe_update_key_in_definitions":529,"load_from_iterator":670,"on.update":741,"get_definition_from_app":735,"font":353,"fw_app":"driver","sy":469,"manifest_navigator_down":635,"on":1,"initialize_manifest_navigator":773,"on_handle":547,"Manifest_navigator":495,"on_text":539,"on.mouse_press":722,"update_editor_box":711,"sx":544,"vx":545,"box_height":680,"schema1_of_y":667,"compute_layout":385,"on.key_release":720,"on.code_change":734,"y_of_schema1":364,"mouse_cursor":558,"Mouse_cursor":559,"add_hotkey_to_menu":616,"set_mouse_cursor":562,"Page":475,"draw_ticks":663,"on.mouse_release":721,"approximate":579,"tick_spec":660,"Menu_border_color":612,"scale":712,"on.text_input":521,"add_def_to_menu":640,"on.save_settings":742,"order_of_magnitude":573,"initialize_editor":678,"line_height":365,"Animating":770,"new_definition":767,"Cursor_node":172,"on.initialize":695,"draw_cursor":639,"A":713,"fw_parent":772,"manifest_navigator_up":628,"add_thick_line":400,"B":379,"copy_shape":396,"approximate_up":658,"manifest_coord":636,"on.keychord_press":739,"draw_menu_bar":641,"on.code_submit":766,"Ticks_font":669,"keychord_press_on_manifest_navigator":765,"Definitions":503,"manifest_index":637}
initialize_manifest_navigator = function()
Manifest_navigator.candidates = Manifest
Manifest_navigator.num_lines = num_lines_for_manifest_navigator(Manifest_navigator.candidates)
end
reset_manifest_navigator = function()
Manifest_navigator.show = false
Manifest_navigator.index = 1
Manifest_navigator.filter = ''
end
{"load_definition":716,"Manifest":769,"load_manifest":694,"get_manifest":768,"on.draw":565,"delete_definition":673,"Menu_background_color":611,"move_candidate_to_front_of_manifest":632,"on.load_settings":700,"Surface":422,"Menu_command_color":613,"text_input_on_manifest_navigator":634,"Menu_highlight_color":614,"vy":546,"table_and_array_both_empty":689,"Viewport":604,"manifest_navigator_candidates":638,"draw_manifest_navigator":677,"num_lines_for_manifest_navigator":676,"reset_manifest_navigator":772,"maybe_update_key_in_definitions":529,"load_from_iterator":670,"on.update":741,"get_definition_from_app":735,"font":353,"fw_app":"driver","sy":469,"manifest_navigator_down":635,"on":1,"on_handle":547,"Manifest_navigator":495,"on_text":539,"on.mouse_press":722,"update_editor_box":711,"sx":544,"vx":545,"box_height":680,"schema1_of_y":667,"compute_layout":385,"on.key_release":720,"on.code_change":734,"y_of_schema1":364,"mouse_cursor":558,"Mouse_cursor":559,"add_hotkey_to_menu":616,"set_mouse_cursor":562,"Page":475,"draw_ticks":663,"on.mouse_release":721,"approximate":579,"tick_spec":660,"Menu_border_color":612,"scale":712,"on.text_input":521,"add_def_to_menu":640,"on.save_settings":742,"order_of_magnitude":573,"initialize_editor":678,"line_height":365,"Animating":770,"new_definition":767,"Cursor_node":172,"on.initialize":695,"draw_cursor":639,"A":713,"fw_parent":771,"manifest_navigator_up":628,"add_thick_line":400,"B":379,"copy_shape":396,"approximate_up":658,"manifest_coord":636,"on.keychord_press":739,"draw_menu_bar":641,"on.code_submit":766,"Ticks_font":669,"keychord_press_on_manifest_navigator":765,"Definitions":503,"manifest_index":637}
-- ONE MAJOR GOTCHA
-- You might be used to programming with files. I think this approach is
-- superior, but it has one major drawback: you can't make any assumptions
-- about the order definitions are loaded in. In particular, don't mention one
-- global in the initialization of another.
--
-- Foo = { Bar }
--
-- Things might work fine for a long time before breaking.
--
-- As a corollary, never use the environment to modify this buffer. `on`
-- should always live in version id 1.
--
-- There are no such restrictions on function definitions.