Preliminary version of project manager
Adapted from contribute rxi/lite-plugins but changed to avoid restarting the application when switching project. Current problem: - the reload of the treeview take some time without any feedback for the user
This commit is contained in:
@@ -4,6 +4,7 @@ local style = require "core.style"
|
||||
local keymap = require "core.keymap"
|
||||
local Object = require "core.object"
|
||||
local View = require "core.view"
|
||||
local CommandView = require "core.commandview"
|
||||
local DocView = require "core.docview"
|
||||
|
||||
|
||||
@@ -376,6 +377,41 @@ function Node:draw()
|
||||
end
|
||||
|
||||
|
||||
function Node:is_empty()
|
||||
if self.type == "leaf" then
|
||||
return #self.views == 0
|
||||
else
|
||||
return self.a:is_empty() and self.b:is_empty()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Node:close_all_docviews()
|
||||
if self.type == "leaf" then
|
||||
local i = 1
|
||||
while i <= #self.views do
|
||||
local view = self.views[i]
|
||||
if view:is(DocView) and not view:is(CommandView) then
|
||||
table.remove(self.views, i)
|
||||
else
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
if #self.views == 0 and self.has_documents_view then
|
||||
self:add_view(EmptyView())
|
||||
end
|
||||
else
|
||||
self.a:close_all_docviews()
|
||||
self.b:close_all_docviews()
|
||||
if self.a:is_empty() then
|
||||
self:consume(self.b)
|
||||
elseif self.b:is_empty() then
|
||||
self:consume(self.a)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local RootView = View:extend()
|
||||
|
||||
@@ -437,6 +473,11 @@ function RootView:open_doc(doc)
|
||||
end
|
||||
|
||||
|
||||
function RootView:close_all_docviews()
|
||||
self.root_node:close_all_docviews()
|
||||
end
|
||||
|
||||
|
||||
function RootView:on_mouse_pressed(button, x, y, clicks)
|
||||
local div = self.root_node:get_divider_overlapping_point(x, y)
|
||||
if div then
|
||||
|
||||
Reference in New Issue
Block a user