Skip to content
Merged
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
5 changes: 5 additions & 0 deletions data/micro.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@
"type": "boolean",
"default": true
},
"tabalways": {
"description": "Whether to always show the tab bar, even when only one tab is open\nhttps://github.com/micro-editor/micro/blob/master/runtime/help/options.md#options",
"type": "boolean",
"default": false
},
"tabmovement": {
"description": "Whether to navigate spaces at the beginning of lines as if they are tabs\nhttps://github.com/micro-editor/micro/blob/master/runtime/help/options.md#options",
"type": "boolean",
Expand Down
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`

Comment on lines +465 to +468

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is so often the case with new options, micro.json is overlooked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated! FWIW, I left it alone because @dmaluka said "we don't care about keeping it up to date". I'm inclined to agree and would lean toward deleting it altogether, but that's beyond the scope of this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is often forgotten (from us too) or simply ignored and it breaks with single point of truth/failure I'm inclined to drop it as well.

* `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
Loading