Skip to content

Commit 18f42fe

Browse files
committed
Merge branch 'tab_powerline' of https://github.com/slfotg/kitty
2 parents bd67814 + 2a3cc71 commit 18f42fe

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

kitty/config_data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,11 @@ def tab_fade(x: str) -> Tuple[float, ...]:
953953
o('tab_separator', '"{}"'.format(default_tab_separator), option_type=tab_separator, long_text=_('''
954954
The separator between tabs in the tab bar when using :code:`separator` as the :opt:`tab_bar_style`.'''))
955955

956+
o('tab_powerline_style', 'angled', option_type=choices('angled', 'slanted', 'round'), long_text=_('''
957+
The powerline separator style between tabs in the tab bar when using :code:`powerline`
958+
as the :opt:`tab_bar_style`, can be one of: :code:`angled`, :code:`slanted`, or :code:`round`.
959+
'''))
960+
956961

957962
def tab_activity_symbol(x: str) -> Optional[str]:
958963
if x == 'none':

kitty/tab_bar.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class DrawData(NamedTuple):
4242
title_template: str
4343
active_title_template: Optional[str]
4444
tab_activity_symbol: Optional[str]
45+
powerline_style: str
4546

4647

4748
def as_rgb(x: int) -> int:
@@ -186,21 +187,30 @@ def draw_tab_with_powerline(draw_data: DrawData, screen: Screen, tab: TabBarData
186187
inactive_bg = as_rgb(color_as_int(draw_data.inactive_bg))
187188
default_bg = as_rgb(color_as_int(draw_data.default_bg))
188189

190+
separator_symbol = ''
191+
separator_alt_symbol = ''
192+
if draw_data.powerline_style == 'slanted':
193+
separator_symbol = ''
194+
separator_alt_symbol = '╱'
195+
elif draw_data.powerline_style == 'round':
196+
separator_symbol = ''
197+
separator_alt_symbol = ''
198+
189199
min_title_length = 1 + 2
190200

191201
if screen.cursor.x + min_title_length >= screen.columns:
192202
screen.cursor.x -= 2
193203
screen.cursor.bg = default_bg
194204
screen.cursor.fg = inactive_bg
195-
screen.draw(' ')
205+
screen.draw('{} '.format(separator_symbol))
196206
return screen.cursor.x
197207

198208
start_draw = 2
199209
if tab.is_active and screen.cursor.x >= 2:
200210
screen.cursor.x -= 2
201211
screen.cursor.fg = inactive_bg
202212
screen.cursor.bg = tab_bg
203-
screen.draw(' ')
213+
screen.draw('{} '.format(separator_symbol))
204214
screen.cursor.fg = tab_fg
205215
elif screen.cursor.x == 0:
206216
screen.cursor.bg = tab_bg
@@ -224,9 +234,9 @@ def draw_tab_with_powerline(draw_data: DrawData, screen: Screen, tab: TabBarData
224234
screen.cursor.bg = default_bg
225235
else:
226236
screen.cursor.bg = inactive_bg
227-
screen.draw('')
237+
screen.draw(separator_symbol)
228238
else:
229-
screen.draw(' ')
239+
screen.draw(' {}'.format(separator_alt_symbol))
230240

231241
end = screen.cursor.x
232242
if end < screen.columns:
@@ -273,7 +283,8 @@ def __init__(self, os_window_id: int, opts: Options):
273283
self.opts.inactive_tab_foreground, self.opts.inactive_tab_background,
274284
self.opts.tab_bar_background or self.opts.background, self.opts.tab_title_template,
275285
self.opts.active_tab_title_template,
276-
self.opts.tab_activity_symbol
286+
self.opts.tab_activity_symbol,
287+
self.opts.tab_powerline_style
277288
)
278289
if self.opts.tab_bar_style == 'separator':
279290
self.draw_func = draw_tab_with_separator

0 commit comments

Comments
 (0)