Add text and select_text to CommandView options

This commit is contained in:
Guldoman
2022-06-02 19:30:51 +02:00
parent 6c89a3e575
commit ec58b1f0bd
6 changed files with 53 additions and 24 deletions
+5 -3
View File
@@ -448,13 +448,15 @@ local commands = {
["doc:save-as"] = function()
local last_doc = core.last_active_view and core.last_active_view.doc
local text
if doc().filename then
core.command_view:set_text(doc().filename)
text = doc().filename
elseif last_doc and last_doc.filename then
local dirname, filename = core.last_active_view.doc.abs_filename:match("(.*)[/\\](.+)$")
core.command_view:set_text(core.normalize_to_project_dir(dirname) .. PATHSEP)
text = core.normalize_to_project_dir(dirname) .. PATHSEP
end
core.command_view:enter("Save As", {
text = text,
submit = function(filename)
save(common.home_expand(filename))
end,
@@ -482,8 +484,8 @@ local commands = {
core.error("Cannot rename unsaved doc")
return
end
core.command_view:set_text(old_filename)
core.command_view:enter("Rename", {
text = old_filename,
submit = function(filename)
save(common.home_expand(filename))
core.log("Renamed \"%s\" to \"%s\"", old_filename, filename)