diff --git a/0021-draw_menu b/0021-draw_menu index c8c5e4f..f7a8075 100644 --- a/0021-draw_menu +++ b/0021-draw_menu @@ -15,11 +15,13 @@ draw_menu = function() x, y = load_button(x, y, r) 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.is_stash then + if Current_pane.filename then + if has_local_modifications(Current_pane.filename) then x, y = stash_button(x, y, r) + x, y = revert_button(x, y, r) + elseif can_be_unstashed(Current_pane) then + x, y = unstash_button(x, y, r) end - x, y = revert_button(x, y, r) end x, y = new_pane_button(x, y, r) x, y = delete_pane_button(x, y, r) diff --git a/0191-unstash_button b/0191-unstash_button new file mode 100644 index 0000000..9f02be4 --- /dev/null +++ b/0191-unstash_button @@ -0,0 +1,3 @@ +unstash_button = function(x,y, r) + return overflowable_button('unstash', x, y, r, press_unstash_button) +end \ No newline at end of file diff --git a/0192-press_unstash_button b/0192-press_unstash_button new file mode 100644 index 0000000..2a83f54 --- /dev/null +++ b/0192-press_unstash_button @@ -0,0 +1,5 @@ +press_unstash_button = function() + -- disable local modifications to a file without deleting it or saving the pane + Show_menu = nil + unstash_pane(Current_pane) +end \ No newline at end of file diff --git a/0193-unstash_pane b/0193-unstash_pane new file mode 100644 index 0000000..77def63 --- /dev/null +++ b/0193-unstash_pane @@ -0,0 +1,12 @@ +unstash_pane = function(pane) + local src = Stash_directory..pane.filename + local contents, error = love.filesystem.read(src) + if not contents then return print_to_output(error) end + love.filesystem.createDirectory(Directory) + local filename = unstash_filename(pane.filename) + local dest = Directory..filename + local success, error = love.filesystem.write(dest, contents) + if not success then return print_to_output(error) end + pane.filename = filename + pane.is_stash = nil +end \ No newline at end of file diff --git a/0194-unstash_filename b/0194-unstash_filename new file mode 100644 index 0000000..5afafa7 --- /dev/null +++ b/0194-unstash_filename @@ -0,0 +1,3 @@ +unstash_filename = function(filename) + return filename:gsub('%..*', '') +end \ No newline at end of file diff --git a/0195-can_be_unstashed b/0195-can_be_unstashed new file mode 100644 index 0000000..f86538e --- /dev/null +++ b/0195-can_be_unstashed @@ -0,0 +1,6 @@ +can_be_unstashed = function(pane) + if not pane.is_stash then return end + assert(pane.filename) + local filename = unstash_filename(pane.filename) + return not nativefs.getInfo(App.save_dir..Directory..filename) +end \ No newline at end of file