Added doc:rename command; changed command_view:set_text to take select argument

This commit is contained in:
rxi
2020-05-09 16:09:07 +01:00
parent 7479c1380d
commit 70f62f3c8a
3 changed files with 25 additions and 9 deletions
+18 -2
View File
@@ -278,6 +278,10 @@ local commands = {
end)
end,
["doc:toggle-line-ending"] = function()
doc().crlf = not doc().crlf
end,
["doc:save-as"] = function()
if doc().filename then
core.command_view:set_text(doc().filename)
@@ -295,8 +299,20 @@ local commands = {
end
end,
["doc:toggle-line-ending"] = function()
doc().crlf = not doc().crlf
["doc:rename"] = function()
local old_filename = doc().filename
if not old_filename then
core.error("Cannot rename unsaved doc")
return
end
core.command_view:set_text(old_filename)
core.command_view:enter("Rename", function(filename)
doc():save(filename)
core.log("Renamed \"%s\" to \"%s\"", old_filename, filename)
if filename ~= old_filename then
os.remove(old_filename)
end
end, common.path_suggest)
end,
}