1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Tab bar rendering for the home page header."""
from __future__ import annotations
from pyratatui import Constraint, Direction, Frame, Layout, Paragraph, Rect, Tabs
from pygittools.tui.git_colors import active_tab_style, current_theme, focus_style
def init_tab_colors() -> None:
"""Refresh cached tab attributes from the active Git color theme."""
return None
def render_tab_row(
frame: Frame,
area: Rect,
prefix: str,
tab_labels: tuple[str, ...],
active_index: int,
*,
prefix_focused: bool = False,
) -> None:
"""Draw project prefix and selectable tabs into ``area``."""
if area.height <= 0 or area.width <= 0:
return
theme = current_theme()
prefix_style = focus_style(theme.branch) if prefix_focused else theme.branch
prefix_width = min(area.width, len(prefix) + 2)
chunks = (
Layout()
.direction(Direction.Horizontal)
.constraints([Constraint.length(prefix_width), Constraint.fill(1)])
.split(area)
)
frame.render_widget(Paragraph.from_string(prefix).style(prefix_style), chunks[0])
frame.render_widget(
Tabs(list(tab_labels))
.select(active_index)
.highlight_style(active_tab_style())
.style(theme.tab_inactive)
.divider(" "),
chunks[1],
)