66from typing import Any , Dict , NamedTuple , Optional , Sequence , Tuple
77
88from .config import build_ansi_color_table
9- from .types import WindowGeometry
109from .fast_data_types import (
1110 DECAWM , Screen , cell_size_for_window , pt_to_px , set_tab_bar_render_data ,
1211 viewport_for_window
1312)
1413from .layout .base import Rect
1514from .options_stub import Options
1615from .rgb import Color , alpha_blend , color_as_sgr , color_from_int , to_color
16+ from .types import WindowGeometry
17+ from .typing import PowerlineStyle
1718from .utils import color_as_int , log_error
1819from .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
4849def 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+
184191def 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 :
0 commit comments