Makes resizable attribute explicit in Node:split()

This commit is contained in:
Francesco Abbate 2021-02-11 16:12:21 +01:00
parent c6a1323214
commit f482ea318a
3 changed files with 7 additions and 6 deletions

View File

@ -399,9 +399,10 @@ function core.init()
core.command_view = CommandView()
core.status_view = StatusView()
core.root_view.root_node.is_primary_node = true
core.root_view.root_node:split("down", core.command_view, true)
core.root_view.root_node.b:split("down", core.status_view, true)
local cur_node = core.root_view.root_node
cur_node.is_primary_node = true
cur_node = cur_node:split("down", core.command_view, true)
cur_node = cur_node:split("down", core.status_view, true)
core.project_scan_thread_id = core.add_thread(project_scan_thread)
command.add_defaults()

View File

@ -92,7 +92,7 @@ end
local type_map = { up="vsplit", down="vsplit", left="hsplit", right="hsplit" }
function Node:split(dir, view, locked)
function Node:split(dir, view, locked, resizable)
assert(self.type == "leaf", "Tried to split non-leaf node")
local type = assert(type_map[dir], "Invalid direction")
local last_active = core.active_view
@ -104,6 +104,7 @@ function Node:split(dir, view, locked)
if view then self.b:add_view(view) end
if locked then
self.b.locked = locked
self.b.resizable = resizable or false
core.set_active_view(last_active)
end
if dir == "up" or dir == "left" then

View File

@ -249,8 +249,7 @@ end
-- init
local view = TreeView()
local node = core.root_view:get_active_node()
local treeview_node = node:split("left", view, true)
treeview_node.resizable = true
local treeview_node = node:split("left", view, true, true)
-- register commands and keymap