Add command to create a directory in a new category "files"
Use the alt + (left click) is tree view to create a directory and shift + (middle click) to remove a project directory.
This commit is contained in:
@@ -137,12 +137,29 @@ function TreeView:on_mouse_moved(px, py)
|
||||
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)
|
||||
if not self.hovered_item then
|
||||
return
|
||||
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)
|
||||
elseif keymap.modkeys["alt"] and button == "left" then
|
||||
create_directory_in(self.hovered_item)
|
||||
else
|
||||
self.hovered_item.expanded = not self.hovered_item.expanded
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user