Compare commits
1 Commits
amiga2.1
...
files-comm
Author | SHA1 | Date |
---|---|---|
Francesco Abbate | 63331ac50c |
|
@ -59,7 +59,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function command.add_defaults()
|
function command.add_defaults()
|
||||||
local reg = { "core", "root", "command", "doc", "findreplace" }
|
local reg = { "core", "root", "command", "doc", "findreplace", "files" }
|
||||||
for _, name in ipairs(reg) do
|
for _, name in ipairs(reg) do
|
||||||
require("core.commands." .. name)
|
require("core.commands." .. name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
local core = require "core"
|
||||||
|
local command = require "core.command"
|
||||||
|
|
||||||
|
command.add(nil, {
|
||||||
|
["files:create-directory"] = function()
|
||||||
|
core.command_view:enter("New directory name", function(text)
|
||||||
|
local success, err = system.mkdir(text)
|
||||||
|
if not success then
|
||||||
|
core.error("cannot create directory %q: %s", text, err)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
})
|
|
@ -137,12 +137,29 @@ function TreeView:on_mouse_moved(px, py)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function create_directory_in(item)
|
||||||
|
local path = item.abs_filename
|
||||||
|
local basename = path:match("[^\\/]+$")
|
||||||
|
core.command_view:enter("Create directory in " .. basename, function(text)
|
||||||
|
local dirname = path .. PATHSEP .. text
|
||||||
|
local success, err = system.mkdir(dirname)
|
||||||
|
if not success then
|
||||||
|
core.error("cannot create directory %q: %s", dirname, err)
|
||||||
|
end
|
||||||
|
item.expanded = true
|
||||||
|
core.request_project_scan()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function TreeView:on_mouse_pressed(button, x, y)
|
function TreeView:on_mouse_pressed(button, x, y)
|
||||||
if not self.hovered_item then
|
if not self.hovered_item then
|
||||||
return
|
return
|
||||||
elseif self.hovered_item.type == "dir" then
|
elseif self.hovered_item.type == "dir" then
|
||||||
if button == "middle" and self.hovered_item.depth == 0 then
|
if keymap.modkeys["shift"] and button == "middle" and self.hovered_item.depth == 0 then
|
||||||
core.remove_project_directory(self.hovered_item.abs_filename)
|
core.remove_project_directory(self.hovered_item.abs_filename)
|
||||||
|
elseif keymap.modkeys["alt"] and button == "left" then
|
||||||
|
create_directory_in(self.hovered_item)
|
||||||
else
|
else
|
||||||
self.hovered_item.expanded = not self.hovered_item.expanded
|
self.hovered_item.expanded = not self.hovered_item.expanded
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue