Skip to content

Commit 863fff8

Browse files
committed
Cleanup previous PR
1 parent 18f42fe commit 863fff8

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
2222

2323
- Allow setting colors when creating windows using the :doc:`launch <launch>` command.
2424

25+
- A new option :opt:`tab_powerline_style` to control the appearance of the tab
26+
bar when using the powerline tab bar style.
27+
2528
- diff kitten: Implement recursive diff over SSH (:iss:`3268`)
2629

2730
- ssh kitten: Allow using python instead of the shell on the server, useful if

kitty/tab_bar.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
from typing import Any, Dict, NamedTuple, Optional, Sequence, Tuple
77

88
from .config import build_ansi_color_table
9-
from .types import WindowGeometry
109
from .fast_data_types import (
1110
DECAWM, Screen, cell_size_for_window, pt_to_px, set_tab_bar_render_data,
1211
viewport_for_window
1312
)
1413
from .layout.base import Rect
1514
from .options_stub import Options
1615
from .rgb import Color, alpha_blend, color_as_sgr, color_from_int, to_color
16+
from .types import WindowGeometry
17+
from .typing import PowerlineStyle
1718
from .utils import color_as_int, log_error
1819
from .window import calculate_gl_geometry
1920

@@ -42,7 +43,7 @@ class DrawData(NamedTuple):
4243
title_template: str
4344
active_title_template: Optional[str]
4445
tab_activity_symbol: Optional[str]
45-
powerline_style: str
46+
powerline_style: PowerlineStyle
4647

4748

4849
def as_rgb(x: int) -> int:
@@ -181,36 +182,34 @@ def draw_tab_with_fade(draw_data: DrawData, screen: Screen, tab: TabBarData, bef
181182
return end
182183

183184

185+
powerline_symbols: Dict[PowerlineStyle, Tuple[str, str]] = {
186+
'slanted': ('', '╱'),
187+
'round': ('', '')
188+
}
189+
190+
184191
def draw_tab_with_powerline(draw_data: DrawData, screen: Screen, tab: TabBarData, before: int, max_title_length: int, index: int, is_last: bool) -> int:
185192
tab_bg = as_rgb(color_as_int(draw_data.active_bg if tab.is_active else draw_data.inactive_bg))
186193
tab_fg = as_rgb(color_as_int(draw_data.active_fg if tab.is_active else draw_data.inactive_fg))
187194
inactive_bg = as_rgb(color_as_int(draw_data.inactive_bg))
188195
default_bg = as_rgb(color_as_int(draw_data.default_bg))
189196

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-
197+
separator_symbol, separator_alt_symbol = powerline_symbols.get(draw_data.powerline_style, ('', ''))
199198
min_title_length = 1 + 2
200199

201200
if screen.cursor.x + min_title_length >= screen.columns:
202201
screen.cursor.x -= 2
203202
screen.cursor.bg = default_bg
204203
screen.cursor.fg = inactive_bg
205-
screen.draw('{} '.format(separator_symbol))
204+
screen.draw(f'{separator_symbol} ')
206205
return screen.cursor.x
207206

208207
start_draw = 2
209208
if tab.is_active and screen.cursor.x >= 2:
210209
screen.cursor.x -= 2
211210
screen.cursor.fg = inactive_bg
212211
screen.cursor.bg = tab_bg
213-
screen.draw('{} '.format(separator_symbol))
212+
screen.draw(f'{separator_symbol} ')
214213
screen.cursor.fg = tab_fg
215214
elif screen.cursor.x == 0:
216215
screen.cursor.bg = tab_bg
@@ -236,7 +235,7 @@ def draw_tab_with_powerline(draw_data: DrawData, screen: Screen, tab: TabBarData
236235
screen.cursor.bg = inactive_bg
237236
screen.draw(separator_symbol)
238237
else:
239-
screen.draw(' {}'.format(separator_alt_symbol))
238+
screen.draw(f' {separator_alt_symbol}')
240239

241240
end = screen.cursor.x
242241
if end < screen.columns:

kitty/typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
CompletedProcess = Tuple
1919
TypedDict = dict
2020
EdgeLiteral = str
21+
PowerlineStyle = str
2122
MatchType = str
2223
Protocol = object

kitty/typing.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ __all__ = (
5656
'FontConfigPattern', 'ScreenType', 'StartupCtx', 'KeyEventType', 'LayoutType',
5757
'RemoteCommandType', 'SessionType', 'SessionTab', 'SpecialWindowInstance', 'TabType', 'ScreenSize', 'WindowType'
5858
)
59+
PowerlineStyle = Literal['angled', 'slanted', 'round']

0 commit comments

Comments
 (0)