Commit graph

4120 commits

Author SHA1 Message Date
Kovid Goyal
a481180d48
Add a mode to report scroll events to programs in full detail
Mode 5523, while mouse tracking is on, makes kitty report each scroll event
as a single CSI > ... M escape code instead of as button 4-7 presses. It
carries integer deltas in v120 units or pixels, with fractions carried
over, the user's scroll multiplier as a hint, the kind of device, the
gesture phase, and flags for momentum and inverted (natural) scrolling,
and the full set of modifiers. Only the sign of the multipliers is applied.

To support this GLFW scroll events now carry the source device, the
gesture phase and whether the direction is inverted, on Wayland, X11 and
macOS. The momentum scroller now forwards the gesture end before starting
momentum and no longer reports a cancel for momentum that never began.
2026-11-16 13:43:41 +05:30
Kovid Goyal
13c7980ab4
Speed up processing of text that scrolls the screen
Lines scrolled onto the screen no longer have their render data cleared,
instead they are marked dirty so that rendering recomputes it, except when
there is a marker, as marks are render data used without rendering. This
reduces the memory written to clear a line by 40%.

The ASCII fast path in draw_text no longer checks for multicell cells in
a line that was just cleared by a line feed scrolling the screen, until
something that can create multicell cells happens.

Together these make the ascii benchmark ~14% and the scrollback and
render benchmarks ~8% and ~14% faster. Also update the throughput
numbers in the performance docs, using the median of several runs.
2026-11-16 13:43:41 +05:30
Kovid Goyal
a49882a5f9
Update performance docs 2026-11-16 13:43:41 +05:30
Kovid Goyal
bf37d5841b
benchmark kitten: Add scrollback and render benchmarks and --output
Replace the --with-scrollback and --render flags with two new
benchmarks, scrollback and render, that use the ASCII text with the
main screen and with rendering allowed, respectively. All other
benchmarks use the alternate screen with rendering suppressed. Add an
--output flag to also write the results to a file as JSON and list the
available benchmarks with descriptions in the help text.
2026-11-16 13:43:40 +05:30
Kovid Goyal
8af327b85c
... 2026-11-16 13:43:40 +05:30
Kovid Goyal
8efb82b5b8
Replace sync_to_monitor and repaint_delay with render_interval
The new render_interval option either syncs redraws to the monitor
(the default), optionally with a minimum interval between frames, or
redraws on a schedule with a minimum interval between frames. The
interval is now enforced per OS window, including when output is being
parsed, which the old repaint_delay was not.

On X11, render frames are now provided by the Present extension, with
libxcb-present loaded at runtime. Frames are requested lazily on X11,
since a pending NotifyMSC request delays buffer presentation by the GPU
driver under Xwayland. Xwayland completing requests early and failing to
report vertical blanks for long periods are handled. Without Present,
kitty falls back to blocking buffer swaps as before.

Render frames now only wake up the main loop when something is waiting
for them, so animations such as the eased cursor blink are no longer
sampled at the monitor refresh rate. On Wayland, frame callbacks are
also used when not syncing to the monitor, to stop rendering hidden
windows.

The removed options are converted to render_interval if it is not
specified anywhere, including in other config files and overrides,
otherwise they are ignored with a warning.

Also fix gen config failing on options whose type is a builtin.
2026-11-16 13:43:39 +05:30
Kovid Goyal
173ece7911
Fix CI failures from the SIMD UTF-8 decoder changes
The SIMD UTF-8 decoders read up to a vector past the end of their input,
which is fine for real callers that have slack after their data, but
test_utf8_decode_to_sentinel passed the Python buffer directly, so the
new long input test triggered heap-buffer-overflow reports under ASAN.
Copy the input into a padded buffer, as the other SIMD test helpers do.

Also fix clang-format violations and broken references to the removed
input_delay option in the changelog that failed the docs build.
2026-11-16 13:43:39 +05:30
Kovid Goyal
14191bbbee
Read variable font data from WOFF and WOFF2 files in font selection
The C font selection code read font tables only from sfnt files, so
variable fonts in WOFF/WOFF2 files had no variable data, causing wrong
faces to be selected, for example, for FiraCode-VF.woff2.

Read WOFF tables using zlib and WOFF2 tables using brotli, decompressing
only the prefix of the stream containing the needed tables, in fixed
size chunks so that memory use does not depend on possibly corrupt
offsets. kitty now links against libbrotlidec on platforms other than
macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 13:43:39 +05:30
Kovid Goyal
752bf496a8
Remove input_delay and parse output as soon as it is received
Holding large chunks of input for input_delay left the parser idle about
30% of the time during bulk output: the parser started only when the
buffer was nearly full, and freed space only at the end of a pass, so the
I/O thread could not read while the parser worked.

Now the I/O thread wakes the main loop whenever new input arrives and no
wakeup is already outstanding, and a parse pass compacts the buffer as it
goes, waking the I/O thread if the buffer had filled up. A pass parses at
most 1MB of input so that a continuous stream cannot starve rendering and
event handling.

This raises parser utilization during kitten __benchmark__ from ~70% to
~97% and throughput by 12% to 30% depending on the kind of output.
2026-11-16 13:43:38 +05:30
Kovid Goyal
51e8342b00
Build the Vulkan GPU driver in the Linux binary builds
Add vulkan-headers to the Linux dependencies, and fail freezing on Linux
if either the OpenGL or the Vulkan GPU driver, or the built-in shaders
for its shader target, are missing. Document vulkan-headers as a build
dependency.
2026-11-16 13:43:37 +05:30
Kovid Goyal
d6c2ea1160
Request a main loop tick after state changes made from timers
Timers are dispatched outside the main loop tick, so state changed by
them was not rendered while the OS window was otherwise idle, only
catching up when some other event woke the loop. For example, a custom
tab bar refreshed from add_timer, or actions mapped to mouse clicks,
which are dispatched from a timer after click_interval.

Request a tick after every Python timer callback, after dispatching
pending clicks and when marking the tab bar dirty.

Closes #10878
2026-11-16 13:32:14 +05:30
Kovid Goyal
ec28187f6f
Fix newly displayed images sometimes not being rendered until the next redraw
prepare_to_render_os_window() decided whether a window needs to be rendered
in layers before calling send_cell_data_to_gpu(), which is what updates the
graphics layers. So on the frame in which an image first becomes visible
grman_has_images() returned a stale false, the window was rendered without
the image, and if nothing else triggered a redraw (for example, the cursor
is hidden so not blinking) the image did not appear until some unrelated
event such as mouse movement.

Fixes #10875
2026-11-16 07:45:22 +05:30
Kovid Goyal
2b260d8d67
Wayland CSD: Re-render on keyboard focus changes
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
The focus state of the decorations comes only from keyboard enter/leave
events, but the decorations were only re-rendered on configure events and
title changes. So they showed a stale focus state whenever focus changed
without a following configure, for example, when switching between tabbed
windows in niri, which keeps all tabs activated.

Re-render the decorations on keyboard enter/leave, looking up the window
again after the focus callbacks have run, since they can close it.

Also:
- Ignore the activated state in the change detection, as focus is tracked
  separately, to avoid rendering twice per focus change.
- Never create decoration surfaces in ensure_csd_resources() for windows
  that should not be decorated, such as fullscreen windows. Title changes
  while fullscreen could previously create them from a stale state.
- Recreate the decoration surfaces when they are missing even if the
  window state is unchanged, otherwise the resize borders were not
  restored after leaving fullscreen with hide_window_decorations
  titlebar-only.

Based on the patch by Ole Jørgen Brønner.

Closes #10873
2026-11-15 20:06:45 +05:30
Kovid Goyal
dea5bd4c24
Update changelog
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-11-15 09:49:43 +05:30
Kovid Goyal
b692122f22
Allow selecting text drawn in the tab bar outside the tabs
Dragging the mouse over text drawn in the tab bar outside the tabs, such
as text a custom tab_bar.py draws below the tabs of a vertical tab bar,
selects it, and releasing the button copies it like a window selection
(primary selection, then copy_on_select). Clicks and double clicks on
empty space and presses on tabs behave as before.

Based on the draft in #10870, with these additions:

- Movement within drag_threshold selects nothing, so a slightly jittery
  double click on text still opens a new tab.
- A selection whose release was lost does not keep capturing the
  mouse: it is cancelled by a press outside the tab bar (which then goes
  to its normal target), by motion with no button held, by any press in
  the tab bar, and by the OS window losing focus.
- The pointer shape is reset after the press or release that starts or
  ends a selection, instead of being left as the drag shape.

Fixes #10869
Closes #10870
2026-11-15 09:32:37 +05:30
Kovid Goyal
3568f959f3
save_as_session: Show where the session will be saved in the path prompt
The prompt now shows the directory relative names are saved in, taking
--base-dir into account, and notes that the .kitty-session extension is
added automatically. File name completion in the prompt is now relative
to that directory instead of the cwd of the active window.

See discussion #10867
2026-11-15 09:16:57 +05:30
Kovid Goyal
87d06354dd
Custom shaders: Fix focus driven groups ending in the wrong state after hide/unhide
Shader animation events are accumulated per OS window and only consumed
when the window is next rendered. A focus-out followed by a focus-in with
no rendered frame in between, as happens when the window is hidden and
shown again, or a brief focus steal within one repaint interval, left both
bits pending. The state machine then treated them as simultaneous, so the
focus-out hard stop prevented os-window-focus-in groups from starting and
groups started by focus-out were turned on while focused.

Now a focus change replaces any pending opposite focus change, so only the
final focus state is reported. Genuinely simultaneous events, such as a
click that moves focus away, still give focus-out priority.

Closes #10871
2026-11-15 08:39:25 +05:30
Kovid Goyal
64a02b4061
Fix cursor underflow when VS15 narrows a wide char on the previous soft wrapped line
The VS15 branch of draw_combining_char unconditionally moved the cursor
back by the width removed from the char. When the char was on the
previous line (cursor at x=0 after a soft wrap) this wrapped cursor->x to
UINT_MAX leading to out of bounds reads and writes. Only move the cursor
when it is on the same line as the char. Also preserve the soft wrap
marker in the cells cleared by halve_multicell_width.
2026-11-15 08:16:13 +05:30
Kovid Goyal
4fa6709910
choose-files kitten: Sanitize untrusted text in the preview panel
File names, archive member names, symlink targets, error messages and
ebook metadata were written to the terminal unsanitized, allowing
crafted names to inject escape codes (e.g. OSC 52 to overwrite the
clipboard) merely by highlighting the entry.
2026-11-14 12:19:09 +05:30
Kovid Goyal
d8f96a7d0a
Unicode input kitten: Fix searching by name not finding some characters
The word filter for control characters was applied to the record index
instead of the codepoint, dropping the words for ~160 characters.

Fixes #10862
2026-11-14 08:23:25 +05:30
Kovid Goyal
e537944ebf
Fix error message when configured editor is not found
Fixes #10865
2026-11-14 08:19:44 +05:30
Kovid Goyal
f8556bbf8d
Fix #10858 2026-11-14 08:16:53 +05:30
Kovid Goyal
c4dd943f72
Only render regular files as window logos/background images and time out image conversion
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
A program running in the terminal could use edit-in-kitty to set --logo=/dev/zero
which would cause the image converter to read an infinite stream, blocking the
kitty main loop and consuming unbounded memory.
2026-11-13 21:51:03 +05:30
Kovid Goyal
11cbfdce23
Allow resizing docks
Docks can now be resized in whole cells by dragging their inner border,
with the resize_window action and with kitten @ resize-window, where
wider or taller always means bigger whatever the edge of the dock. A
dock keeps at least one cell and grows only into the content it is
docked to, so the docks inside it are never shrunk. OS window docks do
not shrink the tab docks of any tab, and when dragged, the other tabs
are re-laid out once, at the end of the drag. Percentage sizes stay
percentages. The new size is stored in the DockSpec, so it is reported
by kitten @ ls and saved in sessions. Resetting window sizes does not
change docks, as they are not part of the layout.

Previously the inner border of a dock showed a resize pointer but
dragging it did nothing, or in the Tall layout moved a layout divider.

Fixes #10857
2026-11-13 19:44:03 +05:30
Kovid Goyal
3fe8677c4d
Cleanup previous PR
Do not track decoration touches that start an interactive move or resize,
the compositor takes the contact over and need not send its up event, which
left the contact active and caused the next decoration touch to be ignored.
Drop a stale tracked contact whenever a new down arrives with the same id,
wherever it lands. A titlebar button held down by one finger no longer
blocks moving or resizing windows with another.

Restore the old mouse behavior of hit testing titlebar buttons only by x, so
that a button is still activated when released after dragging the pointer
below the titlebar.

Update the input serials only for decoration touches that are handled,
including their up events. Share the titlebar commit code between the
pointer and touch paths, remove checks that can no longer fail, fix
indentation in decoration_surface() and add a changelog entry.
2026-11-13 19:44:02 +05:30
Kovid Goyal
760caa1f6a
Handle ConEmu OSC 9;9 cwd reporting and ignore other ConEmu OSC 9 sub-commands
OSC 9;9;path is now treated as a report of the current working directory,
like OSC 7, instead of popping up a desktop notification. Other ConEmu
numeric OSC 9 sub-commands (1-12) are ignored rather than shown as
notifications.
2026-11-13 19:44:02 +05:30
Kovid Goyal
cfd2b23dca
Fix out of bounds accesses with partially scrolled off multiline chars
Scrolling down (CSI T) could cut off the lower rows of a scale > 1 text
sizing character at the bottom of the screen. Adding a combining char to
it then wrote past the end of the line buffer in add_combining_char and
rewrapping on resize read past the end of the line buffer in
copy_multiline_extra_lines.

Multiline chars that are cut off at the edge of the screen or of the
history buffer, by scrolling or by inserting lines, are partially
scrolled off and are rendered as such, so they are kept. Code walking the rows of a multiline char now only visits
the adjacent rows that actually continue the char, rather than trusting
the y and scale of a cell, so it stays in bounds and does not modify
unrelated cells for partial or torn chars.

Chars that would be torn, i.e. left with rows from unrelated lines
adjacent to their remaining part, are removed. This happens when
scrolling with margins, when a partial char is moved away from the edge
of the screen by scrolling or deleting lines, when inserting lines pushes
the lower rows of a char straddling the bottom margin out of the scroll
region, and when a partial char
cut off at the bottom is no longer at the bottom after a resize. Rewrap
drops partial chars, as it already did for chars with missing top rows,
placing cursors that were on them where the char would have been.

The checks for torn chars are skipped unless a multiline char has been
drawn in the screen, and chars cut off at the bottom of the screen,
which can only be created by scrolling down or inserting lines, are
tracked so that
linefeeds do not need to scan for them.

A hard reset now clears the alternate screen as well, so that the flag
tracking whether multiline chars have been used can be reset.

Also fix the lower rows of multiline chars being lost on rewrap when the
lines after the char were continuations that fit on its first row.
2026-11-13 10:43:13 +05:30
Kovid Goyal
b9e7070cc8
dnd kitten: Fix failure to start in a non-writable directory
Create the temporary directory used for staging drops lazily, on the first
drop, instead of at startup, so the kitten works in directories that are not
writable when nothing is dropped into them.

Fixes #10855
2026-11-12 18:54:46 +05:30
Kovid Goyal
ae63e8e671
Update changelog 2026-11-12 13:06:30 +05:30
Kovid Goyal
bdd1e84346
Allow docking windows to the OS window with launch --type=os-window-dock
An OS window dock is shown in every tab of its OS window, below the tab
bar and outside the docks of the tab, and lives as long as the OS window.
It is a single window running a single program, which is kept in the
active tab: it is moved to the new active tab on every tab switch, by a
new C function that moves the window between tabs of an OS window
without recreating its GPU resources. Every tab reserves the space for
the OS window docks, so switching tabs does not resize any windows.

The docks are not closed with tabs and do not keep a tab open, stay in
their OS window when the tab containing them is moved to another OS
window, and are closed when the last other window in the OS window is
closed. They are listed as part of the active tab, and the dock entry of
every docked group in the output of kitten @ ls now has a scope of
window, tab or os-window. They are saved in sessions, once per OS window.

Fixes #10854
2026-11-12 12:47:48 +05:30
Kovid Goyal
65da47b611
More detail for on_quit events and a new on_cwd change event 2026-11-12 11:29:08 +05:30
Kovid Goyal
cb66ed55ca
Fix watcher calls being silently dropped during bursts of window changes
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Every on_resize and on_focus_change took its own 0s timer, so creating many
windows from a single callback filled the fixed size glfw timer table and
add_timer() returned 0, silently dropping the watcher calls. Now watcher
calls are queued and delivered in order behind a single pending timer, and
only when the window actually has a watcher for the event. Calls made during
delivery go to the next batch, preserving the recursion guard the timer
exists for.

Also fix add_timer() leaking a reference to the callback when the timer
could not be added.

Fixes #10853
2026-11-12 09:03:33 +05:30
Kovid Goyal
b261b08b7a
Keep the session of tabs and windows moved to another tab or OS window
A tab moved to another OS Window keeps its session, and new tabs and OS
Windows created for moved tabs and windows belong to the session of what
was moved. A window keeps its own session, which may be none, wherever it
is moved, so --add-to-session=! is respected; a window of no session
belongs to the session of the tab it is in.

Add Window.effective_session_name for the "window session, else its tab's
session" rule that was duplicated in five places, and use it in launch as
well, so --add-to-session=. and --cwd=current agree with
new_window_with_cwd. OS Windows created by launch --type=os-window or for
moved tabs and windows now also record their session.

Closes #10851
2026-11-12 08:51:54 +05:30
Kovid Goyal
a0ac36784f
Cleanup previous PR 2026-11-12 08:49:43 +05:30
Zhizhen He
c5e6bdf1fe
Preserve session files when save_as_session --match has no windows to save
Report an error before writing if a filtered session serializes to
nothing. This keeps an existing session file intact and avoids
creating an empty one at a new path.
2026-11-12 09:33:49 +08:00
Kovid Goyal
6d8f7ac14f
Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Let preview renderers supply extra cache key data instead of checking for
the cmd_renderer type. Include the command line in the key for custom
previews and the video_preview settings in the key for video thumbnails,
so that changing them no longer shows stale previews. GetPath and AddPath
now take this extra key data, replacing GetPathWithAlias.

Track the entry each path uses per extra key, so that previews of one file
with different settings do not evict each other. Do not remove an entry
while another path, such as another symlink to the same file, still uses
it. Cache hits are now recorded so that such shared entries are known.
Failing to remove an orphaned entry on a cache hit no longer turns the hit
into an error.

Fix ensure_entries() discarding unwritten changes when the entries file
does not exist yet, which lost the first path recorded in a new cache.
Also reset the path map when clearing the cache.
2026-11-11 21:26:01 +05:30
Zhizhen He
a1f5604cc2
choose-files: Keep custom preview caches separate for symlinks
Custom preview commands receive the selected path. Include that path
in their cache key so that symlinks to the same file can have different
previews. Keep the resolved target in the key so retargeting a link
still invalidates its entry.
2026-11-11 23:32:42 +08:00
Kovid Goyal
7e16359486
Keep everything drawn over the frozen frame aligned during synchronized output
While rendering is paused, output can change the live scroll position,
pixel scroll offset, scrollback size and active screen. Image layers,
cursor visibility and the scrollbar used those live values while the
text was drawn from the frozen snapshot, so they drifted from it.

Capture the scrollback size and active screen at pause time and add
rendered_scrolled_by, rendered_history_count and rendered_on_main_screen
macros alongside rendered_pixel_scroll_offset_y. Move image layer
updates and scrollbar visibility and geometry into screen.c so the
renderer and the tests share the same code.

Closes #10847
2026-11-11 13:29:24 +05:30
Kovid Goyal
a9147bbf01
Fix erase_last_command when the live prompt has scrolled into the scrollback
When the first lines of the live prompt were in the scrollback, an unsigned
wrap made erase_last_command delete most of the screen and the newest
scrollback lines, including the live prompt. Delete the erased lines from
the middle of the scrollback instead, with a new historybuf_delete_lines()
that removes multicell chars cut by the deletion, and also remove such
fragments from the screen. Clear selections and the wrap flag of the line
above the erased lines on every path.

Also keep the last visited prompt on the same content when lines are
inserted or deleted (CSI L/M), forget it on a hard reset, and only fill from
the scrollback when unscrolling (CSI + T) if the scroll region starts at the
top of the screen, instead of overwriting the top line of the screen.
2026-11-11 11:22:56 +05:30
Kovid Goyal
e52586d87c
Track the last visited prompt as a single content row
Store the last visited prompt as one row relative to the top of the live
screen (negative rows are in the scrollback) plus the viewport row it was
visited at, and derive the scroll offset when it is used. Previously it was
stored as a (viewport y, scrolled_by) pair that every code path moving lines
had to keep consistent by hand, which broke after erasing a command left
less scrollback than the saved offset, and when scrolling regions with
margins or reverse indexing.
2026-11-11 11:08:48 +05:30
Kovid Goyal
7f5dc2d39c
Update changelog 2026-11-11 08:51:57 +05:30
Kovid Goyal
246df5abf1
save_as_session: Cleanup previous PR
Choose the tab to focus using only the windows that were actually saved,
moving the choice into a pure function so it can be tested without
constructing a TabManager. Test the first OS window logic with simple fake
tab managers instead of patching TabManager internals. Merge the changelog
entries and mention restore after logout.
2026-11-11 08:41:17 +05:30
Chance Zibolski
6234c5f99c Fix the focus_tab written by save_as_session --match
TabManager.serialize_state_as_session wrote focus_tab as the index of the
active tab among all the tabs of the OS window, but loading a session
counts only the tabs it creates. With --match the tabs of other sessions
are not saved, so a session with such tabs before its active tab came back
on the wrong tab, or on its last tab once the index was clamped.

Write the index among the saved tabs. When the active tab is not saved, as
when it belongs to another session, write the saved tab with the most
recently focused saved window. That is the tab kitty focuses when switching
to the session while it is open, as window_for_session_name picks the
session's most recently focused window, so the session comes back as it was
last seen. Leaving focus_tab out instead would focus whichever saved tab
has the last focus command, usually the last one, which is arbitrary.
2026-11-10 16:02:17 -08:00
Chance Zibolski
32c6dbd501 Do not open save_as_session --match sessions in a new OS window
Boss.serialize_state_as_session passed is_first to the first OS window it
serialized, which is any but the focused one when there are several. With
--match that OS window can have no matching windows and write nothing, and
the next one then started the file with new_os_window, so loading the
session opened it in a new OS window instead of the current one. Whether
it did depended on which OS window had focus when saving.

Pass is_first to the first OS window that writes anything.
2026-11-10 16:00:46 -08:00
Kovid Goyal
a95310e8bc
choose-files: Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Always reply from the calibre worker, even when reading metadata raises or
calibre emits stray output, so that the request does not block until it
times out.

Accept cached calibre metadata generated for a different path to the same
file, as the disk cache key resolves symlinks. Otherwise a symlink and its
target keep invalidating each other's cache entry.
2026-11-10 19:29:52 +05:30
Kovid Goyal
501c57deb5
Make scrollback anchoring more robust
Fix various code paths that dont deal with scrolled back state
correctly.

Closes #10841
2026-11-10 19:20:17 +05:30
erango
fa1d1b40ab Add T1K to the list of terminals implementing the keyboard protocol 2026-11-10 09:53:59 +02:00
Kovid Goyal
67c6d243c4
Fix animated mouse pointers restarting on every mouse move
The mouse-demo kitten popped and pushed the pointer shape on every mouse
event, and kitty applied each OSC 22 to the OS pointer immediately, so the
pointer briefly flipped to the default shape and back, restarting
animations. Only change the shape in the kitten when it actually changes,
and apply pointer shape stack changes to the OS pointer once per batch of
parsed child output.

Also have ApplyHoverStyles replace the current shape instead of pushing a
new one, so the shape stack does not grow as the mouse moves between
regions.

Fixes #10838
2026-11-10 08:49:23 +05:30
Kovid Goyal
bc1628d849
get-colors: Report cursor text color as cursor_text_color
ColorProfile.as_dict() used the key cursor_text instead of the kitty.conf
name cursor_text_color, so get-colors listed the window override under a
different name than the configured value, which then shadowed it.
2026-11-10 08:27:50 +05:30
Kovid Goyal
f0286492d5
set-colors: Accept cursor_text_color background in color files
The Go client rejected the value, even though kitty.conf and the old Python
client accept it and treat it as None. Fixes #10832
2026-11-10 08:24:47 +05:30