1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 12:23:46 +03:00
Commit Graph

335 Commits

Author SHA1 Message Date
Wez Furlong
868a085157 termwiz: shrink-to-fit Line::cells when clearing the line
refs: https://github.com/wez/wezterm/issues/534
2021-03-13 08:25:09 -08:00
Wez Furlong
f4105cb42f avoid excess capacity when dealing with iterm2 image protocol
Using a boxed slice means that we hold exactly the memory required
for the file data, rather than the next-power-of-two, which can
be wasteful when a large number of images are being sent to
the terminal.

This is a API breaking change for termwiz, so bump its version.

refs: #534
2021-03-13 08:10:48 -08:00
Mark Juggurnauth-Thomas
60c0d91a07 termwiz: use cnorm instead of cvvis for CursorVisibility::Visible 2021-03-12 08:20:01 -08:00
Mark Juggurnauth-Thomas
ee03d9a260 termwiz: revert tmux workarounds
We can support tmux by properly supporting the distinction between
`cvvis` and `cnorm`.
2021-03-12 08:20:01 -08:00
Wez Furlong
77011593b7 termwiz: alternate plan for restoring cursor visibility in tmux
backout 7c49b43472 and go with
the alternate plan of switching TERM=tmux if `$TERM==screen && $TMUX`.

refs: https://github.com/markbt/streampager/issues/37#issuecomment-797274512
2021-03-11 23:23:32 -08:00
Wez Furlong
7c49b43472 termwiz: improve restoring cursor visibility under tmux
refs: <https://github.com/markbt/streampager/issues/37#issuecomment-797241725>
2021-03-11 22:23:53 -08:00
Wez Furlong
565a4c69d5 lua: add wezterm.format function
The intent is to use this to compose text for a configurable tab bar.

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 09:52:54 -08:00
Wez Furlong
60be1a98a0 lua: add window::effective_config() method
Expose the current window configuration to lua scripts.

refs: https://github.com/wez/wezterm/issues/469
2021-02-27 12:39:22 -08:00
Wez Furlong
f0c163e212 Plumb OSC 777 to toast notifications
```
echo -e "\033]777;notify;This is the notification title;This is the notification text\a"
```

Now pops up a notification in a similar manner to OSC 9, except
that this form allows setting both the title and the body separately.

refs: https://github.com/wez/wezterm/issues/489
2021-02-18 22:13:20 -08:00
Wez Furlong
578b59ad33 fix one 32-bit build issue
refs: #474
2021-02-12 08:35:00 -08:00
Wez Furlong
005b492a8b deps: update to ordered-float 2.1 2021-02-07 22:54:02 -08:00
Wez Furlong
b60e83b22b docs: start documenting supporting escape sequences
I started this a while ago; it's pretty time consuming to produce
accessible and usable documentation for this sort of stuff, so
this isn't yet complete, but in the interest of avoiding additional
bit-rot, let's get this up.

refs: https://github.com/wez/wezterm/issues/257
2021-01-18 11:16:18 -08:00
Wez Furlong
ce6ecc1f38 termwiz: really fixup windows build 2021-01-08 09:33:08 -08:00
Wez Furlong
3a9ab729db termwiz: fixup win32 build 2021-01-08 08:55:43 -08:00
Wez Furlong
5d360ae365 termwiz: Remove anyhow::Result from public API
It's been replaced with an opaque termwiz error type instead.

This is a bit of a more conservative approach than that in (refs: #407)
and has less of an impact on the surrounding code, which appeals to
me from a maintenance perspective.

refs: #406
refs: #407
2021-01-08 00:32:30 -08:00
Wez Furlong
88ebe79fdf add wezterm.terminfo source
You can install this into your $TERMINFO directory (default is
`$HOME/.terminfo`) by running:

`tic -x wezterm.terminfo`

from this data directory.

Once installed, you can set `TERM=wezterm`.

refs: https://github.com/wez/wezterm/issues/415
2021-01-06 18:44:53 -08:00
Wez Furlong
e1f7edaeb3 recognize the : form of the true color CSI/SGR encoding
refs: https://github.com/wez/wezterm/issues/415
2021-01-06 18:20:42 -08:00
Wez Furlong
3df0201d42 recognize kitty style CSI 4:3 m underlines
refs: https://github.com/wez/wezterm/issues/415
2021-01-06 17:59:54 -08:00
Wez Furlong
b6a422a542 vtparse: allow for CSI parameters to be : separated
This allows us to support the kitty style underline sequence,
or the : separated form of the true color escape sequences.

refs: https://github.com/wez/wezterm/issues/415
2021-01-06 16:58:58 -08:00
Wez Furlong
93576691fe compute most line-glyphs on-the-fly
We now have too many permutations to pre-render in the initial
texture size, so do this on the fly instead.

refs: https://github.com/wez/wezterm/issues/415
2021-01-05 14:16:21 -08:00
Wez Furlong
b35f3aa199 Add Curly, Dotted, Dashed and colored underline concept to model
These aren't currently rendered, but the parser and model now support
recognizing expanded underline sequences:

```
CSI 24 m   -> No underline
CSI 4 m    -> Single underline
CSI 21 m   -> Double underline
CSI 60 m   -> Curly underline
CSI 61 m   -> Dotted underline
CSI 62 m   -> Dashed underline

CSI 58 ; 2 ; R ; G ; B m   -> set underline color to specified true color RGB
CSI 58 ; 5 ; I m           -> set underline color to palette index I (0-255)
CSI 59                     -> restore underline color to default
```

The Curly, Dotted and Dashed CSI codes are a wezterm assignment in the
SGR space.  This is by no means official; I just picked some numbers
that were not used based on the xterm ctrl sequences.

The color assignment codes 58 and 59 are prior art from Kitty.

refs: https://github.com/wez/wezterm/issues/415
2021-01-05 10:29:36 -08:00
Félix Saparelli
1762ccd761
Instruct docs.rs to build with widgets and serde features (#409) 2020-12-30 09:25:54 -08:00
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
Wez Furlong
d7c04b154d termwiz: shift Boxing of DCS around
Previously, we'd require boxing the entire DCS representation
in the escape sequence parser.  This was due to some clippy
advice that made sense at the time, but now that I'm looking
at more things using DCS it seems wasteful to Box each byte of
the dcs sequence.  This commit shifts the box to the heavier
weight portion: the DCS hook/entry representation.
2020-06-09 22:01:26 -07:00
Wez Furlong
18a234a162 termwiz: fix dec private mode parsing
When processing `\033[?1002;1003;1005;1006h`, when we encountered
`1005` we would skip 1006.  This was because we hit the unspecified
enum case for 1005 (we have no enum variant for that mode) and that
code path didn't properly advance only by a single position.

This commit fixes that.

refs: https://github.com/wez/wezterm/issues/211#issuecomment-641302077
2020-06-09 19:00:12 -07:00
Wez Furlong
65f94bd57b vtparse: fix DCS parsing
This corrects an issue where the mode byte of the DCS sequence was
discarded from the DcsHook, making it impossible to know what sequence
is being activated.

So far this hasn't come up as these sequences are relatively rare,
but in looking at sixel parsing I noticed the error.
2020-06-09 09:03:08 -07:00
Wez Furlong
ff9151bb9b termwiz/term: implement window/pixel size responses
refs: https://github.com/wez/wezterm/issues/211
2020-06-08 18:44:05 -07:00
Wez Furlong
8204a1a6b6 termwiz: recognize wezterm as supporting iterm2 images 2020-06-05 23:08:17 -07:00
Wez Furlong
82261ff16d wezterm: enable scrollback in the error window
This commit doesn't do anything specific to scrollback though!
It moves the implementation of the TermWizTermTab away from
a directly manipulated Surface and over to using the term::Terminal,
making the renderer look more like the one used by the local tab
and domain implementation.

As a side effect of doing this, we get scrollback management
for free.

refs: https://github.com/wez/wezterm/issues/201
2020-06-03 08:45:03 -07:00
Wez Furlong
ccf9fc141b wezterm: fixup DECKPAM/DECANM/DECCKM interaction
We were treating DECCKM as the sole thing to enable application
cursor reporting, but looking closely at the docs, that mode only
takes effect when both DECANM (Vt52 emulation mode) AND DECKPAM
(application keypad mode) are both active.

neovim enables DECCKM and DECKPAM but not DECANM.

refs: https://github.com/wez/wezterm/issues/203
2020-05-31 15:45:25 -07:00
Wez Furlong
92fdf043b8 termwiz: fix panic in RgbColor::from_rgb_str w/ empty string
Need to check the len before looking at the first character!

closes https://github.com/wez/wezterm/issues/198
2020-05-29 07:15:45 -07:00
Wez Furlong
58686f925f termwiz: fix a widget layout and optimization issue
This commit adds a simple example of nested widgets, which uncovered
an issue with respecting the layout positioning, and adds a secondary
screen buffer to make the widget render cycle more optimal:

```
cargo run --example widgets_nested --features widgets --release
```

refs: https://github.com/wez/wezterm/issues/171
2020-05-18 07:40:09 -07:00
Wez Furlong
77fafd512b termwiz: add example program that strips escape sequences 2020-05-17 21:30:12 -07:00
Wez Furlong
1ad6f00696 termwiz: cut 0.9.0 release 2020-05-17 12:05:46 -07:00
Wez Furlong
3349ef0dca termwiz: fix categorization of F keys
refs: https://github.com/wez/wezterm/issues/178
2020-05-16 17:25:23 -07:00
Wez Furlong
f2b12c64ba termwiz: use long form ST when rendering OSC
Neovim doesn't like using BEL as an alternative for ST when
parsing the OSC dynamic color responses.

Use the longer form sequence to make it happier!
2020-05-16 11:01:26 -07:00
Wez Furlong
a3921a73fa Explicitly ignore focus tracking (dec private mode 1004)
We still don't support it, but we no longer log that we don't
know what the mode is.
2020-05-16 09:31:02 -07:00
Wez Furlong
a1c0cabf18 term: process OSC 110+: ResetDynamicColors
neovim uses these
2020-05-16 09:25:17 -07:00
Wez Furlong
132529cfd5 support Terminal identification sequence
This reports the TERM_PROGRAM and TERM_PROGRAM_VERSION
separated by a space.

See discussion in https://github.com/mintty/mintty/issues/881
with a more concise description of the functionality here in
this VTE issue: https://gitlab.gnome.org/GNOME/vte/-/issues/235

```bash
$ printf '\033[>q'; cat
^[P>|WezTerm 20200503-171512-b13ef15f-4-g0395639a^[\
```
2020-05-03 22:10:38 -07:00
Wez Furlong
fa32457656 cargo fmt 2020-05-02 17:39:45 -07:00
Wez Furlong
b3a57f0d1c termwiz: line editor: fix a couple of bugs
* ctrl-R to find a line and then hit enter would cause the search
  text rather than the match text to be returned and run!
* When exiting the editor, clear to end of screen to make sure
  that we clean up any UI from the incremental search status
2020-04-10 21:10:42 -07:00
Wez Furlong
d4df39f793 termwiz: line editor: add ChangeSequence helper
This helps us keep track of the extent and cursor position that
we render for the line editor, making it easier to make the editor
rendering more fancy.
2020-04-10 20:42:02 -07:00
Wez Furlong
8963fb76aa termwiz: line editor: add incremental history search 2020-04-10 11:02:59 -07:00
Wez Furlong
79007d9c33 termwiz: line editor: allow custom editor actions
This restructures the LineEditor to allow the hosting application to
override key presses and apply custom edits to the editor buffer.

Methods for performing predefined actions and for accessing the line
buffer and cursor position have been provided/exposed to support this.

One consequence of this change is that the editor instance needs to be
passed through to the host trait impl and that means that the LineEditor
can no longer be generic over `Terminal`.  Instead we now take `&mut dyn
Terminal` which was how the majority of non-example code was using it in
any case.  This simplifies a bit of boilerplate in wezterm but adds an
extra line to the most basic examples.
2020-04-09 07:37:23 -07:00
Wez Furlong
eb1f583e2b termwiz: line editor: allow embedded app to override key map 2020-04-09 06:40:29 -07:00
Wez Furlong
e033e3576f termwiz: History::get() -> Option<Cow<str>>
The BasicHistory impl returned a borrowed reference but the sqlite based
impl I'm adding to wzsh needs to own it.
2020-04-08 22:32:14 -07:00
Wez Furlong
af339f7cfe termwiz: line editor: allow application cursor keys
On Windows, if you run `wsl.exe` from the terminal and start zsh
(maybe bash also?) and it enables application cursor key mode,
exiting zsh doesn't clear application cursor key mode and when we
return to the shell and are using virtual terminal input rather
than the native windows console input, we'll continue to receive
application cursor key sequences instead of regular cursor key
input sequences.

This commit recognizes both flavors as arrow movement
in the line editor to make this feel less broken.
2020-04-08 19:11:15 -07:00
Wez Furlong
5b57f5f9ff termwiz: line editor: exit completion state for a single completion result 2020-04-08 10:07:15 -07:00
Wez Furlong
11c7e29b59 termwiz: windows: toggle autonewline when toggling cooked/raw
Without this, `wzsh` will keep the terminal in raw mode between
line editor invocations, resulting in staggered/stairway output
for any spawned commands.
2020-04-08 08:57:26 -07:00
Wez Furlong
db845db55b termwiz: line editor: allow for multi-line prompts 2020-04-07 22:06:05 -07:00
Wez Furlong
5b700e4d5d wezterm: recognize MS terminal mode 25 for cursor visibility 2020-04-06 13:19:44 -07:00