1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00
Commit Graph

552 Commits

Author SHA1 Message Date
kumattau
f9d22cc357 Fix missing string after ";" from icon and window title 2022-05-01 08:56:03 -07:00
Wez Furlong
97005b8c1c termwiz: use perfect hashing for emoji variation sequences 2022-04-26 19:10:00 -07:00
Wez Furlong
fb635c4362 feed unicode version config through to Line for ls-fonts
This makes the reported metrics show correctly for:

```
wezterm -n --config "font=wezterm.font('Noto Sans Mono CJK JP')" \
        --config treat_east_asian_ambiguous_width_as_wide=true \
        ls-fonts --text ".☆a☆☆☆☆"
```

refs: https://github.com/wez/wezterm/issues/1888
2022-04-19 21:12:21 -07:00
Wez Furlong
cf20de8899 termwiz: fixup test build for ambiguous width change
refs: https://github.com/wez/wezterm/issues/1888
2022-04-19 07:08:50 -07:00
Wez Furlong
5b8b9630a3 Add treat_east_asian_ambiguous_width_as_wide option
I've bundled this into termwiz's UnicodeVersion type as that is
a similar concept that is already routed through to the appropriate
function.

refs: https://github.com/wez/wezterm/issues/1888
2022-04-19 06:56:39 -07:00
Wez Furlong
132377cc33 termwiz: treat graphemes in Unassigned range as width=1 rather than 0
Otherwise we filter them out of the terminal model and they effectively
vanish.

refs: #1864
2022-04-12 09:52:03 -07:00
Wez Furlong
5914a91490 palette now stores alpha for all color values
We're now capable of remembering an alpha value for everything
in the palette and the main window theme, but not the tab bar theme.

Whether the alpha is correctly respected at render time is a different
story!

refs: #1835
2022-04-08 07:08:33 -07:00
Wez Furlong
b35e3b2aad deps: remove pretty_env_loggger
Go directly to the underlying env_logger crate, as pretty_env_logger
hasn't been updated in some time, and I'd like to be able to redirect
the log output to a file more directly, and that feature is in a newer
version of the env logger than pretty_env_logger was pulling in.
2022-04-07 08:24:07 -07:00
Wez Furlong
1bb31d78ab termwiz: fix code formatting
doh!
2022-04-07 07:39:52 -07:00
Wez Furlong
d0d23d6c46 termwiz: prep for crates.io 2022-04-07 07:27:54 -07:00
Wez Furlong
e92db03ec8 termwiz: add comment about bracketed paste offset 2022-04-07 07:16:13 -07:00
Thomas Linford
59425237bc termwiz: fix partial bracketed paste panic 2022-04-07 07:16:13 -07:00
Thomas Linford
28baf56a6e termwiz: add test for partial bracketed paste 2022-04-07 07:16:13 -07:00
tantei3
60ec82554b
Added support for kitty images protocol using Shared Memory (#1810)
* termwiz: add support for kitty image using shm mode
* termwiz: kitty image shm cleanup error handling
* termwiz: kitty image shm create wrapper for HANDLE and impl Drop for it
* termwiz: kitty image shm refactor windows implementation

Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
2022-04-03 12:59:58 -07:00
Wez Furlong
1c9bd347c2 multiplexer: improve handling of image attachments
There were a a couple of issues:

* `ImageData::hash` would re-hash the image on every call, and this was
  called for every cell that comprised an image on the mux server side
* `SerializedLine` needed to understand how to remove the `Arc<ImageData>`
  image attachments so that we didn't serialize a complete copy of the
  image per cell that comprised the image.

A new RPC was introduced to attempt to fetch `ImageData` given its
content hash and pane, row and cell index as a hint to locate it.

A client side LRU of content hash to `ImageData` is used to avoid
issuing repeat calls to that new RPC.

refs: #1237
2022-03-28 20:28:05 -07:00
Wez Furlong
b9c194c0d3 sixel: remove leftover debug
refs: #217
2022-03-27 16:27:14 -07:00
Wez Furlong
77e5cdd00d sixel: improve sixel parsing performance.
Test scenario is:

```
wezterm -n --config enable_kitty_graphics=false
./notcurses-demo -p ../data iv
```

In `20220326-231415-4cd89333`

```
             runtime│ frames│output(B)│    FPS│%r│%a│%w│TheoFPS║
══╤════════╤════════╪═══════╪═════════╪═══════╪══╪══╪══╪═══════╣
 1│   intro│  12.38s│    238│  10.50Mi│   19.2│ 1│ 0│82│  22.82║
 2│    view│  37.87s│    982│  89.35Mi│   25.9│ 0│ 0│46│  54.31║
══╧════════╧════════╪═══════╪═════════╪═══════╧══╧══╧══╧═══════╝
              50.25s│   1220│  99.86Mi│
```

With this commit:

```
             runtime│ frames│output(B)│    FPS│%r│%a│%w│TheoFPS║
══╤════════╤════════╪═══════╪═════════╪═══════╪══╪══╪══╪═══════╣
 1│   intro│   3.39s│    458│  23.13Mi│  135.2│ 8│ 1│17│ 490.79║
 2│    view│  18.59s│    978│  89.35Mi│   52.6│ 1│ 0│ 5│ 645.10║
══╧════════╧════════╪═══════╪═════════╪═══════╧══╧══╧══╧═══════╝
              21.98s│   1436│ 112.48Mi│
```

as a point of comparison, here's the kitty protocol numbers on
the same build:

```
             runtime│ frames│output(B)│    FPS│%r│%a│%w│TheoFPS║
══╤════════╤════════╪═══════╪═════════╪═══════╪══╪══╪══╪═══════╣
 1│   intro│   3.68s│    485│  39.49Mi│  131.7│ 5│ 1│23│ 421.85║
 2│    view│  20.66s│    979│ 423.90Mi│   47.4│ 1│ 0│18│ 225.83║
══╧════════╧════════╪═══════╪═════════╪═══════╧══╧══╧══╧═══════╝
              24.34s│   1464│ 463.39Mi│
```

so we're now in the same ballpark.

cc: @autumnmeowmeow in case you have some other sixel benchmarks
to help verify this :)

refs: https://github.com/wez/wezterm/issues/217
2022-03-27 15:30:43 -07:00
Wez Furlong
15cd990e33 refactor: move sixel parser/builder to own file 2022-03-27 13:38:33 -07:00
Wez Furlong
5b0edfddea hyperlink rules: avoid panic when a capture is missing
```
./target/debug/wezterm -n --config 'hyperlink_rules={{regex="pr-(\\d+)(-\\d)?",format="https://github.com/NixOS/nixpkgs/pull/$1"}}'
```

then output `pr-1`.

refs: #1780
2022-03-27 11:12:16 -07:00
Wez Furlong
5b09ff1dd0 fix incorrect csi-u encoding with non-ascii characters
refs: https://github.com/wez/wezterm/issues/1746
2022-03-21 20:38:42 -07:00
Wez Furlong
0fcdea0789 sixel: allow slightly poorly formed sixel data
The issue appears to be due to a rogue trailing semicolon in the input
data.  Support for this appears to be mixed: an online converter didn't
produce valid output, but image magick's convert utility accepted it.

This commit allows an optional trailing semicolon at the end of the
color definition regex and enables wezterm to render the image.

refs: https://github.com/wez/wezterm/issues/1711
2022-03-19 14:24:10 -07:00
Ivan Tham
84007274cf Docs change Duration::new(0, 0) to Duration::ZERO 2022-03-18 07:50:10 -07:00
Greg V
9879005f87 add support for XF86Copy/XF86Paste keys 2022-03-11 06:43:18 -08:00
Wez Furlong
3b209c671d termwiz: update widechar_width
Brings us up to date with c68f845054

Notably: ea5824d966
2022-02-11 20:16:40 -07:00
Autumn
4997c463d4
Support DECSDM (#1577)
* #217 DECSDM, and commented pseudocode for improved handling of transparent image cells

* oops forgot cargo fmt --all

* #217 set initial palette colors to match VT340

* #217 cleanup color_map initialization, fix sixel scrolling

* #217 remove large comment - transparency discussion for another time
2022-02-09 19:48:01 -07:00
Wez Furlong
435ff1e93b deps: image -> 0.24 2022-02-06 18:51:32 -07:00
Wez Furlong
8cb74c62d2 allow setting selection colors with alpha values
This commit allows the following configuration:

```
wezterm -n --config 'colors = { selection_fg = "clear", selection_bg = "rgba:50% 50% 50% 50%" }'
```

which sets the selection_bg to fully transparent, and selection_bg to
50% transparent gray.

When selection_fg is fully transparent we'll use the normal fg color.

When selection_bg is partially (or fully!) transparent, it will be
alpha blended over the current cell background color.

To support this, the config file will now accept rgba colors specified
as 4 whitespace delimited numeric values. If a value ends with `%` it
is interpreted as a number in the range 0-100.  Otherwise, it is
interpreted as a number in the range 0-255.  The 4 values are
red, green, blue, alpha.

At this time, only the selection_fg and selection_bg settings accept
alpha values.

refs: #1615
2022-02-05 15:17:22 -07:00
Wez Furlong
240026de48 refactor: move color parsing into wezerm-color-types crate
Resolves a little bit of the awkward duplication of color types
between some of the crates by factoring them a little bit better.

This is prep for allowing specifying alpha for some colors
in the config.
2022-02-05 13:59:54 -07:00
Wez Furlong
bd47979292 revise ligature render / cursor intersection
This puts to final rest #478, wherein ligatured glyphs that span
cells would render portions of the glyph with the wrong fg color,
where wrong was usually the bg color and cause the glyph to turn
invisible when cursoring through the ligature.

The approach used here is to divide the glyph into 7 discrete strips
where each strip either intersects with the cursor, the selection, or
neither. That allows us to render each strip with the appropriate
foreground color.

This change simplifies some of the logic and allows some other code
to be removed, so that feels good!

As is tradition with these renderer changes, there's a good chance that
I overlooked something in testing and that the metrics or alignment
might be slightly off for some font/text combo.  Let's see how this
goes!

refs: #784
refs: #478
refs: #1617
2022-02-05 10:49:49 -07:00
Wez Furlong
c3234b61d7 nerdfonts: re-order numerics so that 10 comes after 1 etc. 2022-02-03 09:08:39 -07:00
Wez Furlong
038938479f docs: embed nerd fonts symbols on the nerdfonts page 2022-02-03 08:19:51 -07:00
Wez Furlong
98f35bbf24 bidi: tag Line with bidi mode
This commit refines bidi property handling:

* experimental_bidi has been split into two new configuration settings;
  `bidi_enabled` (which controls whether the terminal performs implicit
  bidi processing) and `bidi_direction` which specifies the base
  direction and whether auto detection is enabled.
* The `Line` type can now store those bidi properties (they are actually
  split across 3 bits representing enabled, auto-detection and
  direction)
* The terminal now has a concept of active bidi properties and default
  bidi properties
* The default properties are pulled from the wezterm configuration
* active bidi properties are potentially set via escape sequences,
  BDSM (which sets bidi_enabled) and SCP (which sets bidi_direction).
  We don't support the 2501 temporary dec private mode suggested by
  the BIDI recommendation doc at this time.
* When creating new `Line`'s or clearing from the start of a `Line`, the
  effective bidi properties are computed (from the active props,
  falling back to default propr) and applied to the `Line`.
* When rendering the line, we now look at its bidi properties instead
  of just the global config.

The default bidi properties are `bidi_enabled: false` and
`bidi_direction: LeftToRight` which corresponds to the typical
bidi-unaware mode of most terminals.

It is possible to live reload the config to change the effective
defaults, but note that they apply, by design, to new lines being
processed through the terminal.  That means existing output is
left unaffected by a config reload, but subsequently printed lines
will respect it.  Pressing CTRL-L or otherwise contriving to have
the running application refresh its display should cause the
refreshed display to update and apply the new bidi mode.

refs: #784
2022-01-30 09:50:04 -07:00
Wez Furlong
75c80ca322 bidi: feed reordered runs through to harfbuzz
Two problems:

* Need reordered_runs method to populate ranges based on
  the reordered levels!
* Use reordered runs to get the *logical* bounds of those
  runs and pass those to harfbuzz.

Now the text is ordered correctly, but the rendering advances
by the wrong amount for the reordered clusters and looks bad
unless experimental_pixel_positioning=true.

refs: #784
2022-01-29 05:59:24 -07:00
Wez Furlong
0324ff66f0 wezterm: add experimental_bidi config option and very basic bidi
This commit is larger than it appears to due fanout from threading
through bidi parameters.  The main changes are:

* When clustering cells, add an additional phase to resolve embedding
  levels and further sub-divide a cluster based on the resolved bidi
  runs; this is where we get the direction for a run and this needs
  to be passed through to the shaper.
* When doing bidi, the forced cluster boundary hack that we use to
  de-ligature when cursoring through text needs to be disabled,
  otherwise the cursor appears to push/rotate the text in that
  cluster when moving through it! We'll need to find a different
  way to handle shading the cursor that eliminates the original
  cursor/ligature/black issue.
* In the shaper, the logic for coalescing unresolved runs for font
  fallback assumed LTR and needed to be adjusted to cluster RTL.
  That meant also computing a little index of codepoint lengths.
* Added `experimental_bidi` boolean option that defaults to false.
  When enabled, it activates the bidi processing phase in clustering
  with a strong hint that the paragraph is LTR.

This implementation is incomplete and/or wrong for a number of cases:

* The config option should probably allow specifying the paragraph
  direction hint to use by default.
* https://terminal-wg.pages.freedesktop.org/bidi/recommendation/paragraphs.html
  recommends that bidi be applied to logical lines, not physical
  lines (or really: ranges within physical lines) that we're doing
  at the moment
* The paragraph direction hint should be overridden by cell attributes
  and other escapes; see 85a6b178cf

and probably others.

However, as of this commit, if you `experimental_bidi=true` then

```
echo This is RTL -> عربي فارسی bidi
```

(that text was sourced from:
https://github.com/microsoft/terminal/issues/538#issuecomment-677017322)

then wezterm will display the text in the same order as the text
renders in Chrome for that github comment.

```
; ./target/debug/wezterm --config experimental_bidi=false ls-fonts --text "عربي فارسی ->"
LeftToRight
 0 ع    \u{639}      x_adv=8  glyph=300  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 2 ر    \u{631}      x_adv=3.78125 glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 4 ب    \u{628}      x_adv=4  glyph=244  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 6 ي    \u{64a}      x_adv=4  glyph=363  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 8      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 9 ف    \u{641}      x_adv=11 glyph=328  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
11 ا    \u{627}      x_adv=4  glyph=240  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
13 ر    \u{631}      x_adv=3.78125 glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
15 س    \u{633}      x_adv=10 glyph=278  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
17 ی    \u{6cc}      x_adv=4  glyph=664  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
19      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
20 -    \u{2d}       x_adv=8  glyph=276  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
21 >    \u{3e}       x_adv=8  glyph=338  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
```

```
; ./target/debug/wezterm --config experimental_bidi=true ls-fonts --text "عربي فارسی ->"
RightToLeft
17 ی    \u{6cc}      x_adv=9  glyph=906  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
15 س    \u{633}      x_adv=10 glyph=277  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
13 ر    \u{631}      x_adv=4.78125 glyph=272  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
11 ا    \u{627}      x_adv=4  glyph=241  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 9 ف    \u{641}      x_adv=5  glyph=329  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 8      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 6 ي    \u{64a}      x_adv=9  glyph=904  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 4 ب    \u{628}      x_adv=4  glyph=243  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 2 ر    \u{631}      x_adv=5  glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 0 ع    \u{639}      x_adv=6  glyph=301  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
LeftToRight
 0      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 1 -    \u{2d}       x_adv=8  glyph=480  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 2 >    \u{3e}       x_adv=8  glyph=470  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
;
```

refs: https://github.com/wez/wezterm/issues/784
2022-01-25 09:00:53 -07:00
Wez Furlong
7ccce20544 fonts: allow harfbuzz to guess the script
Our default meant that harfbuzz wouldn't engage preprocessing
steps that normalized the text to NFC.  With this change we now
correctly normalize and render certain compositions that were
totally borked previously.

refs: https://github.com/wez/wezterm/issues/1573
refs: https://github.com/wez/wezterm/issues/1474
2022-01-21 10:10:39 -07:00
Wez Furlong
85a6b178cf termwiz: recognize some bidi-related escape sequences
We don't do anything with these; this is just teaching
the parser how to recognize these codes.

refs: https://github.com/wez/wezterm/issues/784
2022-01-20 07:37:19 -07:00
Wez Furlong
067c376eec termwiz: fix mouse reporting on windows
We didn't enable it for VT mode enabled windows consoles!
2022-01-18 13:43:54 -07:00
Alhadis
807f483462 Fix typo in strip-ansi-escapes --help output 2022-01-18 06:18:15 -08:00
Wez Furlong
e188406dfc make semantic zones more cacheable
This commit decomposes the main get_semantic_zones method into two
parts:

* A per-line portion, where the line ranges are cached (invalidated on
  change)
* The overall screen portion, where the line ranges are merged

This changes the overall complexity of computing zones from

   O(width * scrollback-height)

To an incremental:

   O((width * number of changed lines since last query) + scrollback-height)

You can see some samples of elapsed time below; those show the times for
running both the old and the new implementation on the same data.  The
number of lines/zones in the scrollback increases with each call and you
can see that the new implementation is a bit faster anyway at low
volumes but is significantly faster as the number of lines/zones
increases, because the amount of work is reduced.

```
get_semantic_zones: 71.708µs
get_semantic_zones_new: 59.041µs
get_semantic_zones: 71.166µs
get_semantic_zones_new: 9.166µs
get_semantic_zones: 44.291µs
get_semantic_zones_new: 4.208µs
get_semantic_zones: 69.791µs
get_semantic_zones_new: 10.291µs
get_semantic_zones: 59.375µs
get_semantic_zones_new: 7.958µs
get_semantic_zones: 52.5µs
get_semantic_zones_new: 4.5µs
get_semantic_zones: 91.791µs
get_semantic_zones_new: 20.916µs
get_semantic_zones: 229.916µs
get_semantic_zones_new: 109.208µs
get_semantic_zones: 224.125µs
get_semantic_zones_new: 15.208µs
get_semantic_zones: 291.791µs
get_semantic_zones_new: 11.833µs
get_semantic_zones: 238.875µs
get_semantic_zones_new: 12.625µs
get_semantic_zones: 468.458µs
get_semantic_zones_new: 126.583µs
get_semantic_zones: 460.5µs
get_semantic_zones_new: 25.666µs
get_semantic_zones: 358.291µs
get_semantic_zones_new: 19.541µs
get_semantic_zones: 436.833µs
get_semantic_zones_new: 17.875µs
get_semantic_zones: 313.166µs
get_semantic_zones_new: 15.25µs
get_semantic_zones: 333.958µs
get_semantic_zones_new: 16.541µs
get_semantic_zones: 364.666µs
get_semantic_zones_new: 14.041µs
 ```
2022-01-17 22:00:38 -07:00
Wez Furlong
11a9d9065e handle ESK k title ST sequence used by tmux
refs: #336
2022-01-17 15:47:39 -07:00
Wez Furlong
4ebbc6688d tmux: capture initial screen contents
refs: #1090
2022-01-17 14:36:57 -07:00
Wez Furlong
e4ed2c93e2 encoding my preferred import grouping in the rustfmt config
This uses an unstable option in rustfmt, you `cargo +nightly fmt`
needs to be used to format the code correctly.
2022-01-17 13:50:51 -07:00
Wez Furlong
8f31aed3f1 move tmux-cc crate to be module inside termwiz
refs: #1090
2022-01-17 13:43:35 -07:00
Wez Furlong
db01691359 fix build
refs: #1090
2022-01-17 13:29:40 -07:00
g4c
1bdc952d9d fix log level 2022-01-17 13:08:41 -07:00
g4c
8ee5c295f7 doc and cleanup 2022-01-17 13:08:41 -07:00
g4c
3054fd045e concat tmux parser buffer and unparsed bytes 2022-01-17 13:08:41 -07:00
g4c
64d38c94c5 nicely quit tmux mode 2022-01-17 13:08:41 -07:00
g4c
a26f190c7c it worked! 2022-01-17 13:08:39 -07:00
g4c
007a0c1b27 split out tmux command process 2022-01-17 13:08:12 -07:00
g4c
f36d4c6734 parse tmux control mode events
when in tmux mode, bypass vtparse
2022-01-17 13:06:03 -07:00
Wez Furlong
54e92b6858 Add module to map nerd font symbol names to codepoints
I generated nerdfonts_data.rs with this shell script; it uses `i_all.sh`
from the nerdfonts repo to get the base mapping:

```
source ./lib/i_all.sh

echo "//! Data mapping nerd font symbol names to their char codepoints"
echo "pub const NERD_FONT_GLYPHS: &[(&str, char)] = &["
for var in "${!i@}"; do
  # trim 'i_' prefix
  glyph_name=${var#*_}
  glyph_char=${!var}
  glyph_code=$(printf "%x" "'$glyph_char'")
  echo "(\"$glyph_name\", '\u{$glyph_code}'), // $glyph_char"
done
echo "];"
```

Then intent is to use it in wezterm:

```
local wezterm = require 'wezterm'

wezterm.log_info(wezterm.nerdfonts.dev_mozilla)
```
2022-01-16 17:25:08 -07:00
Wez Furlong
475fc0667b fix termwiz compilation when widgets are enabled
refs: #1457
2022-01-12 07:14:14 -07:00
Wez Furlong
79f7f63064 deps: ordered-float -> 2.10
closes: https://github.com/wez/wezterm/pull/1524
2022-01-09 19:25:48 -07:00
Wez Furlong
4524abcdba gui: revise win32-input-mode flow
We need 100% of the info for it to work correctly, so this commit:

* Exposes the keyboard encoding mode via the Pane trait
* Adds the scan code to the RawKeyEvent
* Has the GUI perform the encoding if the keyboard is set that way
* Removes the basic encoder from termwiz in favor of the gui level one

The net result is that we bypass the Pane::key_up/Pane::key_down methods
in almost all cases when the encoding mode is set to win32-input-mode.

There is now a config option: allow_win32_input_mode that can be
used to prevent using this mode.

refs: #1509
2022-01-07 13:02:09 -07:00
Wez Furlong
72595d99d1 input: add Backspace to win32-input-mode list
refs: #1515
2022-01-06 17:47:29 -07:00
Wez Furlong
ca8362ff08 input: fix modifier only win32-input-mode reporting
Normalize the left/right to the main VK.

Fixup the left/right control modifier flags: they were flipped!

refs: https://github.com/wez/wezterm/issues/318
refs: https://github.com/wez/wezterm/issues/1509
refs: https://github.com/wez/wezterm/issues/1510
2022-01-06 10:55:52 -07:00
Wez Furlong
ce23ee9eb8 input: generate win32-input-mode for a subset of keys
This commit causes the terminal to emit win32-input-mode encoded key up
and down events for a limited subset of keys When win32-input-mode is
enabled.

We limit them to keys where we know the VK key code equivalent,
and where those keys are either not representable (eg: modifier
only key events), or may generate ambiguous output (eg: CTRL-SPACE
in different keyboard layouts).

However, in my experiments, modifier only key presses confuse powershell
and cause it to emit `@`, so I've disabled that in the code for now.

refs: https://github.com/wez/wezterm/issues/318
refs: https://github.com/wez/wezterm/issues/1509
refs: https://github.com/wez/wezterm/issues/1510
2022-01-06 10:19:58 -07:00
Wez Furlong
51aec27ec2 termwiz/term: introduce KeyboardEncoding enum, existence of win32-input-mode
This is a baby step that formalizes the different encoding schemes into
an enum, and hooks up the decset sequence for win32-input-mode.

It doesn't change any of the actual encoding at this time.

refs: #1509
2022-01-06 07:50:49 -07:00
Wez Furlong
41ce7903a9 write -> write_all, h/t clippy via @CGMossa 2022-01-05 18:52:14 -07:00
Wez Furlong
b05cb1241e force clusters to break around cursor boundary
When rendering the IME composing text, I noticed that for the Korean
input sequence: shift+'ㅅ' followed by 'ㅏ' we'd render the 'ㅆ' (the
shifted first character) in black and the composing 'ㅏ' in white
against the cursor color, and that was very difficult to read,
especially at the default font size.

To resolve this, this commit:

* Forces clustering to break around the cursor boundary, so that
  we treat the cursor position as its own separately styled cluster
* Adjusts cursor/bg rendering so that we always consider the start of
  the cluster for the colors of that run.  We are guaranteed that a
  ligatured sequence will fit in the background area anyway.

This has the effect of "breaking" programming ligatures such as '->'
when cursoring through them, and decomposing them into their individual
'-' and '>' glyphs, which is a reasonable price to pay for being able
to see things better on screen.

refs: https://github.com/wez/wezterm/issues/1504
refs: https://github.com/wez/wezterm/issues/478
2022-01-05 09:20:11 -07:00
Autumn Lamonte
07a2acb840 #1457 refactor, ClickPosition 2022-01-04 19:49:06 -08:00
Autumn Lamonte
81f4bbd4aa #1457 Initial commit compiles but doesn't yet work 2022-01-04 19:49:06 -08:00
Wez Furlong
d11bc4a5bb termwiz: sync with upstream wichdechar_width
refs: https://github.com/ridiculousfish/widecharwidth/issues/16
refs: https://github.com/ridiculousfish/widecharwidth/pull/17
closes: https://github.com/wez/wezterm/issues/1469
2022-01-01 08:18:41 -07:00
Wez Furlong
c68b55ba4f termwiz: clamp grapheme column width to 2
This isn't ideal, but it addresses a couple of issues:

* wezterm currently has a debug assertion that this is true
* Korean text in NFD is currently recognized as having a width of 3
  when it should be 2 due to upstream issue
  https://github.com/ridiculousfish/widecharwidth/issues/16
* NFD and NFC should render the same for the sample text in
  https://github.com/wez/wezterm/issues/1474 but don't as a result

Clamping to 2 "solves" these, at the cost of potentially other
weird stuff in the future.  It seems like a reasonable tweak
for the time being!

refs: https://github.com/wez/wezterm/issues/1469
refs: https://github.com/wez/wezterm/issues/1474
refs: https://github.com/ridiculousfish/widecharwidth/issues/16
2021-12-29 21:38:33 -07:00
Wez Furlong
5608e9477b termwiz: make seqno a required param for Line
Previously, we would implicitly set it to the special SEQ_ZERO
value, but since that value always flags the row as changed,
it causes some over-invalidation issues downstream in wezterm.

This commit makes that parameter required, so that the code that
is creating a new Line always passes down the seqno from that event.

refs: #1472
2021-12-29 08:34:59 -07:00
Wez Furlong
88b8cb3e21 term: fix overinvalidation of selection on Windows
Not 100% sure why this only really manifested on Windows, but
the symptoms were:

* Run powershell in a tab
* Run `dir`
* Hit enter a couple of times to show a couple of prompts
* Try using the mouse to select across the prompt boundaries

The selection would get invalidated crossing the boundaries.
I traced this down to the lines around those regions having
SEQ_ZERO as their sequence, so this commit ensures that lines
that are created as part of scrolling the screen are correctly
tagged with the current seqno from the terminal display.

Why only windows? Not totally sure; perhaps it is related to
something funky happening in the conpty layer and sending us
unusual escapes (eg: scroll margins?)
2021-12-24 08:53:49 -07:00
Autumn Lamonte
0a93a58605 New optional argument 'doNotMoveCursor' for iTerm2 images. This
permits iTerm2 images to be drawn anywhere on screen without
scrolling the cursor, including the bottom row.

Also included is a check in fcwrap.rs to_range_set(), without which
was causing a panic at runtime due to subtraction from unsigned
leading to overflow.
2021-12-23 07:07:08 -08:00
Wez Furlong
294579fd31 term: introduce right&bottom padding to ImageCell
This helps us correctly set the size of the image cell
for the case where we have a partial cell at the right/bottom
edge of an image being mapped across cells.

refs: #1270
2021-12-23 07:26:49 -07:00
Wez Furlong
872935f656 termwiz: publish 0.15 2021-12-22 13:02:31 -07:00
Wez Furlong
89d25ccdb6 termwiz: Windows: force CP_UTF8, fix alt-screen and examples
We need to force the codepage to UTF8 this to avoid having our UTF-8
bytestreams be misinterpreted, and to restore the original before we're
done.

refs: https://github.com/wez/wezterm/issues/1435

implement missing alt-screen support and fixup building the examples
while we're in here.

refs: #1244
2021-12-22 12:54:57 -07:00
Wez Furlong
b40f65c25e termwiz: s/Fuschia/Fuchsia/g
closes: #1407
2021-12-21 20:38:59 -07:00
Wez Furlong
f9366ad962 termwiz: allow arbitrary whitespace between hsl color components
refs: #1436
2021-12-21 14:52:37 -07:00
Wez Furlong
1203dff277 termwiz: fix 10bpc color bug. Allow hsl color specs
This commit teaches `RgbColor::from_rgb_str` to support
colors in the form `hsl:235 100 50`, an HSL colorspace
color specification.

While banging my head on why my test wasn't passing, I realized
that this was producing 10 bpc color and the code to convert
those to RGB was incorrectly multiplying conversion terms!

refs: https://github.com/wez/wezterm/issues/1436
2021-12-20 10:17:52 -07:00
Luis Javier Merino Morán
15f9d9b695 Support empty first param for CUP, HVP, SLRM, STBM
From esctest:
CUPTests.test_CUP_ColumnOnly
HVPTests.test_HVP_ColumnOnly

and the newly added at https://invent.kde.org/ninjalj/esctest.git:
DECSETTests.test_DECSET_DECLRMM_OnlyRight
DECSTBMTests.test_DECSTBM_OnlyBottom
2021-12-08 07:26:48 -08:00
Wez Furlong
9589c7a647 Respect emoji-variation-sequences.txt
Not all codepoints are valid when combined with a presentation
selector.

This commit ensures that we respect the valid sequences defined
by the current version of unicode (version 14).

refs: #1231
refs: #997
2021-11-25 14:37:24 -07:00
Wez Furlong
d69df605cd Add escape sequence to control unicode version
As promised in the previous commit, this one implements an escape
sequence to control the unicode version.

Unknown to me in the previous commit, iTerm2 already defines such
an escape sequence, so we simply implement it here with the same
semantics.

refs: #1231
refs: #997
2021-11-25 12:12:52 -07:00
Wez Furlong
225e7a1243 introduce unicode_version config
This is a fairly far-reaching commit. The idea is:

* Introduce a unicode_version config that specifies the default level
  of unicode conformance for each newly created Terminal (each Pane)
* The unicode_version is passed down to the `grapheme_column_width`
  function which interprets the width based on the version
* `Cell` records the width so that later calculations don't need to
  know the unicode version

In a subsequent diff, I will introduce an escape sequence that allows
setting/pushing/popping the unicode version so that it can be overridden
via eg: a shell alias prior to launching an application that uses a
different version of unicode from the default.

This approach allows output from multiple applications with differing
understanding of unicode to coexist on the same screen a little more
sanely.

Note that the default `unicode_version` is set to 9, which means that
emoji presentation selectors are now by-default ignored.  This was
selected to better match the level of support in widely deployed
applications.

I expect to raise that default version in the future.

Also worth noting: there are a number of callers of
`unicode_column_width` in things like overlays and lua helper functions
that pass `None` for the unicode version: these will assume the latest
known-to-wezterm/termwiz version of unicode to be desired. If those
overlays do things with emoji presentation selectors, then there may be
some alignment artifacts. That can be tackled in a follow up commit.

refs: #1231
refs: #997
2021-11-25 09:00:45 -07:00
Wez Furlong
591e1f593c termwiz: import widechar_width wcwidth implementation
This commit adopts the use of https://github.com/ridiculousfish/widecharwidth/
to determine the width of a character.

This allows removing a couple of other rust deps that are no longer
needed, but doesn't otherwise change the behavior.

refs: https://github.com/wez/wezterm/issues/1231
2021-11-24 18:11:59 -07:00
Wez Furlong
f56a6aa276 termwiz: allow degenerate empty parameter in iTerm2 protocol
The `bv` utility emits this slightly wonky sequence; since iTerm2 allows
it, we should also allow it.

refs: #1291
2021-11-05 08:08:03 -07:00
Wez Furlong
962e44bbfb WIP: fancier tab bar
`use_fancy_tab_bar` switches to an alternate rendering of the tab
bar that uses the window_frame config to get a proportional
title font to use to render tabs, as well as rendering a few
additional elements to space out and make the tabs feel more
like tabs.

Computing the number of tabs doesn't respect the alternate font
at this time.

Formatted tab item foreground and background colors are also
not respected at this time.

refs: #1180
2021-10-04 17:35:54 -07:00
Paul Laborderie
2820b2c35a Remove unused Error import 2021-09-29 20:58:47 -07:00
Wez Furlong
0ee1f7529b fonts: Fix shaping metrics
This was a bit of a PITA to run down; the essence of the problem
was that the shaper was returning an x_advance of 0 for U+3000,
which caused wezterm's shaping layer to elide that glyph.

I eventually tracked down the x_advance to be the result of
scaling by an x_scale of 0, which in turn is the result of
harfbuzz not knowing the font size.

The critical portion of this diff is the line that advises
harfbuzz that the font has changed after we've applied the
font size.

The rest is just stuff to make it easier to debug and verify.

This:

```
printf "x\u3000x."
```

Now correctly renders on screen as "x  x".

fixes: #1161
2021-09-22 08:34:40 -07:00
Wez Furlong
0e5d0d8117 term: fix encoding F1-F4
This was accidentally broken by 8da1f676a8

refs: #892
2021-09-12 09:30:14 -07:00
Wez Furlong
545a8fc8a7 deps: ordered-float -> 2.8 2021-09-05 23:25:37 -07:00
Wez Furlong
311bd78902 Fix SU (scroll up) using default-blank cells
closes: https://github.com/wez/wezterm/issues/1102#
2021-09-04 17:35:33 -07:00
Wez Furlong
dc1996ac67 fixup terminfo for underline color
I noticed while reviewing the session recording for https://github.com/wez/wezterm/issues/1102
that wezterm reported:

```
2021-09-04T22:05:46.136Z WARN  wezterm_term::terminalstate::performer > unknown unspecified CSI: "58::2::87::61::38m"
2021-09-04T22:05:46.138Z WARN  wezterm_term::terminalstate::performer > unknown unspecified CSI: "58::2::87::61::38m"
```

Those extra double-colons aren't valid, and I think they're coming from
this terminfo file, so fix it up!
2021-09-04 15:52:20 -07:00
Wez Furlong
67e8bdc5c2 term: fix DCH removing cells instead of setting to current bg color
refs: #789
2021-09-03 16:21:15 -07:00
Wez Furlong
8da1f676a8 ALT+ "function" keys incorrectly sent ESC prefixed sequences
closes: #892
2021-09-03 11:35:01 -07:00
Wez Furlong
c5d1f67853 term/termwiz: move key encoding to termwiz
This will enable eg: a lua helper function to serialize keycodes to
assist in some key rebinding scenarios (see:
https://github.com/wez/wezterm/pull/1091#issuecomment-910940833 for the
gist of it) but also makes it a bit easier to write unit tests for key
encoding so that situations like those in #892 are potentially less
likely to occur in the future.
2021-09-03 11:12:42 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
d59898987a gui: fix lost sync with the cell position in the renderer
If a cell contained a ligature, the math used to track where the
next quad was going to be placed could lose consistency with
the cluster/shaping information and result in offset glyphs.

This was most noticeable to me in tab titles in the tab bar;
my shell dotfiles append `-- something` to the title when a
command is launched, and the `--` is a ligature in my font.

I think I've also seen this mess up positioning in the notcurses
demo as well.

The solution is to take the cluster initial cell index rather
than trying to reverse engineer it from incomplete info.
2021-08-13 09:34:36 -07:00
Wez Furlong
6f78ee4f14 deps: update unicode-segmentation to 1.8 2021-08-11 23:06:17 -07:00
Wez Furlong
6c2f9f2d18 term: restore line length pre-allocation
A while back I made the line lengths lazily grown; the reduction
in memory was nice, and it helped with render performance for
really wide screens.

Unfortunately, it puts a bunch of reallocation into the hot path
of the parser and updating the terminal model when people run
the inevitable `cat giant-file.txt` benchmark.

This commit reinstates pre-allocating lines to match the physical
terminal width, and tweaks the code a bit to take advantage of
const Cell allocation and to avoid some clones (a really micro
optimization).
2021-08-11 23:06:17 -07:00
Wez Furlong
c90ccec102 micro-optimize TeenyString and cell width
For simple graphemes, we can avoid subsequently calling
grapheme_column_width and cache that information in TeenyString.

Make blank TeenyString and Cell initializations const.
2021-08-11 23:06:17 -07:00
Wez Furlong
60786dd74d termwiz: fix off-by-one in computing line length
We were over-allocating 1 extra cell in the end-of-line case
2021-08-11 23:06:17 -07:00
Wez Furlong
d51f5f7670 termwiz: improve performance of emoji presentation lookup 2021-08-11 23:06:16 -07:00
Wez Furlong
3c5916d760 termwiz: fix test build when image feature is disabled 2021-08-08 16:43:10 -07:00
Wez Furlong
4427ca3a1c wezterm.terminfo: update to include more tmux extensions
refs: #999
2021-08-08 16:41:14 -07:00
Wez Furlong
eae327efcc model: replace LineBits::DIRTY with a sequence number
Terminal now maintains a sequence number that increments
for each Action that is applied to it.

Changes to lines are tagged with the current sequence number.

This makes it a bit easier to reason about when an individual
line has changed relative to some point in "time"; the consumer
of the terminal can sample the current sequence number and then
can later determine which lines have changed since that point
in time.

refs: https://github.com/wez/wezterm/issues/867
2021-08-08 12:45:08 -07:00
Wez Furlong
0158e8e49a gui: fixup window transparency 2021-08-06 13:07:50 -07:00
Wez Furlong
6a7e6596b9 kitty img: make allowances for permanence of image attachments
An implementation detail in wezterm is that it doesn't model
image placements as a separate entity; they are all bound to
the image cells in the terminal model.

The semantics of the kitty image protocol are that placements
are "permanent" wrt. overwriting a cell with text, except for
the explicit EraseInLine/EraseInDisplay sequences that are
used for clearing.

This commit takes a pass at implementing that semantic in
the wezterm data model.

refs: #986
2021-08-06 09:01:18 -07:00
Wez Furlong
9d8f9c7c5a termwiz: break clusters when presentation varies
This should give the shaper a better chance at using text
presentation in a run that mixes emoji with text and/or
uses presentation selectors.

It also exposes the presentation property to the shaper
so that it could potentially adjust its fallback strategy.
However, it doesn't do that here.

refs: https://github.com/wez/wezterm/issues/997
2021-08-04 22:42:43 -07:00
Wez Furlong
28e8b5ff2f termwiz: better fidelity Emoji_Presentation logic
Make a distinction between default and selected presentation,
and account for that in the cell width.

Add a method to the cell that returns the effective presentation.

refs: https://github.com/wez/wezterm/issues/997
2021-08-04 22:36:17 -07:00
Wez Furlong
b6c6cef876 refactor: move cursor sprite generation to be dynamic
This allocates cursor sprites as needed, and uses the Poly drawing
code from the customglyph module to do it.
2021-08-04 10:01:21 -07:00
Wez Furlong
02b5defac1 kitty img: parse and implement basic anim frame composition
This is just enough for notcurses-demo to run, and is definitely
missing various cases.

refs: #986
2021-08-03 21:57:27 -07:00
Wez Furlong
76b72e4be4 improve handling of VS15 and VS16
These modifiers have the effect of forcing us to consider the grapheme
as being either a single cell (VS15) or two cells (VS16) in the
terminal model.

These don't affect font choice as wezterm doesn't know whether a given
font in the fallback has a textual vs. an emoji version of a given
glyph, or whether a later font in the fallback has one or the other
because we can't know until we fall back, and that has a very high
cost--we perform fallback asynchronously in another thread because
of its high cost.

Depending on the selected glyph, it may or may not render as double
wide.

refs: #997
2021-08-03 12:17:03 -07:00
Wez Furlong
07bea8c269 gui: change image frame caching scheme to use frame hash
Since we can now mutate individual frames, we need to avoid
falsely caching across a change; switch from using (image_id, frame_idx)
to frame_hash.

refs: #986
2021-08-03 08:42:39 -07:00
Wez Furlong
e85e94248b basic kitty img animation support
this is the bare minimum to squeak by with notcurses; it currently
only supports editing single frame images.

refs: #986
2021-08-02 21:35:57 -07:00
Wez Furlong
29a64e10b8 allow locking ImageData's ImageDataType for mutation
refs: #986
2021-08-02 21:35:57 -07:00
Wez Furlong
90b16b9518 move image decoding into termwiz
Adds a use_image feature to termwiz that enables an optional
dep on the image crate.  This in turn allows decoding of animation
formats (gif, apng) from file data, but more crucially, allows
modeling animation frames at the termwiz layer, which is a pre-req
for enabling kitty img protocol animation support.

refs: #986
2021-08-02 21:35:50 -07:00
Wez Furlong
b862c8d111 termwiz: add ImageData::hash
Moves the localized hashing logic from term -> termwiz
where it can be re-used.

refs: #986
2021-08-02 09:18:25 -07:00
Wez Furlong
7f9d96328c kitty img: parser support for animation frame transmission
refs: #986
2021-08-01 23:33:27 -07:00
Wez Furlong
94d409d340 prefer to hold rgba8 rather than png data for kitty, sixel
I noticed when running the notcurses demo that we're spending a
decent amount of time decoding png data whenever we need to
re-do the texture atlas.

Let's avoid that by allowing for ImageData at the termwiz layer
to represent both the image file format and decoded rgba8 data.

This commit is a bit muddy and also includes some stuff to try
to delete placements from the model.  It's not perfect by any
means--more expensive than I want, and there's something funky
that causes a large number of images to build up during some
phases of the demo.

refs: #986
2021-08-01 11:29:50 -07:00
Wez Furlong
ff3ba4c4ec parse and respond to kitty img protocol queries
refs: #986
refs: https://github.com/dankamongmen/notcurses/issues/1998
2021-07-31 17:32:40 -07:00
Wez Furlong
bbe019db96 implement kitty image source and offset options for placement
Allows selecting a source "sprite" from the image data, and offsetting
its position within the cell.

refs: #986
2021-07-31 14:03:27 -07:00
Wez Furlong
71e88a4fea conceptually allow for multiple image attachments in a cell
refs: #986
2021-07-29 19:41:52 -07:00
Wez Furlong
62cc64f293 incomplete, basic implementation of kitty image protocol
This isn't complete; many of the placement options are not supported,
and the status reporting is missing in a number of cases, including
querying/probing, and shared memory objects are not supported yet.

However, this commit is sufficient to allow the kitty-png.py script
(that was copied from
https://sw.kovidgoyal.net/kitty/graphics-protocol/#a-minimal-example)
to render a PNG in the terminal.

This implementation routes the basic image display via the same
code that we use for iterm2 and sixel protocols, but it isn't
sufficient to support the rest of the placement options allowed
by the spec.

Notably, we'll need to add the concept of image placements to
the data model maintained by the terminal state and find a way
to efficiently manage placements both by id and by a viewport
range.

The renderer will need to manage separate quads for placements
and order them by z-index, and adjust the render phases so that
images can appear in the correct plane.

refs: #986
2021-07-28 09:04:52 -07:00
Wez Furlong
f0996a5dc5 termwiz: add KittyImageData::load_data
refs: #986
2021-07-28 09:04:45 -07:00
Wez Furlong
7b0b042683 termwiz: parse and encode kitty image protocol
This teaches termwiz to recognize and encode the APC
sequences used by the kitty image protocol.

This doesn't include support for animations, just the
transmit, placement and delete requests.

refs: #986
2021-07-28 09:04:37 -07:00
Wez Furlong
de1298f8b2 vtparse: parse APC sequences
These were parsed but swallowed. This commit expands the transitions
to be able to track the APC start, data and end and then adds
an `apc_dispatch` method to allow capturing APC sequences.

APC sequences are used in the kitty image protocol.

refs: #986
2021-07-28 09:04:28 -07:00
Wez Furlong
aca13c6977 termwiz: fixup regression in sgr parsing for empty parameter case
I broke this with my recent csi parser changes.
2021-07-25 08:20:36 -07:00
Autumn Lamonte
e3f1d15f5d #133 unit tests 2021-07-24 23:43:30 -07:00
Autumn Lamonte
d100dded23 #133 cleanup + terminalstate-level reverse video mode 2021-07-24 23:36:49 -07:00
Autumn Lamonte
70544b7b26 #133 cleanup, rapid blinking text 2021-07-24 23:35:06 -07:00
Autumn Lamonte
c19f330194 #133 parse out double-width/double-height, but do not render 2021-07-24 23:20:06 -07:00
Autumn Lamonte
d2e2c5dec6 #133 clean up DECREQTPARM 2021-07-24 23:19:51 -07:00
Autumn Lamonte
ad30664361 #133 Screen.reverse_video_mode + fmt fixes 2021-07-24 23:13:40 -07:00
Autumn Lamonte
31aff81884 #133 DECREQTPARM - needs cleanup 2021-07-24 23:10:52 -07:00
Autumn Lamonte
d3b0881ded #133 Tab stops, reverse video. 2021-07-24 23:07:20 -07:00
Wez Furlong
6ddc8afc64 termwiz: recognize the XTGETTCAP DCS sequence
Parse and respond to this sequence docs can be found
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Device-Control-functions:DCS-plus-q-Pt-ST.F95

refs: https://github.com/wez/wezterm/issues/954
2021-07-24 21:06:48 -07:00
Wez Furlong
365a68dfb8 Wrap up synchronized output handling, parser changes
This commit hooks up DECRQM so that we can report that we implement
synchronized updates, and then refines the code that manages sending
data to the terminal model; the first cut at synchronized updates
was a bit simplistic, and now we make a point of "flushing" pending
actions when we start a sync point, and again as soon as we release
the sync point.

This smooths out the jaggies around the orca that I mentioned in
dcbbda7702

and while testing this, I realized that recent parser changes had
mangled processing bundled dec private mode sequences where multiple
modes were specified in the same overall escape sequence.  I've
added the missing unit test case for this and made that work again.

refs: https://github.com/wez/wezterm/issues/955
refs: https://github.com/wez/wezterm/issues/882
2021-07-24 17:01:21 -07:00
Wez Furlong
a249021920 vtparse: simplify csi dispatch
This commit removes the intermediates parameter and collapses it
together with the parameters themselves.

This allows us to model DECSET (eg: `CSI ? 1 l`) correctly.
Previously this would get reported as:

```
  params: [1],
  intermediates: ['?'],
  code: 'l'
```

but since the intermediates are logically things that precede the code,
the canonical interpretation of that would be as if we'd received
`CSI 1 ? l`.

AFAICT, DECSET isn't conforming to ECMA 48 when it comes to this
sequence.

That made things a bit of a headache in the CSI parser, so what we do
now is to treat intermediates as parameters so that it is much simpler
to reason about and match in the CSI parser; we now get:

```
  params: ['?', 1],
  code: 'l',
```

refs: https://github.com/wez/wezterm/issues/955
2021-07-24 12:44:49 -07:00
Wez Furlong
86c1d50b4a WIP: improve CSI parsing fidelity
The original design of the vtparse crate was inspired by the vte
crate.  There were some assumptions about the shape of CSI sequences
that were lossy and that is posing a problem when it comes to
implementing DECRQM.

This commit improves the situation by adjusting CsiParam to be capable
of capturing all of the possible parameters as well as intermediates.

This commit isn't done; I just need to push it to transfer it to another
machine.

refs: https://github.com/wez/wezterm/issues/882
refs: https://github.com/wez/wezterm/issues/955
2021-07-24 08:34:36 -07:00
Wez Furlong
c6dc677e50 preliminary support for synchronized output
This implementation doesn't include a timeout, but should be
recoverable via a SoftReset.

There's no query response either: I think I'm missing DECRQM
entirely at the moment.

refs: https://github.com/wez/wezterm/issues/882
2021-07-24 08:34:36 -07:00
Wez Furlong
092effba04 fix background color cloning
4e99edf6f5 split the color into
thin/fat components, but overlooked copying the optional fat
part of the color.

That in turn broke sequences like:

* Set background color
* Erase to end of line

This commit teaches the sgr attribute cloning function to look
at the optional fat component.

refs: #962
2021-07-21 07:56:36 -07:00
Wez Furlong
a2e882a7cb deps: cargo update, and a couple of dependabot suggestions 2021-07-18 19:10:46 -07:00
nick black
9355da958a implement DA3 tertiary deviceattr
Add the third device attributes (DA3) query+reply,
eliminating "unknown/unspecified CSI" error. Like
XTerm, simply reply with zeroes as opposed to site
codes or unique IDs.
https://vt100.net/docs/vt510-rm/DA3.html
2021-07-17 20:47:41 -07:00
nick black
d337677b8e
[terminfo] add smxx/rmxx, purge blink (#905)
* [terminfo] add smxx/rmxx, purge blink

Testing with WezTerm nightly indicates no blink support
available through the xterm \E[5m, and I didn't see any
support in the code -- purge it. smxx and rmxx, meanwhile,
have been added to indicate support for struck text.

* restore blink

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2021-07-11 21:36:56 -07:00
Wez Furlong
cc2b9507f8 fixup build on windows 2021-07-10 17:52:14 -07:00
Wez Furlong
4e99edf6f5 CellAttributes: split color into thin/fat components
The common palette indices are in the main cell attributes.
Using true color will allocate fat storage.

This allows reducing the Cell size from 32 -> 24 across the
implementation of storing 10 bpc color (it peaked at 40 in
the last couple of commits).
2021-07-10 15:42:15 -07:00
Wez Furlong
47839adf95 CellAttribute: move fg/bg color accesses to accesors
This facilitates hiding the raw fields in the next diff
2021-07-10 15:15:36 -07:00
Wez Furlong
1a673a5e5b RgbColor: store 10bpc
This makes Cell larger; will compensate in following diff
2021-07-10 15:06:32 -07:00
Wez Furlong
9c77d56026 RgbColor: hide internal red, green, blue fields
I'd like to adjust this to support 10bpc color, so the first step
is hiding the individual 8bpc fields.
2021-07-10 14:22:31 -07:00
Autumn Lamonte
39535bbd77 #891 Fix tests 2021-06-20 08:29:31 -07:00
Autumn Lamonte
ab1cad0cbf #891 VT100 character set support 2021-06-20 08:29:31 -07:00
Wez Furlong
ccd66c01a9 sixel: respect Dec Private Mode 8452
This adjusts the cursor position after emitting a sixel.

@dankamongmen: I don't have much of a sixel test suite to speak
of (cat snake.six :-p); I'd appreciate it if you could run
notcurses against this and confirm that it is doing something
sane!

At the very least, we shouldn't be warning about the unhandled
mode any more!

refs: https://github.com/wez/wezterm/issues/863
refs: https://github.com/dankamongmen/notcurses/issues/1743
2021-06-19 21:07:44 -07:00
Wez Furlong
d317f0f312 Don't abort for overlay large sixel payloads
Rust hasn't stabilized fallible allocation, so when we are presented
with an implausibly large sixel, Rust terminates the program; it's not
even a panick that we could potentially catch -> direct to termination.

This commit introduces an arbitrary constraint so that we can
avoid unconditionally terminating for this bad input case.

Thanks to @klamonte for sharing this test case!
2021-06-19 13:01:17 -07:00
Wez Furlong
8ca0024bfb termwiz: erase_cell could panic if erasing beyond EOL
A relatively recent commit made it possible for the cell storage
to be smaller than the viewport width.

Avoid panicking when erasing beyond the end of the cell storage.
We can simply NOP as that cell is already implictly erased.

closes: #847
2021-06-16 08:35:09 -07:00
Wez Furlong
d1d7def1a1 termwiz: avoid file io when terminfo db is pre-filled
ProbeHints would unconditionally load the terminfo based on $TERM
whever it was created, even if the caller had a pre-supplied
terminfo buffer.

Defer loading that until the caps instance is created.

refs: #817
2021-06-13 09:06:22 -07:00