start implementing stashed files

akkartik
Mar 17, 2024, 8:51 PM
NM2SILGFTYCIH7TDU3PU3U67J5KLZMDERTFLZQ3DA7WYGWPKEHKAC

Dependencies

  • [2] JIERZ45W resolve conflicts
  • [3] GYFNSF33 new menu option: revert local changes
  • [4] JOY24JW6 indicate local modifications in load/save dialog
  • [5] FIUQJVL2 first draft of load/save buttons
  • [6] W4EQ6IW4 simplify state management for menus
  • [7] 2IJLEJGT indicate local modifications in editor title bar
  • [8] I2YECDRF decouple menu font from output buffer
  • [9] G5ZIPHJC make it look more like a dialog
  • [10] XJBUCJAG bugfix: skipping files near right margin
  • [11] JV27LDDK sliders for font size and color settings
  • [12] 5RUFNRJO start of the visual skeleton
  • [13] BTMACW42 resolve conflicts
  • [14] PO77NPCO indicate unsaved changes
  • [15] AZMYKWMH resolve conflicts
  • [16] 7QVNDHPE filter file list based on input
  • [*] R5QXEHUI somebody stop me

Change contents

  • file addition: 0188-add_files_to_dialog (----------)
    [18.2]
    add_files_to_dialog = function(contents, x,y, colorfn)
    for _,filename in ipairs(contents) do
    if filename:find(File_dialog_input_text) then
    local w = Font:getWidth(filename) + 10
    if x ~= Menu_left+10 and x+w > Safe_width-Menu_left-10 then
    x = Menu_left+10
    y = y+Line_height+10
    if y > Safe_height-Menu_bottom-10 then
    break
    end
    end
    styled_button(filename, x,y, function()
    -- TODO: File_dialog_callback needs to somehow know to load stashed files.
    File_dialog_callback(filename)
    reset_file_dialog_state()
    end,
    --[[tooltip text]] nil,
    colorfn(filename))
    x = x+w+10
    end
    end
    return y
    end
  • file addition: 0187-directory_contents (----------)
    [18.2]
    directory_contents = function(directory)
    contents = {}
    local filenames = App.files(directory)
    for _,filename in ipairs(filenames) do
    local file_info = App.file_info(directory..filename)
    if file_info.type == 'file' then
    table.insert(contents, filename)
    end
    end
    table.sort(contents)
    return contents
    end
  • file addition: 0186-press_stash_button (----------)
    [18.2]
    press_stash_button = function()
    -- disable local modifications to a file without deleting it or saving the pane
    Show_menu = nil
    stash_pane(Current_pane)
    end
  • file addition: 0185-stash_pane (----------)
    [18.2]
    stash_pane = function(pane)
    local src = Directory..pane.filename
    local contents, error = love.filesystem.read(src)
    if not contents then return print_to_output(error) end
    love.filesystem.createDirectory(Stash_directory)
    local dest = Stash_directory..pane.filename
    local success, error = love.filesystem.write(dest, contents)
    if not success then return print_to_output(error) end
    love.filesystem.remove(src)
    pane.stash_note = ''
    end
  • file addition: 0184-Stash_directory (----------)
    [18.2]
    Stash_directory = 'stash/'
  • file addition: 0183-stash_button (----------)
    [18.2]
    stash_button = function(x,y, r)
    return overflowable_button('stash', x, y, r, press_stash_button)
    end
  • file addition: 0182-Stash_color (----------)
    [18.2]
    Stash_color = {r=0, g=0.3, b=0.6}
  • replacement in 0180-Local_modifications_color at line 1
    [4.181][4.182:227]()
    Local_modifications_color = {r=0.8, g=0, b=0}
    [4.181]
    Local_modifications_color = {r=0.7, g=0, b=0}
  • replacement in 0178-revert_button at line 2
    [3.365][3.365:460]()
    return overflowable_button('revert', x, y, r, press_revert_button, --[[final button?]] false)
    [3.365]
    [3.460]
    return overflowable_button('revert', x, y, r, press_revert_button)
  • edit in 0127-one_time_load at line 9
    [5.376]
    [5.376]
    -- Clear some other recent state
    Current_pane.stash_note = nil
    Current_pane.editor_state.next_save = nil
  • replacement in 0119-draw_file_dialog at line 32
    [5.1870][5.1870:1901]()
    refresh_directory_contents()
    [5.1870]
    [5.1901]
    Directory_contents = directory_contents(Directory)
  • replacement in 0119-draw_file_dialog at line 34
    [5.1906][5.1906:1998](),[5.1998][5.46:94](),[5.94][5.628:670](),[5.670][5.132:303](),[5.132][5.132:303](),[5.303][5.2359:2366](),[5.2359][5.2359:2366](),[5.2366][5.304:347](),[5.347][4.478:623](),[4.623][5.420:434](),[5.420][5.420:434](),[5.434][5.2366:2372](),[5.2366][5.2366:2372]()
    local x, y = Menu_left+10, Menu_bottom+10
    for _,filename in ipairs(Directory_contents) do
    if filename:find(File_dialog_input_text) then
    local w = Font:getWidth(filename) + 10
    if x ~= Menu_left+10 and x+w > Safe_width-Menu_left-10 then
    x = Menu_left+10
    y = y+Line_height+10
    if y > Safe_height-Menu_bottom-10 then
    break
    end
    end
    styled_button(filename, x,y, function()
    File_dialog_callback(filename)
    reset_file_dialog_state()
    end,
    --[[tooltip text]] nil,
    local_modifications_color(filename))
    x = x+w+10
    end
    [5.1906]
    [5.2372]
    local y = add_files_to_dialog(Directory_contents, Menu_left+10, Menu_bottom+10, local_modifications_color)
    if Stash_directory_contents == nil then
    -- on the first frame after dialog is enabled
    Stash_directory_contents = directory_contents(Stash_directory)
  • edit in 0119-draw_file_dialog at line 39
    [5.2377]
    [4.624]
    y = y+Line_height+20
    App.color{r=1, g=1, b=1}
    g.print('stashed files:', Menu_left+10, y)
    y = y+Line_height+5
    y = add_files_to_dialog(Stash_directory_contents, Menu_left+10, y,
    function(filename) return Stash_color end)
  • edit in 0021-draw_menu at line 19
    [3.750]
    [3.750]
    if not Current_pane.stash_note then
    x, y = stash_button(x, y, r)
    end
  • replacement in 0021-draw_menu at line 36
    [5.5795][2.159:163]()
    end
    [5.5795]
    end
  • replacement in 0020-draw_editor_border at line 21
    [5.322][5.325:382]()
    if has_local_modifications(Current_pane.filename) then
    [5.322]
    [4.842]
    if Current_pane.stash_note then
    App.color(Stash_color)
    elseif has_local_modifications(Current_pane.filename) then