6LYD2XCQC5OXNX22M4DQWIFAMW2DWRZFAN2JV4MGDTYMMZXWPZRQC
O4XAVDJWAM73TFGXRFXMB7Z4G2D4EQ6F2W6PY4SITYKGYF6ER7PQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
GT3XZRTCVBWCSWUXAJ7N4OK2U2G5Y7EGSC5YE76KXZG7C4L53VTQC
KR33DR75FPD3WGIADGWUP6B6JAKZH5Q6OKIHKP4YD4KIVD3TI65QC
OWBGSQM3PQWLWZ55GKXM6YA2B626GTCYKZTAUPQZ2F62KNFDJX2QC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
end
load_definition = function(name)
-- save current buffer locally
local old_buffer = live.definition_to_string(Editor_state)
if old_buffer:find('%s*%S') then
local old_definition_name = live.get_cmd_from_buffer(old_buffer)
Cached_definitions[old_definition_name] = {saved=Editor_state.saved, data=old_buffer}
end
--
if old_definition_name == name then return end -- don't clobber unsaved data
move_candidate_to_front_of_manifest(name)
-- load new buffer
Editor_state = edit.initialize_state(Menu_bar_height + Margin_top, Margin_left+Line_number_width, App.screen.width-Margin_right)
local definition_string, saved
if Cached_definitions[name] == nil then
-- from app
definition_string, saved = get_definition_from_app(name), true
else
-- from local store
definition_string, saved = Cached_definitions[name].data, Cached_definitions[name].saved
end
Editor_state.lines = load_from_iterator(definition_string:gmatch("[^\r\n]+"))
Editor_state.saved = saved
Text.redraw_all(Editor_state)
Editor_state.font_height = Font_height
HUD_line_height = Line_height
Editor_state.em = em
reset_manifest_navigator()
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":671,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":673,"keychord_press_on_manifest_navigator":675,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"line_height":365,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"load_definition":674,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":674,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
keychord_press_on_manifest_navigator = function(chord, key)
if chord == 'escape' then
reset_manifest_navigator()
elseif chord == 'return' then
if Manifest_navigator.delete then
delete_definition(Manifest_navigator.candidates[Manifest_navigator.index])
else
load_definition(Manifest_navigator.candidates[Manifest_navigator.index])
end
A()
reset_manifest_navigator()
elseif chord == 'backspace' then
local len = utf8.len(Manifest_navigator.filter)
local byte_offset = Text.offset(Manifest_navigator.filter, len)
Manifest_navigator.filter = string.sub(Manifest_navigator.filter, 1, byte_offset-1)
Manifest_navigator.index = 1
Manifest_navigator.candidates = manifest_navigator_candidates()
elseif chord == 'left' then
if Manifest_navigator.index > 1 then
Manifest_navigator.index = Manifest_navigator.index-1
end
elseif chord == 'right' then
if Manifest_navigator.index < #Manifest_navigator.candidates then
Manifest_navigator.index = Manifest_navigator.index+1
end
elseif chord == 'down' then
manifest_navigator_down()
elseif chord == 'up' then
manifest_navigator_up()
end
end
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":671,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":673,"keychord_press_on_manifest_navigator":672,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"line_height":365,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"load_definition":674,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":673,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
load_definition = function(name)
move_candidate_to_front_of_manifest(name)
if Definitions[name] then return end -- just one copy per definition for now
Definitions[name] = {
type='text',
data=load_from_iterator(get_definition_from_app(name):gmatch("[^\r\n]+")),
x=0, y=0,
width=400,
bg={r=0.7,g=0.7,b=1},
}
end
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":671,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":673,"keychord_press_on_manifest_navigator":672,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"line_height":365,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":672,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
delete_definition = function(name)
live.send_to_app('DELETE '..name)
Manifest_navigator.reload = true
end
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":671,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":631,"keychord_press_on_manifest_navigator":672,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"line_height":365,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":671,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
keychord_press_on_manifest_navigator = function(chord, key)
if chord == 'escape' then
reset_manifest_navigator()
elseif chord == 'return' then
if Manifest_navigator.delete then
delete_definition(Manifest_navigator.candidates[Manifest_navigator.index])
else
load_definition(Manifest_navigator.candidates[Manifest_navigator.index])
end
reset_manifest_navigator()
elseif chord == 'backspace' then
local len = utf8.len(Manifest_navigator.filter)
local byte_offset = Text.offset(Manifest_navigator.filter, len)
Manifest_navigator.filter = string.sub(Manifest_navigator.filter, 1, byte_offset-1)
Manifest_navigator.index = 1
Manifest_navigator.candidates = manifest_navigator_candidates()
elseif chord == 'left' then
if Manifest_navigator.index > 1 then
Manifest_navigator.index = Manifest_navigator.index-1
end
elseif chord == 'right' then
if Manifest_navigator.index < #Manifest_navigator.candidates then
Manifest_navigator.index = Manifest_navigator.index+1
end
elseif chord == 'down' then
manifest_navigator_down()
elseif chord == 'up' then
manifest_navigator_up()
end
end
new_definition = function()
table.insert(Definitions, {
type='text',
data={''},
x=0, y=0,
width=400,
bg={r=0.7,g=0.7,b=1},
})
end
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":671,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":631,"keychord_press_on_manifest_navigator":633,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"line_height":365,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":670,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
{"Ticks_font":669,"vy":546,"Manifest":494,"load_manifest":496,"get_manifest":497,"B":379,"Definitions":503,"new_definition":504,"Menu_background_color":611,"Menu_border_color":612,"text_input_on_manifest_navigator":634,"Menu_command_color":613,"Menu_highlight_color":614,"manifest_index":637,"Surface":422,"add_def_to_menu":640,"num_lines_for_manifest_navigator":619,"Cursor_node":172,"maybe_update_key_in_definitions":529,"on.keychord_press":666,"on":1,"on.text_input":521,"manifest_navigator_down":635,"delete_definition":631,"keychord_press_on_manifest_navigator":633,"tick_spec":660,"update_editor_box":570,"on.draw":565,"on_text":539,"schema1_of_y":667,"get_definition_from_app":624,"load_from_iterator":670,"on.mouse_press":617,"copy_shape":396,"y_of_schema1":364,"on.update":561,"on.key_release":552,"Page":475,"mouse_cursor":558,"Mouse_cursor":559,"on.initialize":506,"initialize_editor":450,"line_height":365,"set_mouse_cursor":562,"manifest_navigator_candidates":638,"draw_ticks":663,"font":353,"move_candidate_to_front_of_manifest":632,"draw_manifest_navigator":618,"manifest_coord":636,"draw_cursor":639,"manifest_navigator_up":628,"reset_manifest_navigator":621,"on.code_change":306,"order_of_magnitude":573,"A":507,"sy":469,"on.mouse_release":554,"box_height":345,"approximate":579,"compute_layout":385,"add_hotkey_to_menu":616,"draw_menu_bar":641,"scale":7,"Manifest_navigator":495,"parent":669,"add_thick_line":400,"Viewport":604,"approximate_up":658,"sx":544,"on_handle":547,"vx":545}
load_from_iterator = function(f)
local result = {}
local i,line,drawing = 0, ''
while true do
local line = f()
if line == nil then break end
table.insert(result, line)
end
if #result == 0 then
table.insert(result, '')
end
return result
end