Check for conversion errors per option so a failed conversion returns
immediately instead of storing the error sentinel and continuing. Document
why macos_titlebar_color stays signed. Make the test meaningful on 64-bit
platforms by asserting negative values are rejected for the unsigned
options, and restore options afterwards.
RGB encodings can use the high bit of a 32-bit long. Decode the Wayland titlebar and scrollbar colors as unsigned values at runtime, matching their config converters. Keep the signed macOS titlebar sentinels.
Expect OverflowError for dimensions that exceed sys.maxsize, since
PyArg_ParseTuple rejects them before the PNG buffer validation runs.
Continue to expect ValueError for invalid dimensions and buffer lengths
that reach the validation code.
Use int64 for encoded special colors so RGB values shifted into the
upper three bytes remain positive on 32-bit platforms, while preserving
the negative sentinel values used for macOS titlebar colors.
Update the tests to use the same type, avoiding overflowing int constants
when compiling them on 32-bit platforms.
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.
Replace the grab/release error handler pattern with a process wide
handler that is installed for the lifetime of the display. Errors are
captured by nestable traps identified by request serial numbers, so
traps only capture errors from requests made while they are open, and
errors from requests not covered by any trap are reported rather than
exiting the process.
Requests to windows owned by other clients (selection requestors, drag
and drop peers) are trapped individually, without waiting for a round
trip to the server, and without covering calls into the application.
Also fix reading uninitialized memory when handling a MULTIPLE
selection request whose requestor window has been destroyed, trap
errors when replying to drag sources, report failure to deliver drag
data, and fix detectEWMH() leaving the error handler installed on an
early return.
Follow up to the previous commit fixing hangs when previewing named pipes:
- Skip previewing anything that is not a regular file (or a symlink to
one) in preview_for, before any previewer opens it. This avoids
unblocking and then breaking writers waiting on a FIFO and covers the
non-text previewers (images, video, archives, calibre, commands) too.
- Apply the text preview size limit to the symlink target instead of the
symlink itself, and enforce it while reading so that files growing
after stat() are also handled.
- Pre-allocate the read buffer based on the file size, as os.ReadFile does.
- Read ignore files during scanning with the same non-blocking reader, so
a FIFO named .ignore or .gitignore cannot stall the scan.
- Unblock goroutines stuck on FIFOs when tests time out.
Answering a SelectionRequest writes a property on the requestor's window
and sends it a SelectionNotify. The requestor may destroy that window at
any time, for example right after issuing ConvertSelection. The reply
then fails with BadWindow, and without an error handler installed,
Xlib's default handler exits the whole process:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 18 (X_ChangeProperty)
This happens in practice with clipboard-syncing clients such as the
Looking Glass client, which request PRIMARY while the user drag-selects
text in kitty, and takes down every window of a --single-instance kitty.
Trap X errors while replying to selection requests, for both the
synchronous path and the asynchronous drag-and-drop data reply.
Open text preview files in nonblocking mode and check the type on
the opened descriptor before reading. Reuse the same read for syntax
highlighting because it can reopen a path after the file changes.
bash is compiled with the paths to its system wide profile and bashrc
(SYS_PROFILE and SYS_BASHRC) and there is no way to query bash for them.
Previously kitty guessed locations in /etc, which fails on distros that
keep these files elsewhere, such as hermetic /usr distros like Clear Linux
(/usr/share/defaults/etc) or Nix (/etc/bashrc).
Now find the paths by scanning the bash executable for them, both in kitty
and in kitten run-shell (so it works on remote hosts via the ssh kitten).
The result is cached per executable in kitty. If the scan fails, or the
locations are explicitly specified via the environment, the previous
behavior is used.
Fixes#10819
Use Capture.ByteRange() from v2 instead of a hand-rolled rune to byte
offset mapping. The old mapping required capture offsets to be monotonic
across matches, so a capture inside a lookaround overlapping a later match
in non-ASCII text caused all matches to be silently dropped.
Also propagate match errors instead of discarding them. Drops the v1
dependency, v2 was already pulled in by chroma.
Shake only the window in which a bell occurred, using
d.bell_window_geometry, either side to side or in random directions.
Useful for shaking the window when a shell command fails. Add docs with
shell snippets to ring the bell on command failure and demo entries.
Fire the event directly from screen_bell() instead of piggy-backing on
start_visual_bell_at in the render loop. Previously the event only fired
when visual_bell_duration was non-zero and bells in windows that were not
visible fired it late, when the window was next rendered. Now only bells
in visible windows (in the active tab and not hidden by an overlay or the
layout) fire the event.
glfwGetWaylandCurrentMonitorFractionalScale() looped on
wl_display_roundtrip() until every monitor had received xdg_output
logical size and position, with no limit. Compositors do not send
these for an xdg_output created on an output whose global has
just been removed, so kitty would hang forever when creating a new OS
window after output churn.
Bound the wait to a few roundtrips and remember monitors for which we
gave up so we dont wait on them again. Re-lookup monitors after each
roundtrip, since a dispatched global_remove can free them.
Also track outputs that have been bound but not yet announced via
wl_output.done, so that a global_remove arriving before done frees them
instead of the dead output being announced later and living in the
monitor list forever.
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