697 Commits
Author SHA1 Message Date
Josh McKinney 374b4dca90 termwiz: add BufferedTerminal::terminal_ref
The only way to reach the terminal inside a BufferedTerminal was
terminal(&mut self), so code holding a shared reference could not ask
it for anything, including its size. dimensions(), reached through
Deref<Target = Surface>, is the size of the cached surface and only
changes when check_for_resize is called.

terminal_ref(&self) is the shared-reference counterpart to terminal(),
so callers can use the now &self Terminal::get_screen_size to get the
real size.
2026-11-23 13:41:27 +01:00
Josh McKinney 28709e0493 termwiz: take &self in Terminal::get_screen_size
No implementation needs mutable access to report the size. The Unix
version issues TIOCGWINSZ on the fd, the Windows version calls
GetConsoleScreenBufferInfo on the handle, and the mux and ssh
implementations copy a cached value.

The &mut requirement came from the UnixTty::get_size and
ConsoleOutputHandle::get_buffer_info helpers, which are both read-only
queries, so they take &self too.

This is a breaking change for implementors of Terminal. Callers are
unaffected, since &mut T coerces to &T.
2026-11-23 13:41:27 +01:00
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 0d11cabfc4 misc: Replace uses of deprecated ::max_value() with ::MAX (#8365) 2026-11-20 07:13:41 +01:00
Kyle Sower 771a4efacc termwiz: fix Se terminfo entry to reset cursor to configured default (#7762) 2026-11-20 06:45:47 +01:00
ZhongYu Li 2afb836403 termwiz: add ClearLine change (#8124) 2026-09-12 13:38:23 +02:00
xtqqczze d2f3f05b38 fix: mismatched_lifetime_syntaxes lint 2026-09-06 10:19:27 +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
xtqqczze 4fbd6b8e90 termwiz: Replace winapi with windows-sys (#8099) 2026-09-01 00:28:20 +02:00
Benoit de Chezelles 4b1c3c151e termwiz: Add Action::ClearLine for LineEditor (#8014) 2026-08-05 10:40:32 +02:00
Benoit de Chezelles 26270fd8d4 termwiz(lineedit): Add Ctrl-u for Kill to StartOfLine
Similar Clrt-k was already implemented, so adding Ctrl-u feels like a
logical addition.
2026-08-05 06:34:07 +01:00
Jesse Portnoy b16aa977e3 docs: fix typos (#8008) 2026-08-04 16:07:57 +02:00
Jonathan Giannuzzi 30ef869d72 Fix parsing of partial SGR mouse sequences 2026-01-17 15:35:15 +00:00
Jun Wu 06a06bca94 termwiz: respect use_serde for a few more structures
Add use_serde optional serde support for a few more structures.
2025-10-14 19:35:29 +01:00
Rebecca Turner bf9a2aeeba Fix mismatched_lifetime_syntaxes warnings
Fixes a bunch of warnings like this:

```
warning: hiding a lifetime that's elided elsewhere is confusing
   --> window/src/os/macos/window.rs:670:23
    |
670 |     fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
    |                       ^^^^^            ------------- the same lifetime is hidden here
    |                       |
    |                       the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
670 |     fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
    |                                                     ++++
```

This lint was added in Rust 1.89: https://github.com/rust-lang/rust/issues/141787
2025-09-09 07:05:12 -07:00
Wez Furlong 408b2016e2 termwiz: fixup win32 build 2025-05-11 05:45:14 -07:00
Wez Furlong 2b15e46421 refactor: extract wezterm-surface from termwiz 2025-05-10 15:07:21 -07:00
Wez Furlong 6740628da5 refactor: extract wezterm-cell from termwiz 2025-05-10 15:07:21 -07:00
Wez Furlong 47b6410f8f accommodate more no_std builds 2025-05-10 15:07:21 -07:00
Wez Furlong 80de3aa313 refactor: extract wezterm-char-props from termwiz
This new crate holds the unicode character properties
and other similar data on emoji and nerdfonts codepoints.
2025-05-10 15:07:20 -07:00
Wez Furlong 0cd3fe8f97 wezterm-escape-parser: allow building no_std (but with alloc)
This commit makes a number of parts of wezterm's core
parsing functionality no_std compatible, but requiring alloc.

In the no_std environment, several lookup tables that would
normally have been used to accelerate some operations are
not available and we instead fall back to an O(n) operation.
2025-05-10 15:07:20 -07:00
Wez Furlong 304fb40567 switch termwiz over to wezterm-escape-parser 2025-05-10 14:54:05 -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
Johannes Altmanninger 52c3515037 Advertize the Su capability too
I'm not sure if applications are supposed to use "Smulx" and "Setulc" or
"Su". Among the terminals that implement XTGETTCAP, contour, foot, ghostty
and kitty advertize both (and XTerm neither).

"Su" is the one mentioned in the original documentation
https://sw.kovidgoyal.net/kitty/underlines/

It's a boolean capability but I'd argue that's even better since I don't
think the flexibility of string capabilities is needed.  (Personally, all
I want to use it for is to answer "will this terminal break if I emit the
hardcoded \e[4:3m and \e[58:2::1:2:3m".

Include "Su" in wezterm's terminfo, for the benefit of XTGETTCAP users..
Updated the compiled database with

	tic -x termwiz/data/wezterm.terminfo -o termwiz/data

Alternatively we could change the kitty documentation.
2025-05-03 06:39:43 -07:00
Wojciech Graj e7d0424cb3 Parse all permutations of optional parameters for CSI P s ; P s X. 2025-04-13 06:52:16 -07:00
Jun Wu 50ea8c3811 termwiz: lazy_static => std::sync::LazyLock
`LazyLock` is a stdlib drop-in replacement to drop the lazy_static
dependency.
2025-04-12 22:05:40 -07:00
Jun Wu 33b40fe629 termwiz: make tmux control code optional with a Cargo feature
The tmux control code support depends on `pest`, which might be a
dependency that some projects won't need. This change makes it
optional with a Cargo feature. It's default on to maintain compatibility.
2025-04-12 22:05:40 -07:00
Jun Wu b4261af93e termwiz: make image support optional with a Cargo feature
The `image` module introduces some extra dependencies that seem a bit
heavyweight. This change adds an `image` Cargo feature to make related
features optional.

    ├── sha2 v0.10.8
    │   ├── cfg-if v1.0.0
    │   ├── cpufeatures v0.2.17
    │   └── digest v0.10.7
    │       ├── block-buffer v0.10.4
    │       │   └── generic-array v0.14.7
    │       │       └── typenum v1.18.0
    │       └── crypto-common v0.1.6
    │           ├── generic-array v0.14.7 (*)
    │           └── typenum v1.18.0
    └── wezterm-blob-leases v0.1.1
        ├── getrandom v0.3.1
        │   ├── cfg-if v1.0.0
        │   └── libc v0.2.170
        ├── mac_address v1.1.8
        │   └── nix v0.29.0 (*)
        ├── sha2 v0.10.8 (*)
        ├── thiserror v1.0.69 (*)
        └── uuid v1.15.1
            ├── atomic v0.6.0
            │   └── bytemuck v1.22.0
            └── getrandom v0.3.1 (*)

The `image` feature is default on to maintain compatibility.

Test Plan:

    cargo check --no-default-features
    cargo check
2025-04-12 22:05:40 -07:00
Wez Furlong ddd60384f3 update changelog 2025-03-20 07:20:19 -07:00
Wez Furlong 4bf28e253c deps: set workspace pest dep to 2.7
This is the same version that is captured in the lock file,
but that lock file doesn't get propagated through to eg: termwiz
when published on crates.io.

Let's be explicit that we need this version because 2.1 doesn't
compile the `continue` token in our pest file:

https://github.com/wezterm/wezterm/pull/6810#issuecomment-2739610838
2025-03-20 07:18:53 -07:00
Wez Furlong d0ff5cb892 termwiz: update changelog 2025-03-19 07:27:28 -07:00
Wez Furlong 8b7ca454b5 termwiz: bump version 2025-03-19 07:23:49 -07:00
Zeev Rotshtein eb9f8604e1 fix: deal with Windows Terminal mouse move with no buttons SGR report 2025-03-19 07:14:06 -07:00
Wez Furlong 7a45f25501 termwiz: add is_white_space_(char|grapheme) helper functions
These are not really expected to be used by most applications.
They are being added to the cell module to support some higher
level checks as part of trying to handle these wezterm issues
a bit better:

 https://github.com/wezterm/wezterm/issues/1422
 https://github.com/wezterm/wezterm/issues/6637

These functions use the White_Space properties as defined by
the UCD version 16.

I'm using the trie form of the data here because I'm already
using the ucd-trie module on other properties.  The dataset
for White_Space is quite small, and is probably fine to use
a binary search on the non-ucd form of the data, I just didn't
have an example of that code hanging around and didn't want
to have to get distracted debugging that; I somehow always
end up with an off-by-one somewhere when hooking up a binary
search for the first time!

This commit has no functional impact on termwiz or any
other crate in the wezterm repo.
2025-03-09 06:23:40 -07:00
Wez Furlong 6fc9719167 emoji_presentation: update for unicode 16 2025-03-09 05:48:52 -07:00
Wez Furlong a434ee3cd9 widechar_width: update for Unicode 16 2025-03-09 05:40:06 -07:00
Joe XueandWez Furlong 4ce83f093a fix: tmux -CC error on %config-error (#6773)
* fix: tmux -CC error on %config-error

refs: #6763

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2025-03-09 04:25:53 -07:00
Joe Xue dd546c9d98 Reorg the code to put rules/events in alphabet order 2025-03-08 19:24:19 -08:00
Wez Furlong 7aadebfe48 termwiz: fix panic when appending long runs to clusterline
There were two different overflows that could happen here when
resizing the terminal from a narrow width to a much wider width,
when the input consists of very very long logical lines.

The first was that we could overflow the maximum number of
cells in the ClusteredLine struct, which had u16 as its type.

The second, after changing u16 to u32, was the maximum length
of a run of cells with the same attribute.

The former could be fixed, preserving the smaller integer type,
by adjusting the API to allow it to return the overflow, but
that feels awkward and we could just increase the size of
the integer type.

The latter can be caught with an overflowing_add operation
and breaking the run in the overflow case.

That is what this commit does.

+bump codec version because this causes a small change
in the serialization of line data used by the mux
protocol.

refs: https://github.com/wezterm/wezterm/issues/6729
2025-03-08 12:25:06 -07:00
Wez Furlong 18371a158c termwiz: add update-changelog.sh
This has the appropriate invocation of git-cliff to update
the changelog

refs: https://github.com/wezterm/wezterm/pull/6709
2025-03-08 06:38:09 -07:00
Josh McKinney e6a323745e Update termwiz Changelog with git-cliff
This is not perfect, but maybe useful
2025-03-08 05:18:00 -08:00
Joe Xue 7e0e15a132 Tmux control: address comments, second round, remove unwrap()
refs: #336
2025-03-07 09:00:48 -08:00
Joe Xue 238896fc41 Tmux control: Address the comments, second round
refs: #336
2025-03-07 09:00:48 -08:00
Joe Xue 279bf50711 Tmux control: address the comments
refs: #336
2025-03-07 09:00:48 -08:00
Joe Xue 7ddaddaf3c remove the commented code 2025-03-07 09:00:48 -08:00
Joe Xue 327a4dd135 Prune panes, tabs
refs: #336
2025-03-07 09:00:48 -08:00
Joe Xue fbb7aecd9f Tmux controle mode, sync remote windows, layouts, panels
refs: #336
2025-03-07 09:00:48 -08:00
Thomas Buckley-Houston d1a077527b Add Clone derive to termwiz::surface::Surface 2025-03-06 11:52:48 -08:00
mgpinf 85409e57a3 Option to disable attributes for non matching text in quick select mode (#6683)
* feat: optionally disable non-matching text attributes in Quick Select

Add a configuration option
'disable_attributes_for_non_matching_text_in_quick_select' that disables
all attributes for non-matching text in Quick Select Mode.
The default value for
'disable_attributes_for_non_matching_text_in_quick_select' is false

This resolves the issue https://github.com/wezterm/wezterm/issues/4022

* docs: documentation for disabling attributes for non matching text in QuickSelect

Add documentation for the below configuration option:
- `disable_attributes_for_non_matching_text_in_quick_select`

* feat: display quick select label and match in bold

* refactor: fetch colors from existing reference to config

* fix: reset additional attributes for non matching text

Reset additional below mentioned attributes to default for non matching
text if the configuration option
disable-attributes-for-non-matching-text-in-quick-select-mode is true
- Italic
- Blink
- StrikeThrough
- Invisible
- Hyperlink

* fix: update attributes to reset

* feat: add reset_attributes function in termwiz cell

Add reset_attributes function in termwiz cell
Use the above function to reset cell attributes for the cell

* refactor: update method name to clear_attributes

* termwiz: update version because public method has been added

Update termwiz version because a new method 'reset_attributes' has been
added in termwiz/src/cell.rs

* fix: update get_lines method in quickselect to be same as with_lines_mut

* termwiz: simpler method name, implementation to clear cell attributes

Use simpler method name and implementation as per suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966596988

* refactor: clear cell attributes for every line if flag is set

Clear attributes for every line if the configuration option
disable-attributes-for-non-matching-text-in-quick-select has been set
Partially implement changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966597826

* refactor: replace for loop with for_each method to iterate through cells

Partially implement changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966597826

* refactor: rename configuration option to quick_select_remove_styling

Rename option to remove styling in quick select from
'disable_attributes_for_non_matching_text_in_quick_select' to
'quick_select_remove_styling'
Implement changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966598496

* fix: remove bold attribute when displaying quick select label, match

This is in order to raise this in a separate PR

Suggestion mentioned here
https://github.com/wezterm/wezterm/pull/6683#issuecomment-2676394535

* docs: update documentation for quick_select_remove_styling

* termwiz: just bump minor part

Since the only change in termwiz is addition of a public method, it
should be forward compatible, so we can just bump the minor part

Apply changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966600258

* fix: clear attributes for each cell in all lines in get_lines method

Apply changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966848308

* fix: clear appdata for line after clearing attributes of each cell

Move call to clear appdata for line after the call to clear attributes
from each cell when configuration option 'quick_select_remove_styling'
is enabled
Apply changes mentioned in suggestion
https://github.com/wezterm/wezterm/pull/6683#discussion_r1966848015
2025-02-23 15:37:09 -07:00
Wez Furlong 9da362c72b remove dead fuzzing code 2025-02-12 10:01:37 -07:00