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 source.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_status_bar_height) App.color(Menu_border_color) love.graphics.rectangle('line', 0,0, App.screen.width, Menu_status_bar_height) App.color(Menu_command_color) Menu_cursor = 5 if Show_file_navigator then source.draw_file_navigator() return end add_hotkey_to_menu('ctrl+e: run') if Focus == 'edit' then add_hotkey_to_menu('ctrl+g: switch file') if Show_log_browser_side then add_hotkey_to_menu('ctrl+l: hide log browser') else add_hotkey_to_menu('ctrl+l: show log browser') end add_hotkey_to_menu('ctrl+k: clear logs') if Editor_state.expanded then add_hotkey_to_menu('alt+b: collapse debug prints') else add_hotkey_to_menu('alt+b: expand debug prints') end add_hotkey_to_menu('alt+d: create/edit debug print') add_hotkey_to_menu('ctrl+f: find in file') add_hotkey_to_menu('alt+left alt+right: prev/next word') elseif Focus == 'log_browser' then -- nothing yet else assert(false, 'unknown focus "'..Focus..'"') end 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 width = App.width(s) if Menu_cursor > App.screen.width - 30 then return end App.color(Menu_command_color) App.screen.print(s, Menu_cursor,5) Menu_cursor = Menu_cursor + width + 30 end function source.draw_file_navigator() App.color(Menu_command_color) App.screen.print(File_navigation.filter, 5, 5) draw_cursor(5 + App.width(File_navigation.filter), 5) if File_navigation.num_lines == nil then File_navigation.num_lines = source.num_lines_for_file_navigator(File_navigation.candidates) end App.color(Menu_background_color) love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height + --[[highlight padding]] 2) local x,y = 5, Menu_status_bar_height for i,filename in ipairs(File_navigation.candidates) do x,y = add_file_to_menu(x,y, filename, i == File_navigation.index) if Menu_cursor >= App.screen.width - 5 then break end end 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,Editor_state.line_height) end end function source.file_navigator_candidates() if File_navigation.filter == '' then return File_navigation.all_candidates end local result = {} for _,filename in ipairs(File_navigation.all_candidates) do if starts_with(filename, File_navigation.filter) then table.insert(result, filename) end end return result end function source.num_lines_for_file_navigator(candidates) local result = 1 local x = 5 for i,filename in ipairs(candidates) do local width = App.width(filename) 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_file_to_menu(x,y, s, cursor_highlight) local width = App.width(s) if x + width > App.screen.width - 5 then y = y + Editor_state.line_height 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=Editor_state.line_height+2*2, bg=color, onpress1 = function() navigate_to_file(s) end }) App.color(Menu_command_color) App.screen.print(s, x,y) x = x + width + 30 return x,y end function navigate_to_file(s) move_candidate_to_front(s) source.switch_to_file(s..'.lua') love.window.setTitle('lines.love - source - '..Editor_state.filename) reset_file_navigator() end function move_candidate_to_front(s) local index = array.find(File_navigation.all_candidates, s) assert(index, 'file missing from manifest') table.remove(File_navigation.all_candidates, index) table.insert(File_navigation.all_candidates, 1, s) end function reset_file_navigator() Show_file_navigator = false File_navigation.index = 1 File_navigation.filter = '' File_navigation.candidates = File_navigation.all_candidates end function keychord_press_on_file_navigator(chord, key) log(2, 'file navigator: '..chord) log(2, {name='fi