start showing source menu file navigation state graphically
[?]
Sep 18, 2022, 8:11 AM
D3FLL7SL45CAFMGVOVABX75JBG4LGL4O35R5AIF3INW7N4VUP4DACDependencies
- [2]
QFTLLRGLindent - [3]
MDGHRTIFsource: up/down in file navigator - [4]
LZYLOTP3rename - [5]
ZQZX364Vuse a helper - [6]
NYRESFK6source: show all files in navigator - [7]
KKMFQDR4editing source code from within the app - [8]
QZ2SXLHFsome debug prints
Change contents
- edit in source.lua at line 2
log_render = {} - replacement in commands.lua at line 57
File_navigation.num_lines = source.num_lines_for_file_navigator()File_navigation.num_lines = source.num_lines_for_file_navigator(File_navigation.candidates) - replacement in commands.lua at line 60
love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height)love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height + --[[highlight padding]] 2) - replacement in commands.lua at line 74
function source.num_lines_for_file_navigator()function source.num_lines_for_file_navigator(candidates) - replacement in commands.lua at line 77
for i,filename in ipairs(File_navigation.candidates) dofor i,filename in ipairs(candidates) do - replacement in commands.lua at line 108
log(2, ('cursor initially at %d %s'):format(File_navigation.index, File_navigation.candidates[File_navigation.index]))log(2, {name='file_navigator_state', files=File_navigation.candidates, index=File_navigation.index}) - edit in commands.lua at line 127
endendfunction log_render.file_navigator_state(o, x,y, w)-- duplicate structure of source.draw_file_navigatorlocal num_lines = source.num_lines_for_file_navigator(o.files)local h = num_lines * Editor_state.line_heightApp.color(Menu_background_color)love.graphics.rectangle('fill', x,y, w,h)-- compute the x,y,width of the current index (in offsets from top left)local x2,y2 = 0,0local width = 0for i,filename in ipairs(o.files) dolocal filename_text = to_text(filename)width = App.width(filename_text)if x2 + width > App.screen.width - 5 theny2 = y2 + Editor_state.line_heightx2 = 0endif i == o.index thenbreakendx2 = x2 + width + 30 - edit in commands.lua at line 151
-- figure out how much of the menu to displaylocal menu_xmin = math.max(0, x2-w/2)local menu_xmax = math.min(App.screen.width, x2+w/2)-- now selectively print out entrieslocal x3,y3 = 0,y -- x3 is relative, y3 is absolutelocal width = 0for i,filename in ipairs(o.files) dolocal filename_text = to_text(filename)width = App.width(filename_text)if x3 + width > App.screen.width - 5 theny3 = y3 + Editor_state.line_heightx3 = 0endif i == o.index thenApp.color(Menu_highlight_color)love.graphics.rectangle('fill', x + x3-menu_xmin - 5, y3-2, width+5*2, Editor_state.line_height+2*2)endif x3 >= menu_xmin and x3 + width < menu_xmax thenApp.color(Menu_command_color)App.screen.draw(filename_text, x + x3-menu_xmin, y3)endx3 = x3 + width + 30end--return h+20