mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-09-04 08:48:21 +00:00
autoformat
This commit is contained in:
parent
7d6d064ea2
commit
dd2c59d255
6 changed files with 68 additions and 52 deletions
|
|
@ -984,7 +984,6 @@ def parse_input_from_terminal(
|
|||
|
||||
class Line:
|
||||
def sprite_at(self, cell: int) -> int: ...
|
||||
|
||||
def cursor_from(self, x: int, y: int = 0) -> Cursor: ...
|
||||
|
||||
def test_shape(line: Line, path: Optional[str] = None, index: int = 0) -> List[Tuple[int, int, int, Tuple[int, ...]]]:
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ def active_tab_title_template(x: str) -> str | None:
|
|||
|
||||
|
||||
def tab_title_wrap(x: str) -> int:
|
||||
'''no/0 -> 0 (disabled), yes -> -1 (wrap at the tab bar width), N -> wrap at N cells'''
|
||||
"""no/0 -> 0 (disabled), yes -> -1 (wrap at the tab bar width), N -> wrap at N cells"""
|
||||
x = x.lower()
|
||||
if x in ('n', 'no', 'false', 'none'):
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -423,7 +423,8 @@ class TestMouse(BaseTest):
|
|||
# direction gets spent cancelling it instead of scrolling.
|
||||
# The fragment sequences below were captured from a Logitech MX Master 3.
|
||||
from kitty.fast_data_types import test_scale_scroll
|
||||
self.set_options() # scale_scroll reads wheel_scroll_multiplier
|
||||
|
||||
self.set_options() # scale_scroll reads wheel_scroll_multiplier
|
||||
cell = 40
|
||||
|
||||
def run(*v120):
|
||||
|
|
@ -432,7 +433,7 @@ class TestMouse(BaseTest):
|
|||
# on the configured multiplier.
|
||||
return test_scale_scroll([float(v) for v in v120], cell)
|
||||
|
||||
down = (-48, -32, -24, -24) # 128 units
|
||||
down = (-48, -32, -24, -24) # 128 units
|
||||
up = (48, 32, 24, 24)
|
||||
|
||||
# Five detents down, then one up. Every detent must scroll, including
|
||||
|
|
@ -444,7 +445,7 @@ class TestMouse(BaseTest):
|
|||
|
||||
# Repeated reversals keep working.
|
||||
res = run(*(down * 2), *(up * 2), *(down * 2))
|
||||
self.ae([-2, 2, -2], [sum(res[i:i + 8]) for i in range(0, 24, 8)])
|
||||
self.ae([-2, 2, -2], [sum(res[i : i + 8]) for i in range(0, 24, 8)])
|
||||
|
||||
# Scrolling in one direction is unaffected: the carry is retained, so a
|
||||
# run of undersized detents still scrolls about one line each.
|
||||
|
|
|
|||
|
|
@ -253,7 +253,8 @@ void vsMain() {}
|
|||
self.assertRaises(ValueError, parse_var_directive, ['var', 'uint'])
|
||||
|
||||
def test_parse_pipeline_definition_vars(self):
|
||||
p = parse_pipeline_definition('''
|
||||
p = parse_pipeline_definition(
|
||||
"""
|
||||
var uint algo = 1
|
||||
var float intensity = 0.5
|
||||
startgroup
|
||||
|
|
@ -263,7 +264,8 @@ void vsMain() {}
|
|||
var uint algo = 2
|
||||
shaders sample
|
||||
endgroup
|
||||
'''.splitlines())
|
||||
""".splitlines()
|
||||
)
|
||||
self.assertEqual(p['vars'], {'algo': ('uint', '1'), 'intensity': ('float', '0.5')})
|
||||
self.assertEqual(p['groups'][0]['vars'], {})
|
||||
self.assertEqual(p['groups'][1]['vars'], {'algo': ('uint', '2')})
|
||||
|
|
@ -278,11 +280,13 @@ void vsMain() {}
|
|||
with tempfile.TemporaryDirectory() as cache_dir:
|
||||
# Clear the lru_cache so the temp cache_dir is actually used
|
||||
clear_caches()
|
||||
p = parse_pipeline_definition('''
|
||||
p = parse_pipeline_definition(
|
||||
"""
|
||||
startgroup
|
||||
shaders sample sample
|
||||
endgroup
|
||||
'''.splitlines())
|
||||
""".splitlines()
|
||||
)
|
||||
try:
|
||||
vert_src, frag_src, metadata = build_custom_shader_pipeline_glsl(p, cache_dir=cache_dir)
|
||||
invocation_tracker = set()
|
||||
|
|
|
|||
|
|
@ -99,12 +99,14 @@ class TestTabBar(BaseTest):
|
|||
self.ae(tb.tab_id_at(5, 150), 2)
|
||||
|
||||
def vertical_tab_bar(self, num_tabs: int = 2, height: int = 160, **opts: object) -> TabBar:
|
||||
self.set_options({
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
**opts,
|
||||
})
|
||||
self.set_options(
|
||||
{
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
**opts,
|
||||
}
|
||||
)
|
||||
central = region(120, 0, 400, height)
|
||||
tab_bar = region(0, 0, 120, height)
|
||||
with (
|
||||
|
|
@ -143,12 +145,14 @@ class TestTabBar(BaseTest):
|
|||
def test_vertical_tab_bar_mixed_title_heights(self) -> None:
|
||||
# a tab whose title has no newline stays one line tall even when the
|
||||
# limit is higher, so tabs pack according to what they actually use
|
||||
self.set_options({
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
'tab_title_max_lines': 3,
|
||||
})
|
||||
self.set_options(
|
||||
{
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
'tab_title_max_lines': 3,
|
||||
}
|
||||
)
|
||||
central = region(120, 0, 400, 160)
|
||||
tab_bar = region(0, 0, 120, 160)
|
||||
with (
|
||||
|
|
@ -159,11 +163,13 @@ class TestTabBar(BaseTest):
|
|||
):
|
||||
tb = TabBar(1)
|
||||
tb.layout()
|
||||
tb.update((
|
||||
TabBarData(title='one\ntwo', tab_id=1, is_active=True),
|
||||
TabBarData(title='solo', tab_id=2),
|
||||
TabBarData(title='a\nb\nc', tab_id=3),
|
||||
))
|
||||
tb.update(
|
||||
(
|
||||
TabBarData(title='one\ntwo', tab_id=1, is_active=True),
|
||||
TabBarData(title='solo', tab_id=2),
|
||||
TabBarData(title='a\nb\nc', tab_id=3),
|
||||
)
|
||||
)
|
||||
self.ae(self.screen_lines(tb)[:8], ['one', 'two', '', 'solo', '', 'a', 'b', 'c'])
|
||||
self.ae(tuple(te.y for te in tb.tab_extents), (CellRange(0, 1), CellRange(3, 3), CellRange(5, 7)))
|
||||
self.ae(tb.tab_id_at(5, 10), 1)
|
||||
|
|
@ -202,6 +208,7 @@ class TestTabBar(BaseTest):
|
|||
tb = self.vertical_tab_bar(num_tabs=4, height=140)
|
||||
self.ae(self.screen_lines(tb), ['t0', '', 't1', '', 't2', '', 't3'])
|
||||
self.ae(len(tb.tab_extents), 4)
|
||||
|
||||
def test_vertical_tab_bar_fills_tab_width(self) -> None:
|
||||
# every line a tab occupies must be padded to the full width of the bar
|
||||
# in that tab's colors, otherwise uneven line lengths leave a ragged edge
|
||||
|
|
@ -293,12 +300,14 @@ class TestTabBar(BaseTest):
|
|||
long_title = 'feature/some-really-long-branch'
|
||||
|
||||
def tb_with(**opts: object) -> list[str]:
|
||||
self.set_options({
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
**opts,
|
||||
})
|
||||
self.set_options(
|
||||
{
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
**opts,
|
||||
}
|
||||
)
|
||||
central, tab_bar = region(140, 0, 740, 240), region(0, 0, 140, 240)
|
||||
with (
|
||||
patch('kitty.tab_bar.cell_size_for_window', return_value=(10, 20)),
|
||||
|
|
@ -330,22 +339,22 @@ class TestTabBar(BaseTest):
|
|||
def test_vertical_tab_bar_wrapping_with_newlines(self) -> None:
|
||||
# an explicit newline still breaks the line, and each resulting line is
|
||||
# wrapped independently
|
||||
tb = self.vertical_tab_bar(
|
||||
num_tabs=1, height=200, tab_title_max_lines=4, tab_title_wrap=-1,
|
||||
tab_title_template='a-really-long-first\\nshort')
|
||||
tb = self.vertical_tab_bar(num_tabs=1, height=200, tab_title_max_lines=4, tab_title_wrap=-1, tab_title_template='a-really-long-first\\nshort')
|
||||
self.ae([line for line in self.screen_lines(tb) if line], ['a-really-lo', 'ng-first', 'short'])
|
||||
|
||||
def test_vertical_tab_bar_wrapping_overflow(self) -> None:
|
||||
# wrapped tabs are packed by the lines they use, and once they stop
|
||||
# fitting the remainder is replaced by the overflow ellipsis
|
||||
long_title = 'feature/really-long-branch-name'
|
||||
self.set_options({
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
'tab_title_max_lines': 2,
|
||||
'tab_title_wrap': -1,
|
||||
})
|
||||
self.set_options(
|
||||
{
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'separator',
|
||||
'tab_title_template': '{title}',
|
||||
'tab_title_max_lines': 2,
|
||||
'tab_title_wrap': -1,
|
||||
}
|
||||
)
|
||||
central, tab_bar = region(140, 0, 740, 100), region(0, 0, 140, 100)
|
||||
with (
|
||||
patch('kitty.tab_bar.cell_size_for_window', return_value=(10, 20)),
|
||||
|
|
@ -362,14 +371,16 @@ class TestTabBar(BaseTest):
|
|||
def test_vertical_tab_bar_fade_style(self) -> None:
|
||||
# Use fixed colors so every fade cell blends to the same midpoint
|
||||
# colour, making fade cells easy to identify by background.
|
||||
self.set_options({
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'fade',
|
||||
'tab_title_template': '{title}',
|
||||
'active_tab_background': Color(200, 0, 0),
|
||||
'tab_bar_background': Color(0, 0, 100),
|
||||
'tab_fade': (0.5, 0.5, 0.5, 0.5),
|
||||
})
|
||||
self.set_options(
|
||||
{
|
||||
'tab_bar_edge': LEFT_EDGE,
|
||||
'tab_bar_style': 'fade',
|
||||
'tab_title_template': '{title}',
|
||||
'active_tab_background': Color(200, 0, 0),
|
||||
'tab_bar_background': Color(0, 0, 100),
|
||||
'tab_fade': (0.5, 0.5, 0.5, 0.5),
|
||||
}
|
||||
)
|
||||
central = region(120, 0, 400, 160)
|
||||
tab_bar_r = region(0, 0, 120, 160)
|
||||
with (
|
||||
|
|
@ -390,14 +401,14 @@ class TestTabBar(BaseTest):
|
|||
def bg(col: int) -> int:
|
||||
return int(s.line(0).cursor_from(col).bg)
|
||||
|
||||
tab_bg = bg(4) # title cell: active_tab_background
|
||||
tab_bg = bg(4) # title cell: active_tab_background
|
||||
fade_bg = bg(0) # leading fade cell: midpoint blend
|
||||
|
||||
# Sanity: fade colour is distinct from plain tab colour.
|
||||
self.assertNotEqual(tab_bg, fade_bg)
|
||||
|
||||
# Issue 1: trailing fades flush with the right edge (cols 8–11), not right after the text.
|
||||
self.ae(bg(6), tab_bg) # col 6, right after 't0', must be plain tab bg
|
||||
self.ae(bg(6), tab_bg) # col 6, right after 't0', must be plain tab bg
|
||||
self.ae(bg(8), fade_bg) # col 8, fade_start = 12 - 4, must be a fade cell
|
||||
|
||||
# Issue 2: no background-coloured separator after the trailing fades.
|
||||
|
|
|
|||
|
|
@ -46,3 +46,4 @@ detect-same-package = true
|
|||
|
||||
[tool.ruff.format]
|
||||
quote-style = 'single'
|
||||
exclude = ['kitty/options/types.py', 'kitty/options/parse.py']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue