Allow tabs to always be visible

This commit is contained in:
Guldoman 2021-08-27 19:03:41 +02:00 committed by Francesco
parent 609795701d
commit c7d044f178
2 changed files with 14 additions and 3 deletions

View File

@ -12,6 +12,7 @@ config.non_word_chars = " \t\n/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-"
config.undo_merge_timeout = 0.3
config.max_undos = 10000
config.max_tabs = 10
config.always_show_tabs = false
config.highlight_current_line = true
config.line_height = 1.2
config.indent_size = 2

View File

@ -262,7 +262,7 @@ end
function Node:get_tab_overlapping_point(px, py)
if #self.views == 1 then return nil end
if not self:should_show_tabs() then return nil end
local tabs_number = self:get_visible_tabs_number()
local x1, y1, w, h = self:get_tab_rect(self.tab_offset)
local x2, y2 = self:get_tab_rect(self.tab_offset + tabs_number)
@ -272,6 +272,16 @@ function Node:get_tab_overlapping_point(px, py)
end
function Node:should_show_tabs()
if self.locked then return false end
if #self.views > 1 then return true
elseif config.always_show_tabs then
return not self.views[1]:is(EmptyView)
end
return false
end
local function close_button_location(x, w)
local cw = style.icon_font:get_width("C")
local pad = style.padding.y
@ -415,7 +425,7 @@ end
function Node:update_layout()
if self.type == "leaf" then
local av = self.active_view
if #self.views > 1 then
if self:should_show_tabs() then
local _, _, _, th = self:get_tab_rect(1)
av.position.x, av.position.y = self.position.x, self.position.y + th
av.size.x, av.size.y = self.size.x, self.size.y - th
@ -570,7 +580,7 @@ end
function Node:draw()
if self.type == "leaf" then
if #self.views > 1 then
if self:should_show_tabs() then
self:draw_tabs()
end
local pos, size = self.active_view.position, self.active_view.size