Skip to content

Commit 8aa35b2

Browse files
Adding tabchars and tabdist options
1 parent c1493bd commit 8aa35b2

File tree

7 files changed

+90
-16
lines changed

7 files changed

+90
-16
lines changed

internal/config/settings.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ var DefaultGlobalOnlySettings = map[string]any{
129129
"savehistory": true,
130130
"scrollbarchar": "|",
131131
"sucmd": "sudo",
132+
"tabchars": "active=[]",
133+
"tabdist": float64(2),
132134
"tabhighlight": false,
133-
"tabreverse": true,
135+
"tabreverse": false,
134136
"xterm": false,
135137
}
136138

internal/display/tabwindow.go

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/zyedidia/micro/v2/internal/config"
77
"github.com/zyedidia/micro/v2/internal/screen"
88
"github.com/zyedidia/micro/v2/internal/util"
9+
"strings"
10+
"unicode/utf8"
911
)
1012

1113
type TabWindow struct {
@@ -37,7 +39,7 @@ func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
3739
return i
3840
}
3941
x += s
40-
x += 3
42+
x += 1 + int(config.GetGlobalOption("tabdist").(float64))
4143
if x >= w.Width {
4244
break
4345
}
@@ -111,12 +113,27 @@ func (w *TabWindow) Display() {
111113
if style, ok := config.Colorscheme["tabbar.active"]; ok {
112114
tabBarActiveStyle = style
113115
}
116+
tabBarInactiveStyle := tabBarStyle
117+
if style, ok := config.Colorscheme["tabbar.inactive"]; ok {
118+
tabBarInactiveStyle = style
119+
}
120+
tabBarDivStyle := tabBarStyle
121+
if style, ok := config.Colorscheme["tabbar.div"]; ok {
122+
tabBarDivStyle = style
123+
}
114124

115-
draw := func(r rune, n int, active bool, tab bool) {
125+
draw := func(r rune, n int, active bool, tab bool, div bool) {
116126
style := tabBarStyle
117-
if active {
118-
style = tabBarActiveStyle
127+
if tab {
128+
if active {
129+
style = tabBarActiveStyle
130+
} else {
131+
style = tabBarInactiveStyle
132+
}
133+
} else if div {
134+
style = tabBarDivStyle
119135
}
136+
120137
for i := 0; i < n; i++ {
121138
rw := runewidth.RuneWidth(r)
122139
for j := 0; j < rw; j++ {
@@ -138,27 +155,64 @@ func (w *TabWindow) Display() {
138155
}
139156
}
140157

158+
var tabactivechars string
159+
var tabinactivechars string
160+
var tabdivchars string
161+
for _, entry := range strings.Split(config.GetGlobalOption("tabchars").(string), ",") {
162+
split := strings.SplitN(entry, "=", 2)
163+
if len(split) < 2 {
164+
continue
165+
}
166+
key, val := split[0], split[1]
167+
switch key {
168+
case "active":
169+
tabactivechars = val
170+
case "inactive":
171+
tabinactivechars = val
172+
case "div":
173+
tabdivchars = val
174+
}
175+
}
176+
177+
if utf8.RuneCountInString(tabactivechars) < 2 {
178+
tabactivechars += strings.Repeat(" ", 2-utf8.RuneCountInString(tabactivechars))
179+
}
180+
if utf8.RuneCountInString(tabinactivechars) < 2 {
181+
tabinactivechars += strings.Repeat(" ", 2-utf8.RuneCountInString(tabinactivechars))
182+
}
183+
if utf8.RuneCountInString(tabinactivechars) < 2 {
184+
tabinactivechars += strings.Repeat(" ", 2-utf8.RuneCountInString(tabinactivechars))
185+
}
186+
tabdist := int(config.GetGlobalOption("tabdist").(float64))
187+
if utf8.RuneCountInString(tabdivchars) < tabdist {
188+
tabdivchars += strings.Repeat(" ", tabdist-utf8.RuneCountInString(tabdivchars))
189+
}
190+
tabactiverunes := []rune(tabactivechars)
191+
tabinactiverunes := []rune(tabinactivechars)
192+
tabdivrunes := []rune(tabdivchars)
141193
for i, n := range w.Names {
142194
if i == w.active {
143-
draw('[', 1, true, true)
195+
draw(tabactiverunes[0], 1, true, true, false)
144196
} else {
145-
draw(' ', 1, false, true)
197+
draw(tabinactiverunes[0], 1, false, true, false)
146198
}
147199

148200
for _, c := range n {
149-
draw(c, 1, i == w.active, true)
201+
draw(c, 1, i == w.active, true, false)
150202
}
151203

152204
if i == len(w.Names)-1 {
153205
done = true
154206
}
155207

156208
if i == w.active {
157-
draw(']', 1, true, true)
158-
draw(' ', 2, true, false)
209+
draw(tabactiverunes[1], 1, true, true, false)
159210
} else {
160-
draw(' ', 1, false, true)
161-
draw(' ', 2, false, false)
211+
draw(tabinactiverunes[1], 1, false, true, false)
212+
}
213+
214+
for j := 0; j < tabdist; j++ {
215+
draw(tabdivrunes[j], 1, false, false, true)
162216
}
163217

164218
if x >= w.Width {
@@ -167,6 +221,6 @@ func (w *TabWindow) Display() {
167221
}
168222

169223
if x < w.Width {
170-
draw(' ', w.Width-x, false, globalTabReverse)
224+
draw(' ', w.Width-x, false, false, false)
171225
}
172226
}

runtime/colorschemes/gotham.micro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ color-link cursor-line "#091F2E"
2525
color-link color-column "#11151C"
2626
color-link symbol "#99D1CE,#0C1014"
2727
color-link match-brace "#0C1014,#D26937"
28+
color-link tabbar "#0C1014,#99D1CE"
2829
color-link tab-error "#D75F5F"
2930
color-link trailingws "#D75F5F"

runtime/colorschemes/monokai-dark.micro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ color-link cursor-line "#323232"
2525
color-link color-column "#323232"
2626
color-link match-brace "#1D0000,#AE81FF"
2727
color-link tab-error "#D75F5F"
28+
color-link tabbar "#1D0000,#D5D8D6"
2829
color-link trailingws "#D75F5F"

runtime/colorschemes/sunny-day.micro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ color-link cursor-line "229"
2626
color-link current-line-number "246"
2727
color-link match-brace "230,22"
2828
color-link tab-error "210"
29+
color-link tabbar "230,0"
2930
color-link trailingws "210"

runtime/help/colors.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ color support comes in three flavors.
4040
same regardless of the configured 16-color palette. However, the color
4141
range is fairly limited due to the small number of colors available.
4242
Default 256-color colorschemes include `monokai`, `twilight`, `zenburn`,
43-
`darcula` and more.
43+
`dracula` and more.
4444

4545
* true-color: Some terminals support displaying "true color" with 16 million
4646
colors using standard RGB values. This mode will be able to support
@@ -179,6 +179,8 @@ Here is a list of the colorscheme groups that you can use:
179179
* statusline.suggestions (Color of the autocomplete suggestions menu)
180180
* tabbar (Color of the tabbar that lists open files)
181181
* tabbar.active (Color of the active tab in the tabbar)
182+
* tabbar.inactive (Color of the inactive tabs in the tabbar)
183+
* tabbar.div (Color of the space/divider between each tab in the tabbar)
182184
* indent-char (Color of the character which indicates tabs if the option is
183185
enabled)
184186
* line-number

runtime/help/options.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,24 @@ Here are the available options:
460460

461461
default value: `true`
462462

463+
* `tabchars`: sets what visual characters to be shown for various tab options.
464+
This option is specified in the form of `key1=value1,key2=value2,...`.
465+
466+
Here are the list of keys:
467+
- `active`: the opening and closing tab characters for the current active tab.
468+
- `div`: the characters to be filled between each tab.
469+
- `inactive`: the opening and closing tab characters for the inactive tabs.
470+
471+
default value: `active=[]`
472+
473+
* `tabdist`: the distance between each tab.
474+
475+
default value: `2`
463476

464477
* `tabhighlight`: highlighting the current active tab by using the inverted tab bar color.
465478
Has no effect if `tabbar.active` is present in the current colorscheme.
466479

467-
default value: `true`
480+
default value: `false`
468481

469482
* `tabmovement`: navigate spaces at the beginning of lines as if they are tabs
470483
(e.g. move over 4 spaces at once). This option only does anything if
@@ -474,7 +487,7 @@ Here are the available options:
474487

475488
* `tabreverse`: reverses the tab bar colors.
476489

477-
default value: `true`
490+
default value: `false`
478491

479492
* `tabsize`: the size in spaces that a tab character should be displayed with.
480493

0 commit comments

Comments
 (0)