Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/action/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func doSetGlobalOptionNative(option string, nativeValue any) error {
for _, b := range buffer.OpenBuffers {
b.UpdateRules()
}
} else if option == "infobar" || option == "keymenu" {
} else if option == "infobar" || option == "keymenu" || option == "tabalways" {
Tabs.Resize()
} else if option == "mouse" {
if !nativeValue.(bool) {
Expand Down
23 changes: 15 additions & 8 deletions internal/action/tab.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewTabList(bufs []*buffer.Buffer) *TabList {
iOffset := config.GetInfoBarOffset()
tl := new(TabList)
tl.List = make([]*Tab, len(bufs))
if len(bufs) > 1 {
if tabBarVisible(len(bufs)) {
for i, b := range bufs {
tl.List[i] = NewTabFromBuffer(0, 1, w, h-1-iOffset, b)
}
Expand Down Expand Up @@ -75,15 +75,22 @@ func (t *TabList) RemoveTab(id uint64) {
}
}

// tabBarVisible reports whether the tab bar should be drawn. It is normally
// only shown when more than one tab is open, but the tabalways option forces
// it to always be visible
func tabBarVisible(numTabs int) bool {
return numTabs > 1 || config.GetGlobalOption("tabalways").(bool)
}

// Resize resizes all elements within the tab list
// One thing to note is that when there is only 1 tab
// the tab bar should not be drawn so resizing must take
// One thing to note is that when the tab bar is hidden (only 1 tab open and
// tabalways off) the panes occupy the full height, so resizing must take
// that into account
func (t *TabList) Resize() {
w, h := screen.Screen.Size()
iOffset := config.GetInfoBarOffset()
InfoBar.Resize(w, h-1)
if len(t.List) > 1 {
if tabBarVisible(len(t.List)) {
for _, p := range t.List {
p.Y = 1
p.Node.Resize(w, h-1-iOffset)
Expand All @@ -107,7 +114,7 @@ func (t *TabList) HandleEvent(event tcell.Event) {
mx, my := e.Position()
switch e.Buttons() {
case tcell.Button1:
if my == t.Y && len(t.List) > 1 {
if my == t.Y && tabBarVisible(len(t.List)) {
if mx == 0 {
t.Scroll(-4)
} else if mx == t.Width-1 {
Expand All @@ -127,12 +134,12 @@ func (t *TabList) HandleEvent(event tcell.Event) {
return
}
case tcell.WheelUp:
if my == t.Y && len(t.List) > 1 {
if my == t.Y && tabBarVisible(len(t.List)) {
t.Scroll(4)
return
}
case tcell.WheelDown:
if my == t.Y && len(t.List) > 1 {
if my == t.Y && tabBarVisible(len(t.List)) {
t.Scroll(-4)
return
}
Expand All @@ -144,7 +151,7 @@ func (t *TabList) HandleEvent(event tcell.Event) {
// Display updates the names and then displays the tab bar
func (t *TabList) Display() {
t.UpdateNames()
if len(t.List) > 1 {
if tabBarVisible(len(t.List)) {
t.TabWindow.Display()
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ var DefaultGlobalOnlySettings = map[string]any{
"savehistory": true,
"scrollbarchar": "|",
"sucmd": "sudo",
"tabalways": false,
"tabhighlight": false,
"tabreverse": true,
"xterm": false,
Expand Down
5 changes: 5 additions & 0 deletions runtime/help/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ Here are the available options:

default value: `true`

* `tabalways`: always shows the tab bar, even when only one tab is open.

default value: `false`

* `tabhighlight`: inverts the tab characters' (filename, save indicator, etc)
colors with respect to the tab bar.

Expand Down Expand Up @@ -628,6 +632,7 @@ so that you can see what the formatting should look like.
"statusline": true,
"sucmd": "sudo",
"syntax": true,
"tabalways": false,
"tabhighlight": true,
"tabmovement": false,
"tabreverse": false,
Expand Down