Also tweak the scale to draw fewer tweaks.
KR33DR75FPD3WGIADGWUP6B6JAKZH5Q6OKIHKP4YD4KIVD3TI65QC
ND6BDFN7SOG6MEQAYX34HFNKQ6JCAWG3GU5VFMICVQLJM4VCRRMQC
GT3XZRTCVBWCSWUXAJ7N4OK2U2G5Y7EGSC5YE76KXZG7C4L53VTQC
RME4YP33NNUXA7HCHKUMB7UTNVGUCBDU3AZW3TDUTYL2CFZMNGOQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
AVTNUQYRBW7IX2YQ3KDLVQ23RGW3BAKTAE7P73ASBYNKOHMQMH5AC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
Y6O2RFHV5UGHFS3ZZEH5HPKN5I7SV74GEV47MTI4WGJPAINJMBZAC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
Menu_background_color = {r=0.6, g=0.8, b=0.6}
Menu_border_color = {r=0.6, g=0.7, b=0.6}
Menu_command_color = {r=0.2, g=0.2, b=0.2}
Menu_highlight_color = {r=0.5, g=0.7, b=0.3}
function draw_menu_bar()
if App.run_tests then return end -- disable in tests
App.color(Menu_background_color)
love.graphics.rectangle('fill', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_border_color)
love.graphics.rectangle('line', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_command_color)
Menu_cursor = 5
if Manifest_navigator.show then
draw_manifest_navigator()
return
end
add_hotkey_to_menu('ctrl+l: load definition')
add_hotkey_to_menu('ctrl+n: new definition')
add_hotkey_to_menu('ctrl+d: delete definition')
add_hotkey_to_menu('ctrl+f: find')
add_hotkey_to_menu('ctrl+left ctrl+right: prev/next word')
add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
add_hotkey_to_menu('ctrl+= ctrl+- ctrl+0: zoom')
end
function add_hotkey_to_menu(s)
local s_text = to_hud_text(s)
local width = App.width(s_text)
if Menu_cursor > App.screen.width - 30 then
return
end
App.color(Menu_command_color)
App.screen.draw(s_text, Menu_cursor,5)
Menu_cursor = Menu_cursor + width + 30
end
function load_from_iterator(f)
local result = {}
local i,line,drawing = 0, ''
while true do
local line = f()
if line == nil then break end
table.insert(result, {data=line})
end
if #result == 0 then
table.insert(result, {data=''})
end
return result
end
function draw_manifest_navigator()
App.color(Menu_command_color)
local filter_text = to_hud_text(Manifest_navigator.filter)
App.screen.draw(filter_text, 5, 5)
draw_cursor(5 + App.width(filter_text), 5)
if Manifest_navigator.num_lines == nil then
Manifest_navigator.num_lines = num_lines_for_manifest_navigator(Manifest_navigator.candidates)
end
App.color(Menu_background_color)
-- inefficient that we're computing this on every frame
-- so look only in the topmost line
local current_definition = live.get_cmd_from_buffer(Editor_state.lines[1].data)
love.graphics.rectangle('fill', 0,Menu_bar_height, App.screen.width, Manifest_navigator.num_lines * (HUD_line_height + --[[highlight padding]]5) + --[[extra highlight padding for bottom]] 2)
local x,y = 5, Menu_bar_height
for i,definition in ipairs(Manifest_navigator.candidates) do
if definition == current_definition then
if not Editor_state.saved then
definition = definition..'*'
end
else
if Cached_definitions[definition] and not Cached_definitions[definition].saved then
definition = definition..'*'
end
end
x,y = add_def_to_menu(x,y, definition, i == Manifest_navigator.index)
if Menu_cursor >= App.screen.width - 5 then
break
end
end
Manifest_navigator.bottom_y = y + HUD_line_height + --[[highlight padding]] 5
end
function draw_cursor(x, y)
-- blink every 0.5s
if math.floor(Cursor_time*2)%2 == 0 then
App.color(Cursor_color)
love.graphics.rectangle('fill', x,y, 3,HUD_line_height)
end
end
function manifest_navigator_candidates()
if Manifest_navigator.filter == '' then
return Manifest
end
local result = {}
for _,def in ipairs(Manifest) do
if starts_with(def, Manifest_navigator.filter) then
table.insert(result, def)
end
end
return result
end
function num_lines_for_manifest_navigator(candidates)
local result = 1
local x = 5
for i,def in ipairs(candidates) do
local width = App.width(to_hud_text(def))
if x + width > App.screen.width - 5 then
result = result+1
x = 5 + width
else
x = x + width + 30
end
end
return result
end
function add_def_to_menu(x,y, s, cursor_highlight)
local s_text = to_hud_text(s)
local width = App.width(s_text)
if x + width > App.screen.width - 5 then
y = y + HUD_line_height + --[[highlight padding]] 5
x = 5
end
local color = Menu_background_color
if cursor_highlight then
color = Menu_highlight_color
end
button(Editor_state, 'menu', {x=x-5, y=y-2, w=width+5*2, h=HUD_line_height+2*2, color=colortable(color),
onpress1 = function()
load_definition(s)
end
})
App.color(Menu_command_color)
App.screen.draw(s_text, x,y)
x = x + width + 30
return x,y
end
function reset_manifest_navigator()
Manifest_navigator.show = false
Manifest_navigator.index = 1
Manifest_navigator.filter = ''
Manifest_navigator.candidates = Manifest
Manifest_navigator.num_lines = num_lines_for_manifest_navigator(Manifest_navigator.candidates)
end
function keychord_press_on_manifest_navigator(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
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
function load_definition(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()
end
function get_definition_from_app(name)
live.send_to_app('GET '..name)
local response_string
repeat
love.timer.sleep(0.01)
response_string = live.receive_from_app()
until response_string
return response_string
end
function move_candidate_to_front_of_manifest(name)
local index = array.find(Manifest, name)
if index then
table.remove(Manifest, index)
table.insert(Manifest, 1, name)
end
end
function delete_definition(name)
live.send_to_app('DELETE '..name)
Manifest_navigator.reload = true
reset_manifest_navigator()
end
function manifest_navigator_up()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y-HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
function manifest_navigator_down()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y+HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
function manifest_coord(index)
local y,x = Menu_bar_height, 5
for i,definition in ipairs(Manifest_navigator.candidates) do
local width = App.width(to_hud_text(definition))
if x + width > App.screen.width - 5 then
y = y + HUD_line_height
x = 5
end
if i == index then
return y, x, width
end
x = x + width + 30
end
end
function manifest_index(fy, fx, fwidth)
local y,x = Menu_bar_height, 5
local best_guess, best_guess_x, best_guess_width
for i,definition in ipairs(Manifest_navigator.candidates) do
local width = App.width(to_hud_text(definition))
if x + width > App.screen.width - 5 then
y = y + HUD_line_height
x = 5
end
if y == fy then
if best_guess == nil then
best_guess = i
best_guess_x = x
best_guess_width = width
elseif math.abs(fx + fwidth/2 - x - width/2) < math.abs(fx + fwidth/2 - best_guess_x - best_guess_width/2) then
best_guess = i
best_guess_x = x
best_guess_width = width
end
end
x = x + width + 30
end
return best_guess
end
function text_input_on_manifest_navigator(t)
Manifest_navigator.filter = Manifest_navigator.filter..t
Manifest_navigator.candidates = manifest_navigator_candidates()
Manifest_navigator.index = 1
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()
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":641,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"add_def_to_menu":640,"manifest_navigator_candidates":638,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":641,"approximate":579,"sy":469,"approximate_up":583,"draw_cursor":639,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":642,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
draw_ticks = function()
local old_font = love.graphics.getFont()
love.graphics.setFont(Ticks_font)
love.graphics.setColor(0.6,0.6,0.6)
-- x axis
local lo, hi = Viewport.x, sx(App.screen.width)
local anchorhi, scale = approximate(hi, order_of_magnitude(hi-lo))
local anchorlo = approximate_up(lo, order_of_magnitude(hi-lo))
if (anchorhi-anchorlo)/scale < 5 then
scale = scale/4
elseif (anchorhi-anchorlo)/scale > 10 then
scale = scale*2.5
end
while vx(anchorlo-scale) > 0 do
anchorlo = anchorlo-scale
end
while vx(anchorhi+scale) < App.screen.width-20 do
anchorhi = anchorhi+scale
end
for x=anchorlo,anchorhi,scale do
love.graphics.line(vx(x), Menu_bar_height, vx(x), Menu_bar_height+5)
love.graphics.print(('%2.0f'):format(x), vx(x)+2, Menu_bar_height+5)
love.graphics.line(vx(x), App.screen.height, vx(x), App.screen.height-5)
love.graphics.print(('%2.0f'):format(x), vx(x)+2, App.screen.height-15)
end
-- y axis
local lo, hi = Viewport.y, sy(App.screen.height)
local anchorhi, scale = approximate(hi, order_of_magnitude(hi-lo))
local anchorlo = approximate_up(lo, order_of_magnitude(hi-lo))
if (anchorhi-anchorlo)/scale < 5 then
scale = scale/2
elseif (anchorhi-anchorlo)/scale > 10 then
scale = scale*2
end
while vy(anchorlo-scale) > Menu_bar_height+20 do
anchorlo = anchorlo-scale
end
while vy(anchorhi+scale) < App.screen.height-20 do
anchorhi = anchorhi+scale
end
for y=anchorlo,anchorhi,scale do
love.graphics.line(0, vy(y), 5, vy(y))
love.graphics.print(('%2.0f'):format(y), 5, vy(y)+2)
love.graphics.line(App.screen.width, vy(y), App.screen.width-5, vy(y))
love.graphics.print(('%2.0f'):format(y), App.screen.width-20, vy(y)+2)
end
love.graphics.setFont(old_font)
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":641,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"add_def_to_menu":640,"manifest_navigator_candidates":638,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":640,"approximate":579,"sy":469,"approximate_up":583,"draw_cursor":639,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
draw_menu_bar = function()
if App.run_tests then return end -- disable in tests
App.color(Menu_background_color)
love.graphics.rectangle('fill', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_border_color)
love.graphics.rectangle('line', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_command_color)
Menu_cursor = 5
if Manifest_navigator.show then
draw_manifest_navigator()
return
end
add_hotkey_to_menu('ctrl+l: load definition')
add_hotkey_to_menu('ctrl+n: new definition')
add_hotkey_to_menu('ctrl+d: delete definition')
add_hotkey_to_menu('ctrl+f: find')
add_hotkey_to_menu('ctrl+left ctrl+right: prev/next word')
add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
add_hotkey_to_menu('ctrl+= ctrl+- ctrl+0: zoom')
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"add_def_to_menu":640,"manifest_navigator_candidates":638,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":639,"approximate":579,"sy":469,"approximate_up":583,"draw_cursor":639,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
add_def_to_menu = function(x,y, s, cursor_highlight)
local s_text = to_hud_text(s)
local width = App.width(s_text)
if x + width > App.screen.width - 5 then
y = y + HUD_line_height + --[[highlight padding]] 5
x = 5
end
local color = Menu_background_color
if cursor_highlight then
color = Menu_highlight_color
end
button(HUD, 'menu', {x=x-5, y=y-2, w=width+5*2, h=HUD_line_height+2*2, color=colortable(color),
onpress1 = function()
load_definition(s)
end
})
App.color(Menu_command_color)
App.screen.draw(s_text, x,y)
x = x + width + 30
return x,y
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"manifest_navigator_candidates":638,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":638,"approximate":579,"sy":469,"approximate_up":583,"draw_cursor":639,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
draw_cursor = function(x, y)
-- blink every 0.5s
if math.floor(Cursor_time*2)%2 == 0 then
App.color(Cursor_color)
love.graphics.rectangle('fill', x,y, 3,HUD_line_height)
end
end
manifest_navigator_candidates = function()
if Manifest_navigator.filter == '' then
return Manifest
end
local result = {}
for _,def in ipairs(Manifest) do
if starts_with(def, Manifest_navigator.filter) then
table.insert(result, def)
end
end
return result
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"manifest_navigator_candidates":638,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":637,"approximate":579,"sy":469,"approximate_up":583,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
manifest_index = function(fy, fx, fwidth)
local y,x = Menu_bar_height, 5
local best_guess, best_guess_x, best_guess_width
for i,definition in ipairs(Manifest_navigator.candidates) do
local width = App.width(to_hud_text(definition))
if x + width > App.screen.width - 5 then
y = y + HUD_line_height
x = 5
end
if y == fy then
if best_guess == nil then
best_guess = i
best_guess_x = x
best_guess_width = width
elseif math.abs(fx + fwidth/2 - x - width/2) < math.abs(fx + fwidth/2 - best_guess_x - best_guess_width/2) then
best_guess = i
best_guess_x = x
best_guess_width = width
end
end
x = x + width + 30
end
return best_guess
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"manifest_index":637,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":636,"approximate":579,"sy":469,"approximate_up":583,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
manifest_coord = function(index)
local y,x = Menu_bar_height, 5
for i,definition in ipairs(Manifest_navigator.candidates) do
local width = App.width(to_hud_text(definition))
if x + width > App.screen.width - 5 then
y = y + HUD_line_height
x = 5
end
if i == index then
return y, x, width
end
x = x + width + 30
end
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"manifest_coord":636,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":635,"approximate":579,"sy":469,"approximate_up":583,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
manifest_navigator_down = function()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y+HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":635,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":634,"approximate":579,"sy":469,"approximate_up":583,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
text_input_on_manifest_navigator = function(t)
Manifest_navigator.filter = Manifest_navigator.filter..t
Manifest_navigator.candidates = manifest_navigator_candidates()
Manifest_navigator.index = 1
end
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":629,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":633,"approximate":579,"sy":469,"approximate_up":583,"text_input_on_manifest_navigator":634,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
{"update_editor_box":570,"on.mouse_release":554,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"Definitions":503,"new_definition":504,"Viewport":604,"box_height":345,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"keychord_press_on_manifest_navigator":633,"maybe_update_key_in_definitions":529,"delete_definition":631,"manifest_navigator_down":629,"manifest_navigator_up":628,"move_candidate_to_front_of_manifest":632,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"on_handle":547,"Manifest_navigator":495,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"sx":544,"vx":545,"vy":546,"Surface":422,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Manifest":494,"mouse_cursor":558,"Mouse_cursor":559,"on.update":561,"on.keychord_press":610,"font":353,"scale":7,"Page":475,"order_of_magnitude":573,"parent":632,"approximate":579,"sy":469,"approximate_up":583,"set_mouse_cursor":562,"on":1,"Ticks_font":594,"y_of_schema1":364,"initialize_editor":450,"B":379,"load_from_iterator":623,"get_definition_from_app":624,"draw_ticks":609,"line_height":365,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"add_thick_line":400}
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
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
move_candidate_to_front_of_manifest = function(name)
local index = array.find(Manifest, name)
if index then
table.remove(Manifest, index)
table.insert(Manifest, 1, name)
end
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"move_candidate_to_front_of_manifest":632,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"add_thick_line":400,"parent":631,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"on_handle":547,"Viewport":604,"on.update":561,"load_manifest":496,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.mouse_press":617,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"delete_definition":631,"on.initialize":506,"A":507,"manifest_navigator_down":629,"manifest_navigator_up":628,"on.mouse_release":554,"add_hotkey_to_menu":616,"line_height":365,"draw_ticks":609,"sy":469,"Menu_border_color":612,"Menu_command_color":613,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"get_definition_from_app":624,"load_from_iterator":623,"Ticks_font":594,"Manifest_navigator":495,"B":379,"draw_manifest_navigator":618,"initialize_editor":450,"on_text":539,"y_of_schema1":364,"Page":475,"approximate":579,"on":1,"set_mouse_cursor":562,"sx":544,"Manifest":494}
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"delete_definition":631,"manifest_navigator_down":629,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Manifest":494,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":630,"set_mouse_cursor":562,"on":1,"approximate":579,"manifest_navigator_up":628,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
delete_definition = function(name)
live.send_to_app('DELETE '..name)
Manifest_navigator.reload = true
reset_manifest_navigator()
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"manifest_navigator_down":629,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Manifest":494,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":629,"set_mouse_cursor":562,"on":1,"approximate":579,"manifest_navigator_up":628,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
manifest_navigator_down = function()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y+HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":627,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"manifest_navigator_down":629,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Manifest":494,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":628,"set_mouse_cursor":562,"on":1,"approximate":579,"manifest_navigator_up":628,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
manifest_navigator_up = function()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y-HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":627,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Manifest":494,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":627,"set_mouse_cursor":562,"on":1,"approximate":579,"manifest_navigator_up":628,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":627,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":626,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
function manifest_navigator_up()
local y, x, width = manifest_coord(Manifest_navigator.index)
local index = manifest_index(y-HUD_line_height, x, width)
if index then
Manifest_navigator.index = index
end
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":626,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":625,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
function delete_definition(name)
live.send_to_app('DELETE '..name)
Manifest_navigator.reload = true
reset_manifest_navigator()
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":625,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":624,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
function move_candidate_to_front_of_manifest(name)
local index = array.find(Manifest, name)
if index then
table.remove(Manifest, index)
table.insert(Manifest, 1, name)
end
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":622,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"get_definition_from_app":624,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":623,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
get_definition_from_app = function(name)
live.send_to_app('GET '..name)
local response_string
repeat
love.timer.sleep(0.01)
response_string = live.receive_from_app()
until response_string
return response_string
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":622,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"load_from_iterator":623,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":622,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
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, {data=line})
end
if #result == 0 then
table.insert(result, {data=''})
end
return result
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":622,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":621,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
function keychord_press_on_manifest_navigator(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
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
reset_manifest_navigator = function()
Manifest_navigator.show = false
Manifest_navigator.index = 1
Manifest_navigator.filter = ''
Manifest_navigator.candidates = Manifest
Manifest_navigator.num_lines = num_lines_for_manifest_navigator(Manifest_navigator.candidates)
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":620,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"reset_manifest_navigator":621,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":620,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"function":620,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":619,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
function text_input_on_manifest_navigator(t)
Manifest_navigator.filter = Manifest_navigator.filter..t
Manifest_navigator.candidates = manifest_navigator_candidates()
Manifest_navigator.index = 1
end
num_lines_for_manifest_navigator = function(candidates)
local result = 1
local x = 5
for i,def in ipairs(candidates) do
local width = App.width(to_hud_text(def))
if x + width > App.screen.width - 5 then
result = result+1
x = 5 + width
else
x = x + width + 30
end
end
return result
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"num_lines_for_manifest_navigator":619,"on.draw":565,"on.key_release":552,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":618,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"on.draw":565,"on.key_release":552,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":617,"set_mouse_cursor":562,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"draw_manifest_navigator":618,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
draw_manifest_navigator = function()
App.color(Menu_command_color)
local filter_text = to_hud_text(Manifest_navigator.filter)
App.screen.draw(filter_text, 5, 5)
draw_cursor(5 + App.width(filter_text), 5)
if Manifest_navigator.num_lines == nil then
Manifest_navigator.num_lines = num_lines_for_manifest_navigator(Manifest_navigator.candidates)
end
App.color(Menu_background_color)
love.graphics.rectangle('fill', 0,Menu_bar_height, App.screen.width, Manifest_navigator.num_lines * (HUD_line_height + --[[highlight padding]]5) + --[[extra highlight padding for bottom]] 2)
local x,y = 5, Menu_bar_height
for i,definition in ipairs(Manifest_navigator.candidates) do
x,y = add_def_to_menu(x,y, definition, i == Manifest_navigator.index)
if Menu_cursor >= App.screen.width - 5 then
break
end
end
Manifest_navigator.bottom_y = y + HUD_line_height + --[[highlight padding]] 5
end
on.mouse_press = function(x,y, mouse_button)
if Cursor_node then
Cursor_node.show_cursor = nil
Cursor_node = nil
end
if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then
return
end
local node = on_text(x,y)
if node then
-- position cursor in node
Cursor_node = node
edit.mouse_press(node.editor, x,y, mouse_button)
return
end
local node = on_handle(x,y)
if node then
-- move node
Move = {xoff=App.mouse_x()-vx(node.x), yoff=App.mouse_y()-vy(node.y), node=node}
return
end
-- pan surface
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
{"vx":545,"vy":546,"Surface":422,"update_editor_box":570,"on.draw":565,"on.key_release":552,"Cursor_node":172,"get_manifest":497,"on.text_input":521,"copy_shape":396,"schema1_of_y":467,"mouse_cursor":558,"Definitions":503,"Mouse_cursor":559,"new_definition":504,"Viewport":604,"on.update":561,"on.keychord_press":610,"font":353,"box_height":345,"scale":7,"compute_layout":385,"Menu_highlight_color":614,"on.code_change":306,"order_of_magnitude":573,"maybe_update_key_in_definitions":529,"parent":616,"on":1,"approximate":579,"Manifest":494,"initialize_editor":450,"Page":475,"y_of_schema1":364,"on.mouse_release":554,"sy":469,"line_height":365,"B":379,"approximate_up":583,"draw_menu_bar":615,"Menu_background_color":611,"Menu_border_color":612,"Menu_command_color":613,"Ticks_font":594,"Manifest_navigator":495,"draw_ticks":609,"set_mouse_cursor":562,"add_hotkey_to_menu":616,"on_text":539,"A":507,"on.initialize":506,"on.mouse_press":617,"load_manifest":496,"on_handle":547,"sx":544,"add_thick_line":400}
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"add_hotkey_to_menu":616,"vx":545,"Surface":422,"Menu_background_color":611,"Menu_command_color":613,"load_manifest":496,"Menu_border_color":612,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_highlight_color":614,"draw_menu_bar":615,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":615,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
add_hotkey_to_menu = function(s)
local s_text = to_hud_text(s)
local width = App.width(s_text)
if Menu_cursor > App.screen.width - 30 then
return
end
App.color(Menu_command_color)
App.screen.draw(s_text, Menu_cursor,5)
Menu_cursor = Menu_cursor + width + 30
end
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"vx":545,"Surface":422,"Menu_background_color":611,"Menu_command_color":613,"load_manifest":496,"Menu_border_color":612,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_highlight_color":614,"draw_menu_bar":615,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":614,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
draw_menu_bar = function()
if App.run_tests then return end -- disable in tests
App.color(Menu_background_color)
love.graphics.rectangle('fill', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_border_color)
love.graphics.rectangle('line', 0,0, App.screen.width, Menu_bar_height)
App.color(Menu_command_color)
Menu_cursor = 5
add_hotkey_to_menu('ctrl+l: load definition')
add_hotkey_to_menu('ctrl+n: new definition')
add_hotkey_to_menu('ctrl+d: delete definition')
add_hotkey_to_menu('ctrl+f: find')
add_hotkey_to_menu('ctrl+left ctrl+right: prev/next word')
add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
add_hotkey_to_menu('ctrl+= ctrl+- ctrl+0: zoom')
end
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"vx":545,"Menu_background_color":611,"Menu_command_color":613,"load_manifest":496,"Menu_border_color":612,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_highlight_color":614,"Surface":422,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":613,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
Menu_highlight_color = {r=0.5, g=0.7, b=0.3}
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"vx":545,"Menu_command_color":613,"load_manifest":496,"Menu_border_color":612,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_background_color":611,"Surface":422,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":612,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
Menu_command_color = {r=0.2, g=0.2, b=0.2}
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"vx":545,"load_manifest":496,"Menu_border_color":612,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_background_color":611,"Surface":422,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":611,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
Menu_border_color = {r=0.6, g=0.7, b=0.6}
{"sy":469,"update_editor_box":570,"scale":7,"on.update":561,"on.keychord_press":610,"on_handle":547,"schema1_of_y":467,"Ticks_font":594,"font":353,"on_text":539,"Cursor_node":172,"on.mouse_press":556,"on.code_change":306,"sx":544,"vx":545,"load_manifest":496,"get_manifest":497,"on.key_release":552,"Viewport":604,"Menu_background_color":611,"Surface":422,"add_thick_line":400,"Manifest_navigator":495,"Definitions":503,"approximate_up":583,"new_definition":504,"compute_layout":385,"box_height":345,"vy":546,"on.initialize":506,"A":507,"parent":610,"set_mouse_cursor":562,"mouse_cursor":558,"draw_ticks":609,"B":379,"line_height":365,"copy_shape":396,"Mouse_cursor":559,"on.draw":565,"maybe_update_key_in_definitions":529,"approximate":579,"on.mouse_release":554,"order_of_magnitude":573,"y_of_schema1":364,"Page":475,"initialize_editor":450,"on.text_input":521,"Manifest":494,"on":1}
Menu_background_color = {r=0.6, g=0.8, b=0.6}