621 Commits
Author SHA1 Message Date
Benoit de Chezelles 3bbf48b1bf termwiz: Add a CI guard+tests for the compiled terminfo entry (#8368)
The compiled terminfo is reduced to a single artifact that CI checks
against its text source, failing on any drift.
Tests load the embedded entry and cover an XTGETTCAP response.
2026-11-20 09:00:05 +01:00
Josh Triplett aa0d91a49f term: Send current focus immediatly when focus tracking starts (#8325)
Other terminals do this when enabling focus tracking, and some programs
behave much better when they get it.
For instance, vim enables focus tracking when resumed after being
backgrounded, and then processes things on the focus event, such as
noticing if a file was changed.

Without this patch: saving a file in vim, Ctrl-Z, `cargo fmt --all`,
and `fg`; vim doesn't immediately notice the file was changed to reload it. (and then, you might edit the file further, and get a conflict later
when vim notices)

With this patch: vim notices the changes right away, making for a
smoother experience.
2026-11-12 04:29:39 +01:00
9fa147c953 term: Add TerminalState accessors for downstream users (#8045)
Add mouse and focus accessors to TerminalState so downstream programs
using wezterm-term crate can introspect the state and act in it.


---------

Co-authored-by: Mark Shamis <mark.shamis@gmail.com>
Co-authored-by: Benoit de Chezelles <benoit.dechezelles@gmail.com>
2026-09-09 08:15:06 +02:00
xtqqczze 092dcf70d8 style: Add newline after inner attribute for readability (#8130)
Add a newline after inner attributes to make it clear that the
attribute applies to the enclosing item rather than the following item.
2026-09-05 15:31:29 +02:00
LoggerandIdo Samuelson 3ff7522b96 image(perf): hash each transmitted image once (#8065)
ImageDataType::Rgba8 carries the sha256 of its pixels, set wherever one
is built and refreshed wherever the pixels are mutated.
compute_hash always re-hashed the pixels to produce same stored hash.

Image hashing ran 3 times for every transmitted image:
- once in new_single_frame on image creation
- once for the cache key in raw_image_to_image_data
- once more in ImageData::with_data on the miss path

A 2400x1440 RGBA frame is 13.18MiB, so a client transmitting frames at
60fps spends most of its time budget there.

AnimRgba8 keeps hashing, because its stored hashes are per-frame, not
global, which compute_hash needs (all frames + their durations).

---------
Co-authored-by: Ido Samuelson <i-am-logger@users.noreply.github.com>
2026-08-19 18:37:03 +02:00
Wez Furlong fe3006aefc term: reset more state on RIS full reset
When a program turns on modifyOtherKeys and exits uncleanly, it can
leave ctrl keys emitting escape sequences the shell doesn't understand.
The obvious recovery is the "Reset the terminal emulation state in the
current pane" command in the command palette, which sends RIS.  However,
RIS wasn't clearing modifyOtherKeys, so it didn't help. This commit
fixes RIS to reset that state, and a sweep for the same kind of
omission turned up missing resets for left/right margin mode and bidi
overrides, which it now resets too. This brings RIS in line with the
state a soft reset (DECSTR) already clears.
2026-08-12 07:01:21 +01:00
zakradandBenoit de Chezelles d6e1859782 fix(term): avoid divide-by-zero crashes in inline image placement (#7872)
assign_image_to_cells contained two unguarded divisions that could panic
with 'attempt to divide by zero' and take down the pane (and, under the mux,
the pane's reader thread):

1. A Kitty graphics escape requesting a zero-sized placement (eg: an explicit
   w=0/h=0, or a source origin outside the image bounds) yields a
   draw_width/draw_height of 0, used as a divisor when sizing the image.
   This is the case reported in #6344.

2. Displaying a cell-sized image (one without explicit c=/r=) on a pane whose
   pty reported no pixel dimensions makes cell_pixel_width/height 0, which is
   then used as a divisor. A zero pixel size is the default PtySize and is what
   tmux/headless domains report, so a perfectly valid image crashes there.

Guard both: refuse the placement when the drawable region or the cell pixel
size is zero.
The error flows into the existing logging handlers for the Kitty, iTerm and
Sixel paths, so no callers change.
Real GUI panes always have a non-zero pixel size, so valid images are
unaffected.

Adds regression tests for both cases (each panics on main, passes with the
fix) and enables kitty graphics in the test terminal config (off by default)
so the path is exercised.

Closes #6344

---------

Co-authored-by: Benoit de Chezelles <benoit.dechezelles@gmail.com>
2026-06-21 22:45:33 +02:00
Jeff QuastandWez Furlong 577474d89e Prevent "screen scraping", disable DECRQCRA (#7701)
* Security fix: prevent screen scraping

Problem
-------

DECRQCRA was added in 6cbb3ba43, for 9702d1cf5 (esctest integration) Sunday, March 17 2019.  Six days later, March 23 2019, although esctest was removed in c93f967bc, DECRQCRA remained enabled by default for all WezTerm releases since.

March 2023, @j4james mentioned WezTerm has this option enabled by default https://github.com/microsoft/terminal/issues/14974, "some people consider it a security risk"

September 2023, https://dgl.cx/2023/09/ansi-terminal-security#cursor-checksum article writes, "using DECRQCRA [..] potential attack here is reading what is displayed on the terminal before a user SSHes to a remote system."

By switching to "alternate screen", it also possible to recover last TUI display, such as contents of the file last opened in an editor.

Example CLI script scrapes screens '0' and '1' of WezTerm, https://github.com/jquast/blessed/blob/master/bin/screen-scrape.py

Solution
--------

Disable https://vt100.net/docs/vt510-rm/DECRQCRA.html by default, may be re-enabled by configuration.

---

Refs: https://github.com/wezterm/wezterm/pull/7701

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2026-03-31 04:00:28 -07:00
James Holderness 58141ad6f2 term: indicate support for OSC 52 in Primary DA response
This is an extension agreed upon by modern terminals to indicate that
they support copying to the clipboard with XTerm's OSC 52 sequence.

https://github.com/contour-terminal/vt-extensions/blob/master/clipboard-extension.md
2025-06-22 06:44:36 +01:00
Wez Furlong 6c7e3722b1 term: normalize imports to wezterm-xxx rather than termwiz re-exports 2025-05-10 15:08:56 -07:00
HAMANO TsukasaandWez Furlong 8ec1f2451c add cell_widths option #6289
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2025-05-03 06:56:33 -07:00
Wez Furlong 54e70e51d2 wezterm-term: revise approach to zero-width graphemes
refs: https://github.com/wezterm/wezterm/issues/1422
refs: https://github.com/wezterm/wezterm/issues/6637

When we encounter a zero-width grapheme we need to be
a little bit smarter about how we handle it.

In the original implementation we'd unconditionally
remap these graphemes into a cell, effectively making
them appear as a blank cell with width of one.

Later we discovered that eg: BIDI control characters
should not be forced to display in this way, so the
logic was changed to elide these graphemes from the
model.

Subsequently we've found that the unicode line separator
should be treated as a blank.  The unicode FAQ says
that any character that has the White_Space property
should be treated that way.

This commit applies that logic: if we get a zero-width
grapheme, if it is white space we'll force it to
have a width of 1, otherwise we'll elide it from
the model.

This probably is still not perfect, but hopefully
balances things out to be good enough, at least
until we find an example of where it isn't the right call!
2025-03-09 06:28:06 -07:00
Wez Furlong 15506bf3ef term: moved saved cursor from ScreenOrAlt -> Screen
refs: #6669
2025-03-06 15:23:38 -07:00
Wez Furlong 44866cc137 new: ConEmu progress reporting OSC sequence
This commit parses and captures the progress state as set by
ConEmu style progress reporting escape sequences.

Changes to the state will propagage through the mux via the
existing MuxNotification Alert system, and should also transit
across multiplexer connections.  However, there is no separate
multiplexer state transfer for the progress state, so reconnecting
to a mux in the middle of a progress sequence will show as None
for the progress state, until the next update occurs.

Aside from propgating and exposing the state to lua via PaneInformation
and a Pane::get_progress method, wezterm doesn't do anything with
the progress information at this time.

This commit includes an example of how you might customize your
tab title to reflect the progress in the active pane.

refs: https://github.com/wezterm/wezterm/issues/6581
2025-02-09 18:26:23 -07:00
Wez Furlong fb023956cf termwiz: parse ConEmu progress OSC sequence
refs: https://github.com/wezterm/wezterm/issues/6581
2025-02-09 17:19:50 -07:00
Jose Biosca 47b91d8e0e fix mouse button streak requiring pixel precision 2025-02-07 19:11:37 -07:00
Wez Furlong 11c4b11669 s,wez/wezterm,wezterm/wezterm,
I moved the repo to an org of its own. Update various things
to reference the new location.
2025-02-07 13:08:01 -07:00
Wez Furlong 00644d4e1a update for new wezterm.org domain 2025-02-06 21:13:50 -07:00
Sean Estabrooks 659aedffe8 Region scrolling tests and a fix
@tbung fixed a scrolling bug in #6099.  This patch just
adds some tests and takes care of a couple corner cases
that still remained with region scrolling.
2024-11-28 09:01:13 -07:00
Sean Estabrooks b2889fe889 Region scrolling tests 2024-11-28 09:01:13 -07:00
Wez Furlong c0649ad4bb remove cfg_attr(feature = "cargo-clippy" noise
I never liked clippy for dropping turds like this throughout the
code. I'm glad it is no longer required, but now rust is warning
about this syntax being redundant.
2024-09-14 06:49:13 -07:00
Wez Furlong 45ec2464e5 docs and related fix for #6099
We should avoid nudging the scrollback position when there is no
scrollback allowed in this other case as well.

refs: https://github.com/wez/wezterm/pull/6099
2024-09-14 06:42:10 -07:00
Till Bungert f911e48a95 fix: only change stable row offset if screen has scrollback 2024-09-14 06:37:36 -07:00
Wez Furlong 56a27e93a9 cargo update
plus some noise around the image crate api evolving and deprecating
some type aliases.
2024-07-30 08:27:27 -07:00
Thayne McCombs 03407cae99 fix: Use cols not rows for left margin bound
The location of the left margin should depend on the width, not the
height.

Fixes: #5750
2024-07-30 07:40:42 -07:00
Wez Furlong 281b6e2740 deps: update metrics to a more recent version
This isn't the latest version of metrics; it's just a more recent
version that allows us to remove a duplicate ahash dependency from the
build graph.
2024-05-13 09:41:11 -07:00
Wez Furlong 14d426fea8 add cargo deny config, update lru 2024-05-13 08:29:36 -07:00
Wez Furlong 91a16e5224 remove unused local
this should have happened in efbafbc229
2024-05-09 22:30:25 -07:00
Wanchang Ryu efbafbc229 fix wrapped long line copy problem on tmux
wezterm ignores wrapped long line when alt screen is used and tmux uses
alt screen that makes copying wrapped long line into multiple lines.

After testing on sevaral tui apps like tmux, w3m, htop it seems to show
reasonable performance on resizing.

Fixes #5283
2024-05-09 14:35:26 -07:00
Wez Furlong aa94a98314 fix invalidation on palette change
refs: https://github.com/wez/wezterm/issues/4932
and possibly: https://github.com/wez/wezterm/issues/2635
2024-02-01 15:58:14 -07:00
Wez Furlong 86d9ec69f5 term: downgrade conpty tmux title mangling warning to debug
The user can't do anything about it anyway.
2024-01-31 07:36:30 -07:00
jonboh 820c451b57 add small helper function to better express bool casting 2024-01-28 07:59:13 -07:00
jonboh 500f84617e fix kitty image protocol display parameters 2024-01-28 07:59:13 -07:00
Wez Furlong 7f3a835548 fix excessive calls to format-tab-title
* Removed title update from main render loop
* Add to PaneFocused event
* term: only emit Alert::OutputSinceFocusLost for the first
  seqno bump after losing focus, rather than on every bump.
  That event indirectly causes the title to update

refs: https://github.com/wez/wezterm/issues/4788
2024-01-25 23:14:38 -07:00
Wez Furlong 516add5a4b fixup tests for seqno increment on resize change
refs: https://github.com/wez/wezterm/issues/4828
refs: https://github.com/wez/wezterm/issues/3694
refs: https://github.com/wez/wezterm/issues/2351
2024-01-23 18:31:59 -07:00
Wez Furlong 8f74e1c848 increment seqno when resizing
Without this, we don't invalidate the shape hash eg: when zooming a
pane.  This is potentially also the root cause of some other weirdness
with the multiplexer.

refs: https://github.com/wez/wezterm/issues/4828
refs: https://github.com/wez/wezterm/issues/3694
refs: https://github.com/wez/wezterm/issues/2351
2024-01-23 18:08:46 -07:00
Wez Furlong 9fc89e621f de-fang paste payloads by removing bracketed paste sequences from them
refs: https://github.com/wez/wezterm/issues/4765
2024-01-08 18:17:22 -07:00
Luis Javier Merino Morán 97e001c93c Clamp cursor position reported by CPR
From esctest:
CHATests.test_CHA_OutOfBoundsLarge
CUPTests.test_CUP_OutOfBoundsParams
HVPTests.test_HVP_OutOfBoundsParams
2023-11-22 14:56:26 -07:00
Luis Javier Merino Morán 769840d2cb DECRQCRA: treat uninitialized cells as spaces
The concept of uninitialized cells in wezterm is not the same as that on
VT520 or that on xterm, so treat them as spaces, at least when asking
for the checksum of a single cell, which is what esctest does.
2023-11-22 14:38:11 -07:00
Luis Javier Merino Morán c4654d8bf4 Make RIS also clear the alternate screen
xterm clears the alternate screen on RIS since #383. VTE and konsole
already did that.

From esctest:
RISTests.test_RIS_ExitAltScreen
2023-11-12 17:09:34 -07:00
Luis Javier Merino Morán f880188ae4 Default G1 to ASCII
As per DEC STD-070 3.6.4

refs: https://github.com/wez/wezterm/issues/3962
2023-11-07 08:22:51 -07:00
Sean Sullivan 5161de59fe expose pen attribute on terminal info 2023-09-22 12:21:15 -07:00
Wez Furlong 33e727b074 Respond to DECRQM 2027 - grapheme clustering
closes: https://github.com/wez/wezterm/issues/4320
2023-09-20 14:48:05 -07:00
Wez Furlong c1b7ba2f35 fix warning in latest rust compiler 2023-08-28 06:39:14 -07:00
Rémi Labeyrie da2c035ad2 feat: handle horizontal mousewheel events 2023-07-10 12:55:13 -07:00
Wez Furlong c54548df7e Fix ClearToEndOfLine in last column when wrap_next=true
Given a sequence like this, where the `ESC [ K` sequence is
emitted at the last column when wrap_next=true:

\u001b[47;30m  17:24:50 \u001b[0m\u001b[K

rather than treating the column as out of bounds, we'd clear the
final cell.

refs: #3548
2023-05-29 16:01:11 -07:00
Wez Furlong e0a4ebd586 implicitly reset palette when setting it to the equivalent of the config
refs: #3685
2023-05-29 14:46:43 -07:00
Wez Furlong 74da631430 mux: allow client to provide palette to mux server
The server-side ownership of the palette is a stumbling block for
many users, so let's fix it.

This commit allows the client to pass its configured palette to
the server when it connects, and when the config is changed.

That palette takes precedence over the palette from the server config.

However, if the remote application uses any escape sequences that
redefine the color palette, the color palette that was active at
that point in time is forked and use as the basis, and will remain
the active palette until the palette is reset via escape sequences.

refs: https://github.com/wez/wezterm/issues/2686
refs: https://github.com/wez/wezterm/issues/3397
2023-03-31 08:02:32 -07:00
Wez Furlong c1366b217d term: respect log_unknown_escape_sequences for OSC 2023-03-29 05:28:28 -07:00
Jalil David Salamé Messina 407b1297eb fix: Update snapshot (see commit 31100244) 2023-03-27 07:38:55 -07:00