start showing source menu file navigation state graphically

[?]
Sep 18, 2022, 8:11 AM
D3FLL7SL45CAFMGVOVABX75JBG4LGL4O35R5AIF3INW7N4VUP4DAC

Dependencies

Change contents

  • edit in source.lua at line 2
    [4.165779]
    [4.165779]
    log_render = {}
  • replacement in commands.lua at line 57
    [4.72][4.72:142]()
    File_navigation.num_lines = source.num_lines_for_file_navigator()
    [4.72]
    [4.142]
    File_navigation.num_lines = source.num_lines_for_file_navigator(File_navigation.candidates)
  • replacement in commands.lua at line 60
    [4.183][4.183:315]()
    love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height)
    [4.183]
    [4.315]
    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
    [4.206553][4.427:474]()
    function source.num_lines_for_file_navigator()
    [4.206553]
    [4.474]
    function source.num_lines_for_file_navigator(candidates)
  • replacement in commands.lua at line 77
    [4.507][4.507:565]()
    for i,filename in ipairs(File_navigation.candidates) do
    [4.507]
    [2.29]
    for i,filename in ipairs(candidates) do
  • replacement in commands.lua at line 108
    [3.65][3.65:186]()
    log(2, ('cursor initially at %d %s'):format(File_navigation.index, File_navigation.candidates[File_navigation.index]))
    [3.65]
    [4.207173]
    log(2, {name='file_navigator_state', files=File_navigation.candidates, index=File_navigation.index})
  • edit in commands.lua at line 127
    [3.303]
    [3.303]
    end
    end
    function log_render.file_navigator_state(o, x,y, w)
    -- duplicate structure of source.draw_file_navigator
    local num_lines = source.num_lines_for_file_navigator(o.files)
    local h = num_lines * Editor_state.line_height
    App.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,0
    local width = 0
    for i,filename in ipairs(o.files) do
    local filename_text = to_text(filename)
    width = App.width(filename_text)
    if x2 + width > App.screen.width - 5 then
    y2 = y2 + Editor_state.line_height
    x2 = 0
    end
    if i == o.index then
    break
    end
    x2 = x2 + width + 30
  • edit in commands.lua at line 151
    [3.309]
    [3.309]
    -- figure out how much of the menu to display
    local menu_xmin = math.max(0, x2-w/2)
    local menu_xmax = math.min(App.screen.width, x2+w/2)
    -- now selectively print out entries
    local x3,y3 = 0,y -- x3 is relative, y3 is absolute
    local width = 0
    for i,filename in ipairs(o.files) do
    local filename_text = to_text(filename)
    width = App.width(filename_text)
    if x3 + width > App.screen.width - 5 then
    y3 = y3 + Editor_state.line_height
    x3 = 0
    end
    if i == o.index then
    App.color(Menu_highlight_color)
    love.graphics.rectangle('fill', x + x3-menu_xmin - 5, y3-2, width+5*2, Editor_state.line_height+2*2)
    end
    if x3 >= menu_xmin and x3 + width < menu_xmax then
    App.color(Menu_command_color)
    App.screen.draw(filename_text, x + x3-menu_xmin, y3)
    end
    x3 = x3 + width + 30
    end
    --
    return h+20