parent
a0702f4a97
commit
ccc67b66c4
@ -31,6 +31,10 @@ version 0.6.0 [future]
|
|||||||
|
|
||||||
- Add a command line switch to set the window title.
|
- Add a command line switch to set the window title.
|
||||||
|
|
||||||
|
- Add more options to customize the tab-bar's appearance (font styles and
|
||||||
|
separator)
|
||||||
|
|
||||||
|
|
||||||
version 0.5.1 [2017-12-01]
|
version 0.5.1 [2017-12-01]
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|||||||
@ -231,6 +231,20 @@ def box_drawing_scale(x):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
def tab_separator(x):
|
||||||
|
for q in '\'"':
|
||||||
|
if x.startswith(q) and x.endswith(q):
|
||||||
|
x = x[1:-1]
|
||||||
|
break
|
||||||
|
if not x.strip():
|
||||||
|
x = defaults.tab_separator
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
def tab_font_style(x):
|
||||||
|
return {'bold-italic': (True, True), 'bold': (True, False), 'italic': (False, True)}.get(x.lower().replace('_', '-'), (False, False))
|
||||||
|
|
||||||
|
|
||||||
type_map = {
|
type_map = {
|
||||||
'adjust_line_height': adjust_line_height,
|
'adjust_line_height': adjust_line_height,
|
||||||
'scrollback_lines': positive_int,
|
'scrollback_lines': positive_int,
|
||||||
@ -263,6 +277,9 @@ type_map = {
|
|||||||
'box_drawing_scale': box_drawing_scale,
|
'box_drawing_scale': box_drawing_scale,
|
||||||
'x11_bell_volume': int,
|
'x11_bell_volume': int,
|
||||||
'background_opacity': unit_float,
|
'background_opacity': unit_float,
|
||||||
|
'tab_separator': tab_separator,
|
||||||
|
'active_tab_font_style': tab_font_style,
|
||||||
|
'inactive_tab_font_style': tab_font_style,
|
||||||
}
|
}
|
||||||
|
|
||||||
for name in (
|
for name in (
|
||||||
|
|||||||
@ -175,11 +175,14 @@ active_border_color #00ff00
|
|||||||
# The color for the border of inactive windows
|
# The color for the border of inactive windows
|
||||||
inactive_border_color #cccccc
|
inactive_border_color #cccccc
|
||||||
|
|
||||||
# Tab-bar colors
|
# Tab-bar customization
|
||||||
active_tab_foreground #000
|
active_tab_foreground #000
|
||||||
active_tab_background #eee
|
active_tab_background #eee
|
||||||
|
active_tab_font_style bold-italic
|
||||||
inactive_tab_foreground #444
|
inactive_tab_foreground #444
|
||||||
inactive_tab_background #999
|
inactive_tab_background #999
|
||||||
|
inactive_tab_font_style normal
|
||||||
|
tab_separator " ┇"
|
||||||
|
|
||||||
|
|
||||||
# The 16 terminal colors. There are 8 basic colors, each color has a dull and
|
# The 16 terminal colors. There are 8 basic colors, each color has a dull and
|
||||||
|
|||||||
@ -228,6 +228,17 @@ class TabBar: # {{{
|
|||||||
color_as_int(opts.inactive_tab_background)
|
color_as_int(opts.inactive_tab_background)
|
||||||
)
|
)
|
||||||
self.blank_rects = ()
|
self.blank_rects = ()
|
||||||
|
sep = opts.tab_separator
|
||||||
|
self.trailing_spaces = self.leading_spaces = 0
|
||||||
|
while sep and sep[0] == ' ':
|
||||||
|
sep = sep[1:]
|
||||||
|
self.trailing_spaces += 1
|
||||||
|
while sep and sep[-1] == ' ':
|
||||||
|
self.leading_spaces += 1
|
||||||
|
sep = sep[:-1]
|
||||||
|
self.sep = sep
|
||||||
|
self.active_font_style = opts.active_tab_font_style
|
||||||
|
self.inactive_font_style = opts.inactive_tab_font_style
|
||||||
|
|
||||||
def as_rgb(x):
|
def as_rgb(x):
|
||||||
return (x << 8) | 2
|
return (x << 8) | 2
|
||||||
@ -264,9 +275,9 @@ class TabBar: # {{{
|
|||||||
for t in data:
|
for t in data:
|
||||||
s.cursor.bg = self.active_bg if t.is_active else 0
|
s.cursor.bg = self.active_bg if t.is_active else 0
|
||||||
s.cursor.fg = self.active_fg if t.is_active else 0
|
s.cursor.fg = self.active_fg if t.is_active else 0
|
||||||
s.cursor.bold = s.cursor.italic = t.is_active
|
s.cursor.bold, s.cursor.italic = self.active_font_style if t.is_active else self.inactive_font_style
|
||||||
before = s.cursor.x
|
before = s.cursor.x
|
||||||
s.draw(t.title)
|
s.draw(' ' * self.leading_spaces + t.title + ' ' * self.trailing_spaces)
|
||||||
extra = s.cursor.x - before - max_title_length
|
extra = s.cursor.x - before - max_title_length
|
||||||
if extra > 0:
|
if extra > 0:
|
||||||
s.cursor.x -= extra + 1
|
s.cursor.x -= extra + 1
|
||||||
@ -274,7 +285,7 @@ class TabBar: # {{{
|
|||||||
cr.append((before, s.cursor.x))
|
cr.append((before, s.cursor.x))
|
||||||
s.cursor.bold = s.cursor.italic = False
|
s.cursor.bold = s.cursor.italic = False
|
||||||
s.cursor.fg = s.cursor.bg = 0
|
s.cursor.fg = s.cursor.bg = 0
|
||||||
s.draw('┇')
|
s.draw(self.sep)
|
||||||
if s.cursor.x > s.columns - max_title_length and not t.is_last:
|
if s.cursor.x > s.columns - max_title_length and not t.is_last:
|
||||||
s.draw('…')
|
s.draw('…')
|
||||||
break
|
break
|
||||||
@ -405,7 +416,7 @@ class TabManager: # {{{
|
|||||||
at = self.active_tab
|
at = self.active_tab
|
||||||
ans = []
|
ans = []
|
||||||
for t in self.tabs:
|
for t in self.tabs:
|
||||||
title = (t.name or t.title or appname) + ' '
|
title = (t.name or t.title or appname).strip()
|
||||||
ans.append(TabbarData(title, t is at, t is self.tabs[-1]))
|
ans.append(TabbarData(title, t is at, t is self.tabs[-1]))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user