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

439 Commits

Author SHA1 Message Date
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