Nicer debug output for scrollbar option

This commit is contained in:
Kovid Goyal
2025-09-14 12:26:25 +05:30
parent 77e22523ec
commit 1e13050fda
4 changed files with 14 additions and 6 deletions

View File

@@ -198,7 +198,7 @@ The scrollback buffer
|kitty| supports scrolling back to view history, just like most terminals. You
can use either keyboard shortcuts or the mouse scroll wheel to do so. |kitty|
displays an interactive :opt:`scrollbar <scrollbar_opacity>` along the right edge
displays an interactive :opt:`scrollbar` along the right edge
of the window that shows your current position in the scrollback. You can click
and drag the scrollbar to quickly navigate through the history.

View File

@@ -22,7 +22,7 @@ from .constants import extensions_dir, is_macos, is_wayland, kitty_base_dir, kit
from .fast_data_types import Color, SingleKey, current_fonts, glfw_get_system_color_theme, gpu_driver_version_string, num_users, wayland_compositor_data
from .options.types import Options as KittyOpts
from .options.types import defaults, secret_options
from .options.utils import KeyboardMode, KeyDefinition
from .options.utils import KeyboardMode, KeyDefinition, ScrollbarSettings
from .rgb import color_as_sharp, color_from_int
from .types import MouseEvent, Shortcut, mod_to_names
from .utils import shlex_split
@@ -91,7 +91,7 @@ def compare_opts(opts: KittyOpts, global_shortcuts: dict[str, SingleKey] | None,
continue
val = getattr(opts, f)
if isinstance(val, dict):
print(title(f'{f}:'))
print(f'{f}:')
if f == 'symbol_map':
for k in sorted(val):
print(f'\tU+{k[0]:04x} - U+{k[1]:04x}{val[k]}')
@@ -100,6 +100,10 @@ def compare_opts(opts: KittyOpts, global_shortcuts: dict[str, SingleKey] | None,
print(' ', val[k])
else:
print(pformat(val))
elif isinstance(val, ScrollbarSettings):
print(f'{f}:')
for ssd in ScrollbarSettings().differences(val):
print(f'\t{ssd}')
else:
val = getattr(opts, f)
if isinstance(val, Color):

View File

@@ -442,10 +442,9 @@ is changed it will only affect newly created windows, not existing ones.
'''
)
opt(
'scrollbar', '',
option_type='scrollbar', ctype='!scrollbar',
opt('scrollbar', '', option_type='scrollbar', ctype='!scrollbar',
long_text='''
TODO: this writeup
''')
opt('scrollback_pager', 'less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER',

View File

@@ -1719,6 +1719,11 @@ class ScrollbarSettings(NamedTuple):
jump_on_track_click: bool = True
visible_when: int = 1
def differences(self, other: 'ScrollbarSettings') -> Iterator[str]:
for key in self._fields:
if getattr(self, key) != (o := getattr(other, key)):
yield f'{key}: {o}'
default_scrollbar = ScrollbarSettings()