Export NULL_COLOR_VALUE using PyLong_FromUnsignedLong instead of
PyModule_AddIntMacro, which converts it to a signed long. On 32-bit
platforms this turns 0xffffffff into -1 and causes the generated Go
uint32 constant to overflow, preventing kitten from building.
Add a regression check for the exported value.
Add the command-start, command-finish, alternate-screen-enter and
alternate-screen-exit events, which fire for changes in the active window,
and the active_window_command_running, active_window_alternate_screen,
active_window_command_state_age and active_window_alternate_screen_age
fields to KittyCustomShaderData, so shaders can show effects while
commands run and hide them in full screen programs.
Previously the cursor was always drawn after the pre-edit text, as the
cursor position sent by the input method was ignored, so one could not see
which character was being edited when moving inside the pre-edit text, as
with Chewing. Pass the pre-edit cursor from IBus, Wayland text-input and
macOS to kitty, in code points, and place the cursor there. On Wayland, do
not drop pre-edit updates that only move the cursor.
Also use the pre-edit cells rather than the original line under them to
size and color the cursor, so that it covers wide pre-edit characters.
The IME candidate window remains anchored at the start of the pre-edit text.
Fixes#10807
Preserve the grapheme segmentation state when the drawing line is
re-initialized after the current char has already been segmented, so that
emoji sequences are not split into multiple cells when wrapped or moved
past scaled text.
Mark colors are now stored per color layer and for the colors set by the
program, like the other colors, instead of in a single array that every
change overwrote. So set-colors without --configured no longer changes the
configured mark colors, window and session layer mark colors survive
changes to the global colors, resetting a layer, the color stack and full
reset restore the correct mark colors, --copy-colors copies them and
get-colors reports the mark colors of the window.
Make ColorProfile.test_mark_colors() return MARK_MASK pairs instead of a
hard-coded three, simplify the test by using MARK_MASK and mutable expected
values, and correct the changelog entry: config reload was not affected,
set-colors, launch --color, sessions and automatic theme switching were.
New color_scheme_dark, color_scheme_light and color_scheme_no_preference
options. When any of them is set, the ssh kitten sends the color schemes
for all three system color schemes to kitty, which applies the one
matching the current system color scheme and switches between them when
the system color scheme changes. color_scheme is used for modes without
a specific color scheme.
The colors are applied in a new session color layer, above the colors of
the window and below colors set by programs. They are associated with the
color stack entry pushed by the ssh kitten and are removed when it is
popped, so nested sessions work and the colors are restored on exit.
Configs that only use color_scheme continue to use escape codes exactly
as before, as does the kitten when running inside tmux.
Fixes#10724
Colors in a window are now tracked in layers: the global configured colors
(kitty.conf and the automatic color theme), the colors of the individual
window (launch --color, --copy-colors) and the colors set by the program
running in the window (escape codes, set-colors without --configured).
Switching between light and dark themes changes only the global layer, so
colors set by the ssh kitten, by programs or by launch --color are no
longer overwritten.
Only the colors set by the program are saved on the color stack, so
popping the stack, for example when exiting the ssh kitten, uses the
current theme colors for everything else rather than those from before
the theme change. launch --color colors now also survive config reloads.
set-colors --configured still replaces colors set in the matched windows.
Fixes#10724
The selection dirty check computed iteration data in a different
coordinate system than apply_selection() used to store last_rendered,
so the two never compared equal when scrolled back, causing the
selection buffer to be re-uploaded and the window redrawn every frame.
Use a common helper for both.
Fixes#10714
- Anchor the IME cursor rectangle at the column the pre-edit text is
actually drawn at, which is shifted left of the cursor when the text
would not otherwise fit on the line, instead of at the cursor column.
- Store the IBus cursor geometry cache per input context rather than in
a function static, only update it after a successful send and reset it
whenever a new input context is created.
- Add a test and a changelog entry.
- Parse in-band resize reports robustly: require the 48; prefix, accept
extra parameters and reject negative values instead of panicking
- Handle bracketed paste in parse_input_from_terminal with a dedicated
scan for the end of paste marker so pasted escape bytes are never lost
- Guard against NaN in scroll_by_pixels and scroll_to_absolute, clamp
negative absolute scroll targets, let infinite fractional scrolls clamp
and propagate overflow errors from PyLong_AsDouble
- Empty disk cache entries no longer claim offset 0 in the cache file and
defrag only moves entries actually written to disk
- Reject zero and too large block sizes in rsync signature headers
- Only replace the encryptor tag once it has been read successfully
- Back off on all accept() errors that leave the connection pending, not
just resource exhaustion, so the talk thread cannot spin on a readable
listener
- Use an atomic for the test only accept failure injection instead of
taking the talk mutex on every accept
- Encrypt disk cache entries in chunks of up to 1MB to reduce the number
of write syscalls for large images
- Have GlobalWatchers.set_extra() invalidate the cached watchers
When growing the buffer, realloc was passed the element count instead of
the byte count, shrinking the buffer while capacity was set to the larger
value. Lines with more than 4096 codepoints (e.g. many combining chars)
would then write past the end of the allocation.
These two code points have Grapheme_Cluster_Break=SpacingMark but a
width of one, the only such code points in Unicode. Grapheme
segmentation (GB9a) adds them to the previous cell, so "จำ" occupied a
single cell in kitty while wcwidth() based programs count two. As a
result the SARA AA glyph was clipped, only the nikhahit was visible and
the cursor drifted right by one cell per AM.
Now, when such a code point combines into a plain one cell wide cell,
the cell is widened to two cells, using the same mechanism as U+FE0F
does for narrow emoji. The C and Go wcswidth() implementations are
updated to match so that kitty's own width calculations agree with the
screen.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Pre-edit text was drawn in reverse video, which is a solid inverted block
moving through the line as you compose. Draw it as italic with a dashed
underline in the highlight color instead.
Underline rather than reverse video is what other terminals do: VTE renders the
pre-edit run with the input method's own attributes and marks only the cursored
cell distinctly, and foot underlines the run explicitly, excluding the part
under the cursor. Dashed avoids the underline styles applications already use:
curly for spell checking and straight for hyperlinks, which is the collision
that made reverse video look like the safer choice.
The styling is applied to the overlay's own cursor and restored afterwards,
alongside the wrap, cursor-visibility and insert-replace modes already saved
there. The previous code toggled reverse with XOR, which restored itself; the
three new attributes are saved and put back explicitly.
Closes#10382
Mostly comes from detecting the case of runs of ASCII printable
characters and using a special fast path for them. Improves benchmarks
as per benchmark.py by 15-30% for text heavy workloads
screen_scroll() looped `count` times with no upper bound, so CSI 2147483647 S
spun for ~2.1 billion iterations at 100% CPU and never returned, hanging the
whole terminal.
Scrolling up by more than the number of lines on screen blanks the entire
region, so clamp count to self->lines. Scroll Down (_reverse_scroll) already
caps its count the same way.
Fixes#10333
Allow terminal applications to detect when their view is not observable so they can avoid unnecessary rendering work.
Implement mode 2033 and the visibility status query, and report changes from tab, pane, window, and platform occlusion state.
This escape code is largely undefined. There is no specification for how
it affects alternate screen mode, overriden colors, kitty keyboard
state, paused rendering, etc. Do what I feel is sensible in these cases.
Fixes#10263
The TextCache interns every unique multi-codepoint cell text for the
lifetime of the window with no eviction, so a stream of unique texts
(for example random combining mark sequences) grows memory without
bound, several hundred MB/hour at moderate throughput.
Mirror the existing hyperlink pool garbage collection: every 8192
newly interned entries, steal the cache contents and have the Screen
remap the index in every live cell (history buffer, main and alt line
buffers, paused rendering snapshot and overlay line), re-interning
only entries still referenced by some cell. Entries whose last
reference scrolled out of the history buffer are freed.
See #10249
Co-Authored-By: Claude <noreply@anthropic.com>
erase_last_command selected the region to erase via find_cmd_output(..., -1),
which anchors on OUTPUT_START (OSC, 133;C). Commands that produce no output
(an empty Enter, a comment, cd, export, etc. -- never emit 133;C, so they were
skipped and an older command-with-output was erased instead. "Erase the last
command" therefore did not erase the last command whenever the most recent ones
has no output.
Select the region by prompt marks instead: erase the prompt block immediately
above the current (live) prompt, whatever it contains. Every submittd command
is now one unit, removed newest-first, one prompt block per invocation.
This also fixes two latent defects in the previous implementation:
* The on-screen deletion was anchored at `cursor->y - count`, which
assumes the region ends exactly one row above the cursor.
Multi-line prompts and skipped rows broke that assumption and left
residual lines. Anchor at the top of the region instead.
* When part of the erased region was in the scrollback, the lines
were removed from the history buffer but no redraw was signalled,
so the deletion of the off-screen lines only became visible after
the next scroll event recomputed the history viewport. Clamp
scrolled_by to the new history length and call dirty_scroll()
after shrinking the buffer.
include_prompt is retained for API compatibility but is now a no-op: the
unit erased is always the whole prompt block.
Recognize CSI ? 5 W as DECST8C, which resets the active screen's tab
stops to the default of every 8 columns. Other CSI W variants continue
to produce a parse error.
Signed-off-by: Ayman Bagabas <aymanbagabas@gmail.com>
Previously, every window resize reinitialised the tab stops to the
default of every 8 columns, discarding any stops set via HTS or cleared
via TBC. ECMA-48 only treats RIS, DECSTR, and DECCOLM as events that
reset tab stops, and other terminal emulators all preserve user-set
stops across an interactive resize.
Copy the surviving prefix of the previous tab stops into the freshly
allocated array on both main and alt screens. Newly added columns when
growing the window keep the default every 8 columns pattern. Also point
the active tabstops pointer at the alt screen's array when a resize
happens while the alt screen is active, instead of unconditionally
resetting it to the main screen's array.
Signed-off-by: Ayman Bagabas <aymanbagabas@gmail.com>
Add a regression test that exercises the code path which crashed in
v0.46.2 (#10017): when paused_rendering is active and a selection
extends into the scrollback, the inner loop of apply_selection iterates
with a negative y. Without the recently-added paused_y translation and
the paused_y < 0 guard, the call to linebuf_init_line treats the
negative y as a huge unsigned index_type and reads ~4GB out of bounds
in line_attrs[idx], crashing with SIGBUS.
The test reproduces the trigger deterministically via the Screen Python
bindings and asserts that current_selections() returns the expected
buffer instead of crashing.