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

263 Commits

Author SHA1 Message Date
Wez Furlong
7cf68365a5 deps: misc updates 2020-12-29 09:24:34 -08:00
Wez Furlong
7cbbb49ab4 deps: ordered-float -> 2.0 2020-12-28 08:25:43 -08:00
Wez Furlong
428b2a7f19 sixel: allow optional width and height specifier
`gosr` omits these fields:
https://github.com/mattn/go-sixel/blob/master/sixel.go#L66

We don't strictly need them; they just make the rest of the
image decode more efficient.

This also fixes `longcat` by the same author.

See also: https://twitter.com/yoichi22/status/1326294574042501122

cc: @yoichi
2020-12-11 20:27:08 -08:00
Wez Furlong
98f289f511 wezterm-font: improve fallback font scaling
Use the scaling factor between the font metrics for the base font
and those of the fallback font selected for a given glyph.

The scenario is this: the base font is typically the first one selected
from the font configuration.  There may be multiple fallback fonts that
are different sizes; for instance, the Font Awesome font has glyphs that
are square in aspect and are thus about twice the width of a typical
textual monospace font.  Similarly, Noto Color Emoji is another square
font but that has a single set of bitmap strikes at a fixed 128 px
square.

The shaper returns advance metrics in the scale of the containing font,
and the rasterizer will target the supplied size and dpi.

We need to scale these to match the base metrics.

Previously we used a crude heuristic to decide whether to scale,
and that happened to work for Noto Color Emoji but not for Font Awesome,
whose metrics were just inside the bounds of the heuristic.

This commit allows retrieving the metrics for a given font_idx so
that we can compute the correct scale factor without any heuristics,
and applies that to the rasterized glyph.

refs: https://github.com/wez/wezterm/issues/342
2020-11-23 16:59:30 -08:00
Wez Furlong
a063d20cf0 wezterm: improve shaping of emoji
This is one of those massive time sinks that I almost regret...
As part of recent changes to dust-off the allsorts shaper, I noticed
that the harfbuzz shaper wasn't shaping as well as the allsorts one.

This commit:

* Adds emoji-test.txt, a text file you can `cat` to see how well
  the emoji are shaped and rendered.

* Fixes (or at least, improves) the column width calculation for
  combining sequences such as "deaf man" which was previously calculated
  at 3 cells in width when it should have just been 2 cells wide, which
  resulted in a weird "prismatic" effect during rendering where the
  glyph would be rendered with an extra RHS portion of the glyph across
  3 cells.

* Improved/simplified the clustering logic used to compute fallbacks.
  Previously we could end up with some wonky/disjoint sequence of
  undefined glyphs which wouldn't be successfully resolved from a
  fallback font.  We now make a better effort to consolidate runs of
  undefined glyphs for fallback.

* For sequences such as "woman with veil: dark skin tone" that occupy a
  single cell, the shaper may return 3 clusters with 3 glyphs in the
  case that the font doesn't fully support this grapheme.  At render
  time we'd just take the last glyph from that sequence and render it,
  resulting in eg: a female symbol in this particular case.  It is
  generally a bit more useful to show the first glyph in the sequence
  (eg: person with veil) rather than the gender or skin tone, so the
  renderer now checks for this kind of overlapping sequence and renders
  only the first glyph from the sequence.
2020-11-23 13:45:38 -08:00
Wez Furlong
a498aa56af termwiz: deallocate "fat" attrs if all are none
Noticed this while looking at another issue
2020-11-20 12:37:38 -08:00
Wez Furlong
18e010f1df deps: normalize the lazy-static version 2020-11-13 08:15:35 -08:00
Wez Furlong
04218bb877 termwiz: fixup sixel width calculation
@yoichi reports that:

```bash
printf "\x1bPqh"
```

would panic wezterm; the issue was that the maximum x value was
only being updated for newlines and that sequence didn't include it.

refs: #217
2020-11-12 10:01:33 -08:00
Wez Furlong
37a3f7db5f wezterm: add ScrollToPrompt key assignment
Adds some supporting methods for computing the `SemanticZone`s
in the display and a key assignment that allows scrolling the
viewport to jump to the next/prev Prompt zone.
2020-11-08 09:58:02 -08:00
Wez Furlong
3d0107cb75 term/termwiz: add Cell::semantic_type
This commit allows the terminal to tag cells with their semantic
type, as defined by OSC 133 escape sequences.

The gist of it is that each cell is now semantically one of:

* Output (eg: from the activity performed by the user. This is the
  default)
* Input (eg: something that the user typed as input)
* Prompt (eg: "uninteresting" chrome/UI from the shell)

The semantic type is applied almost exactly like an SGR attribute,
except that resetting SGR doesn't clear the semantic type.

Tagging the cells in this way allows for smarter UX in the future;
for example, selecting the entire input or output from the last
command without fiddling around to avoid the prompt line(s),
or "paging up" to a prior prompt rather than page.

This doc covers those escapes as used in domterm, iterm2 and other
terminals:
https://gitlab.freedesktop.org/Per_Bothner/specifications/blob/master/proposals/semantic-prompts.md

This is an example of how to configure the shell to emit these
sequences; I'll add a proper little blob of shell specifically
for wezterm in a later commit:
https://github.com/PerBothner/DomTerm/blob/master/tools/shell-integration.zsh
2020-11-07 11:54:22 -08:00
Wez Furlong
d896fa02b0 termwiz: add OSC 133 Semantic Marker sequences
These are proposed in a spec here:
https://gitlab.freedesktop.org/Per_Bothner/specifications/blob/master/proposals/semantic-prompts.md

but are also used by iTerm2 in its shell integration here:
https://iterm2.com/documentation-shell-integration.html

This commit just teaches termwiz how to encode/decode the
OSC sequences.
2020-11-07 11:54:22 -08:00
Wez Furlong
b860c9dbda termwiz: avoid panic for some malformed escapes 2020-11-06 13:59:04 -08:00
Jun Wu
ebd4f4aa06 lineedit: add a way to render previews
Make it possible to implement rendering previews in new lines, seen in
nodejs [1]. The preview is cleared when the line is accepted (Enter)
or canceled (Ctrl+C).

[1]: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#repl-previews
2020-10-29 08:56:30 -07:00
Wez Furlong
2bac3a90bc properly implement 0ec79a40f6
Properly pull out the legacy OSC code.
Thanks tests!
2020-10-16 13:58:55 -07:00
Wez Furlong
0ec79a40f6 avoid panic if someone cats a PNG to the terminal 2020-10-16 13:09:50 -07:00
Wez Furlong
06cd143dd5 termwiz: fixup windows tests after b3f51e8ee2 2020-10-11 17:44:38 -07:00
Wez Furlong
b3f51e8ee2 termwiz: save 8 bytes per Cell in common case
Moved the image and hyperlink portion of CellAttributes out
to a separate heap structure, saving 8 bytes per Cell
for the common case of no hyperlink and no image.
2020-10-11 13:32:53 -07:00
Wez Furlong
2a87c1dec7 Change cell api to avoid direct access to hyperlink/image
This allows potentially changing the struct layout
to reduce the struct size.
2020-10-11 13:12:46 -07:00
Wez Furlong
96c4750a30 termwiz: reduce Cell memory consumption by 24 bytes
Replaces SmallVec with an internal TeenyString that only
occupies a single machine word and avoids heap allocation
in the common case on most architectures.  This takes the
textual portion of Cell from 32 bytes to 8 bytes.
2020-10-11 13:08:57 -07:00
Wez Furlong
7e232ae1af termwiz: add a test to assert size of cell structs
`cargo test -p termwiz`

(fixup color.rs test to run when serde feature is disabled)
2020-10-11 12:40:07 -07:00
Wez Furlong
3aed1b1327 termwiz: fix bounds checking in Line::compute_double_click_range
closes: https://github.com/wez/wezterm/issues/283
2020-09-27 12:38:58 -07:00
Wez Furlong
121c090f22 wezterm: implement leader key binding support
This commit introduces a new `leader` configuration setting
that acts as a modal modifier key.

If leader is specified then pressing that key combination
will enable a virtual LEADER modifier.

While LEADER is active, only defined key assignments that include
LEADER in the `mods` mask will be recognized.  Other keypresses
will be swallowed and NOT passed through to the terminal.

LEADER stays active until a keypress is registered (whether it
matches a key binding or not), or until it has been active for
the duration specified by `timeout_milliseconds`, at which point
it will automatically cancel itself.

Here's an example configuration using LEADER:

```lua
local wezterm = require 'wezterm';

return {
  -- timeout_milliseconds defaults to 1000 and can be omitted
  leader = { key="a", mods="CTRL", timeout_milliseconds=1000 },
  keys = {
    {key="|", mods="LEADER|SHIFT", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
    -- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
    {key="a", mods="LEADER|CTRL", action=wezterm.action{SendString="\x01"}},
  }
}
```

refs: https://github.com/wez/wezterm/issues/274
2020-09-25 21:38:49 -07:00
Wez Furlong
9925b5b608 termwiz: more freebsd compat
refs: https://github.com/wez/wezterm/pull/258
2020-09-09 00:17:40 -07:00
kas
44918364c0 Add default action for delete key 2020-07-11 08:53:42 -07:00
kas
cb2447cbad Add "kill and move" action for separate deletion and cursor movements 2020-07-11 08:53:42 -07:00
Wez Furlong
b307df6add term+termwiz: handle OSC L and OSC l
These are equivalent to OSC 2 and OSC 1 respectively.

We now also respond to requests to fetch the window title
2020-06-21 10:46:03 -07:00
Wez Furlong
e507d4e1e7 termwiz: allow OperatingSystemCommandCode to have non-numeric mappings
The code assumed that OSC parameters were always numeric, but that isn't
the case.

In order to allow adding non-numeric OSC code we need to adjust and
allow for the codes to be any string value, and that's what this
commit does.

It shouldn't change any other behavior.
2020-06-21 10:03:28 -07:00
Wez Furlong
badc4f9d9c term+termwiz: add Overline support
This commit teaches the terminal model about the overline attribute
and the SGR codes to enable/disable overline.

The render layer in the GUI doesn't yet understand this attribute.
2020-06-20 22:48:36 -07:00
Wez Furlong
b69c9b1c70 termwiz+term: add basic support for DECRQSS
Now that we're reporting a higher level from DA1, apps are asking
more exotic codes.  eg: vttest now asks about the conformance level,
but doesn't have a timeout on that request and hangs if we don't
respond.

This commit adds a bit of plumbing to make it easier to consume
and parse DCS sequences that are known to be short/short-lived,
and teaches the term layer to respond to a couple of possible
DECRQSS queries.
2020-06-20 11:04:37 -07:00
Wez Furlong
fea8f2479e termwiz: add Display impl for device control mode 2020-06-20 10:06:50 -07:00
Wez Furlong
aa106b33f1 termwiz: improve Debug impl for EnterDeviceControlMode 2020-06-20 09:51:25 -07:00
Wez Furlong
e2dc0add83 termwiz: recognize CSI > PP ; Pv m sequence
This is an xterm sequence that adjusts how the terminal
encodes keyboard output.

This commit teaches termwiz to parse and encode the sequence,
but doesn't teach the terminal emulator to do anything with it
at this time.

I'm adding this because vim sends these sequences and I wanted
to understand what they were for.
2020-06-19 23:40:48 -07:00
Wez Furlong
35a3f802c2 termwiz+term: improved emulation conformance in a number of areas
This commit adds support for left/right margins and has been
tested against esctest, with a final status of:

```
309 tests passed, 239 known bugs
```

"known bugs" also includes unimplemented features; we have a
similar degree as iTerm2.

As of this commit, we now report as a vt520ish machine to DA1.
I confess to not having read enough of the relevant docs
to know whether this is totally righteous.
2020-06-19 21:20:05 -07:00
Wez Furlong
e30f42a868 termwiz: fix hyperlink matching issue with double wide chars
refs: https://github.com/wez/wezterm/issues/221
2020-06-18 09:46:03 -07:00
Wez Furlong
e373755be2 termwiz: improve CSI parsing conformance
We weren't parsing `CSI 2H`; we'd decide that because it needed two
parameters it was an error instead of defaulting the omitted second
parameter to 1.
2020-06-18 07:44:26 -07:00
Wez Furlong
5ef357bb95 termwiz: improve rgb color parsing conformance with XParseColor 2020-06-18 06:59:02 -07:00
Wez Furlong
1288819180 term: improve esctest BS test conformance 2020-06-18 05:43:47 -07:00
Wez Furlong
2957173a57 termwiz: also allow #FFF form of color spec
We allowed the 6-digit variant, also allow the 3-digit variant.
2020-06-17 21:56:30 -07:00
Wez Furlong
5c5bef934b add decset 1047; our impl is the same as decset 47 2020-06-17 21:44:11 -07:00
Wez Furlong
39f4985741 maybe fixup windows build for num/num_traits changes 2020-06-13 12:05:47 -07:00
Wez Furlong
e70a58e7f3 cargo update 2020-06-13 10:21:49 -07:00
Wez Furlong
24fdf27d65 misc: upgrade unicode-segmentation 2020-06-13 10:10:34 -07:00
Wez Furlong
3002b40fd2 termwiz: make serde an optional dep
closes: https://github.com/wez/wezterm/pull/186
2020-06-13 09:55:18 -07:00
Wez Furlong
070afa65d6 termwiz: trim num dep to num_traits
refs: https://github.com/wez/wezterm/pull/186
2020-06-13 09:55:18 -07:00
Wez Furlong
47dc81c8d9 termwiz: separate CursorVisibility from CursorShape
They are separate concepts and this simplifies some processing.

closes: https://github.com/wez/wezterm/pull/212
2020-06-12 19:44:54 -07:00
Mark Thomas
fc352d00f9 termwiz: add CursorVisibility
Some applications want to control the cursor visibility, without affecting
cursor shape.  Provide the `CursorVisibility` change type for this purpose.

Use this when dropping `UnixTerminal` to ensure the cursor is visible
without affecting the user's cursor shape.
2020-06-12 18:52:49 -07:00
Wez Furlong
87eedfd42d wezterm: add dec private mode 1070 for sixel color map control
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 19:03:12 -07:00
Wez Furlong
a78954375d wezterm: sixel rendering basically working
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 08:13:37 -07:00
Wez Furlong
108def1f90 termwiz: add types for sixel parsing
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 08:13:29 -07:00
Wez Furlong
b370c8020f termwiz: fix swapped width/height in size reporting sequences
Whoops! :)

refs: https://github.com/wez/wezterm/issues/211#issuecomment-642056005
2020-06-10 08:22:46 -07:00