start implementing stashed files
Dependencies
- [2]
JIERZ45Wresolve conflicts - [3]
GYFNSF33new menu option: revert local changes - [4]
JOY24JW6indicate local modifications in load/save dialog - [5]
FIUQJVL2first draft of load/save buttons - [6]
W4EQ6IW4simplify state management for menus - [7]
2IJLEJGTindicate local modifications in editor title bar - [8]
I2YECDRFdecouple menu font from output buffer - [9]
G5ZIPHJCmake it look more like a dialog - [10]
XJBUCJAGbugfix: skipping files near right margin - [11]
JV27LDDKsliders for font size and color settings - [12]
5RUFNRJOstart of the visual skeleton - [13]
BTMACW42resolve conflicts - [14]
PO77NPCOindicate unsaved changes - [15]
AZMYKWMHresolve conflicts - [16]
7QVNDHPEfilter file list based on input - [*]
R5QXEHUIsomebody 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) doif filename:find(File_dialog_input_text) thenlocal w = Font:getWidth(filename) + 10if x ~= Menu_left+10 and x+w > Safe_width-Menu_left-10 thenx = Menu_left+10y = y+Line_height+10if y > Safe_height-Menu_bottom-10 thenbreakendendstyled_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+10endendreturn yend - file addition: 0187-directory_contents[18.2]
directory_contents = function(directory)contents = {}local filenames = App.files(directory)for _,filename in ipairs(filenames) dolocal file_info = App.file_info(directory..filename)if file_info.type == 'file' thentable.insert(contents, filename)endendtable.sort(contents)return contentsend - file addition: 0186-press_stash_button[18.2]
press_stash_button = function()-- disable local modifications to a file without deleting it or saving the paneShow_menu = nilstash_pane(Current_pane)end - file addition: 0185-stash_pane[18.2]
stash_pane = function(pane)local src = Directory..pane.filenamelocal contents, error = love.filesystem.read(src)if not contents then return print_to_output(error) endlove.filesystem.createDirectory(Stash_directory)local dest = Stash_directory..pane.filenamelocal success, error = love.filesystem.write(dest, contents)if not success then return print_to_output(error) endlove.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
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
return overflowable_button('revert', x, y, r, press_revert_button, --[[final button?]] false)return overflowable_button('revert', x, y, r, press_revert_button) - edit in 0127-one_time_load at line 9
-- Clear some other recent stateCurrent_pane.stash_note = nilCurrent_pane.editor_state.next_save = nil - replacement in 0119-draw_file_dialog at line 32
refresh_directory_contents()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+10for _,filename in ipairs(Directory_contents) doif filename:find(File_dialog_input_text) thenlocal w = Font:getWidth(filename) + 10if x ~= Menu_left+10 and x+w > Safe_width-Menu_left-10 thenx = Menu_left+10y = y+Line_height+10if y > Safe_height-Menu_bottom-10 thenbreakendendstyled_button(filename, x,y, function()File_dialog_callback(filename)reset_file_dialog_state()end,--[[tooltip text]] nil,local_modifications_color(filename))x = x+w+10endlocal 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 enabledStash_directory_contents = directory_contents(Stash_directory) - edit in 0119-draw_file_dialog at line 39
y = y+Line_height+20App.color{r=1, g=1, b=1}g.print('stashed files:', Menu_left+10, y)y = y+Line_height+5y = 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
if not Current_pane.stash_note thenx, y = stash_button(x, y, r)end - replacement in 0021-draw_menu at line 36
end[5.5795]end - replacement in 0020-draw_editor_border at line 21
if has_local_modifications(Current_pane.filename) thenif Current_pane.stash_note thenApp.color(Stash_color)elseif has_local_modifications(Current_pane.filename) then