Fix a few things
This commit is contained in:
parent
52325d20dd
commit
abf00254f1
|
@ -105,7 +105,7 @@ keymap.add_direct {
|
||||||
["ctrl+p"] = "core:find-file",
|
["ctrl+p"] = "core:find-file",
|
||||||
["ctrl+o"] = "core:open-file",
|
["ctrl+o"] = "core:open-file",
|
||||||
["ctrl+n"] = "core:new-doc",
|
["ctrl+n"] = "core:new-doc",
|
||||||
["ctrl+shift+c"] = "core:change-project-folder",
|
["ctrl+shift+c"] = "project:open-directory",
|
||||||
["ctrl+shift+o"] = "core:open-project-folder",
|
["ctrl+shift+o"] = "core:open-project-folder",
|
||||||
["alt+return"] = "core:toggle-fullscreen",
|
["alt+return"] = "core:toggle-fullscreen",
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,14 @@ function project.load(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function project.save(name)
|
||||||
|
name = name or core.project_name
|
||||||
|
local filename = common.path_join(USERDIR, "projects", name .. ".lua")
|
||||||
|
save_workspace(filename)
|
||||||
|
core.log("Saved project %s.", core.project_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function project.load_workspace(filename)
|
function project.load_workspace(filename)
|
||||||
local load = loadfile(filename)
|
local load = loadfile(filename)
|
||||||
local workspace = load and load()
|
local workspace = load and load()
|
||||||
|
@ -177,9 +185,7 @@ command.add(nil, {
|
||||||
core.command_view:enter("Save Project As", function(text)
|
core.command_view:enter("Save Project As", function(text)
|
||||||
-- FIXME: add sanity check of project name.
|
-- FIXME: add sanity check of project name.
|
||||||
core.project_name = text
|
core.project_name = text
|
||||||
local filename = common.path_join(USERDIR, "projects", text .. ".lua")
|
project.save()
|
||||||
save_workspace(filename)
|
|
||||||
core.log("Saved project %s.", core.project_name)
|
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -189,10 +195,7 @@ command.add(nil, {
|
||||||
core.project_name = text
|
core.project_name = text
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local filename = common.path_join(USERDIR, "projects", core.project_name .. ".lua")
|
project.save()
|
||||||
save_workspace(filename)
|
|
||||||
core.set_recent_project(core.project_name)
|
|
||||||
core.log("Saved project %s.", core.project_name)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["project:load"] = function()
|
["project:load"] = function()
|
||||||
|
@ -205,7 +208,6 @@ command.add(nil, {
|
||||||
["project:open-directory"] = function()
|
["project:open-directory"] = function()
|
||||||
core.command_view:enter("Open Directory", function(text, item)
|
core.command_view:enter("Open Directory", function(text, item)
|
||||||
text = system.absolute_path(common.home_expand(item and item.text or text))
|
text = system.absolute_path(common.home_expand(item and item.text or text))
|
||||||
if text == core.working_dir then return end
|
|
||||||
local path_stat = system.get_file_info(text)
|
local path_stat = system.get_file_info(text)
|
||||||
if not path_stat or path_stat.type ~= 'dir' then
|
if not path_stat or path_stat.type ~= 'dir' then
|
||||||
core.error("Cannot open folder %q", text)
|
core.error("Cannot open folder %q", text)
|
||||||
|
|
Loading…
Reference in New Issue