diff --git a/0020-draw_editor_border b/0020-draw_editor_border index 17d1e1f..394ed36 100644 --- a/0020-draw_editor_border +++ b/0020-draw_editor_border @@ -18,7 +18,9 @@ draw_editor_border = function() filename = filename..' *' end local tx2 = tx1 + App.width(filename) - if has_local_modifications(Current_pane.filename) then + if Current_pane.stash_note then + App.color(Stash_color) + elseif has_local_modifications(Current_pane.filename) then App.color(Local_modifications_color) end love.graphics.print(filename, tx1, y1-15+5) diff --git a/0021-draw_menu b/0021-draw_menu index 66b21d0..7555fbc 100644 --- a/0021-draw_menu +++ b/0021-draw_menu @@ -16,6 +16,9 @@ draw_menu = function() x, y = paste_button(x, y, r) x, y = copy_button(x, y, r) if Current_pane.filename and has_local_modifications(Current_pane.filename) then + if not Current_pane.stash_note then + x, y = stash_button(x, y, r) + end x, y = revert_button(x, y, r) end x, y = new_pane_button(x, y, r) @@ -30,4 +33,4 @@ draw_menu = function() if Show_menu == 'settings' then draw_settings_menu() end -end +end \ No newline at end of file diff --git a/0119-draw_file_dialog b/0119-draw_file_dialog index 76fc7bd..08b269c 100644 --- a/0119-draw_file_dialog +++ b/0119-draw_file_dialog @@ -29,26 +29,17 @@ draw_file_dialog = function() 5,5) if Directory_contents == nil then -- on the first frame after dialog is enabled - refresh_directory_contents() + Directory_contents = directory_contents(Directory) end - 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 + 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) end + 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) end \ No newline at end of file diff --git a/0127-one_time_load b/0127-one_time_load index f7af8fb..a0d80a2 100644 --- a/0127-one_time_load +++ b/0127-one_time_load @@ -6,4 +6,7 @@ one_time_load = function() Text.redraw_all(Current_pane.editor_state) -- Disable autosave; undo isn't accessible in mobile devices. Current_pane.editor_state.filename = nil + -- Clear some other recent state + Current_pane.stash_note = nil + Current_pane.editor_state.next_save = nil end \ No newline at end of file diff --git a/0178-revert_button b/0178-revert_button index 580b619..2b6aba9 100644 --- a/0178-revert_button +++ b/0178-revert_button @@ -1,3 +1,3 @@ revert_button = function(x,y, r) - return overflowable_button('revert', x, y, r, press_revert_button, --[[final button?]] false) + return overflowable_button('revert', x, y, r, press_revert_button) end \ No newline at end of file diff --git a/0180-Local_modifications_color b/0180-Local_modifications_color index af791fc..e7ed570 100644 --- a/0180-Local_modifications_color +++ b/0180-Local_modifications_color @@ -1 +1 @@ -Local_modifications_color = {r=0.8, g=0, b=0} \ No newline at end of file +Local_modifications_color = {r=0.7, g=0, b=0} \ No newline at end of file diff --git a/0182-Stash_color b/0182-Stash_color new file mode 100644 index 0000000..0956cbd --- /dev/null +++ b/0182-Stash_color @@ -0,0 +1 @@ +Stash_color = {r=0, g=0.3, b=0.6} \ No newline at end of file diff --git a/0183-stash_button b/0183-stash_button new file mode 100644 index 0000000..f6a0ed2 --- /dev/null +++ b/0183-stash_button @@ -0,0 +1,3 @@ +stash_button = function(x,y, r) + return overflowable_button('stash', x, y, r, press_stash_button) +end \ No newline at end of file diff --git a/0184-Stash_directory b/0184-Stash_directory new file mode 100644 index 0000000..ea6a2cc --- /dev/null +++ b/0184-Stash_directory @@ -0,0 +1 @@ +Stash_directory = 'stash/' \ No newline at end of file diff --git a/0185-stash_pane b/0185-stash_pane new file mode 100644 index 0000000..ad70b65 --- /dev/null +++ b/0185-stash_pane @@ -0,0 +1,11 @@ +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 \ No newline at end of file diff --git a/0186-press_stash_button b/0186-press_stash_button new file mode 100644 index 0000000..e3dc565 --- /dev/null +++ b/0186-press_stash_button @@ -0,0 +1,5 @@ +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 \ No newline at end of file diff --git a/0187-directory_contents b/0187-directory_contents new file mode 100644 index 0000000..8d8f764 --- /dev/null +++ b/0187-directory_contents @@ -0,0 +1,12 @@ +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 \ No newline at end of file diff --git a/0188-add_files_to_dialog b/0188-add_files_to_dialog new file mode 100644 index 0000000..04df1d9 --- /dev/null +++ b/0188-add_files_to_dialog @@ -0,0 +1,23 @@ +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 \ No newline at end of file