1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00
Commit Graph

616 Commits

Author SHA1 Message Date
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
1c366063a3 take another crack at fixing up line wrapping attributes
This time we set the wrapped attribute when we implicitly emit
a newline and the wrap_next flag is set.

refs: #978
refs: #971
2021-07-25 09:47:29 -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
ce9d166733 #133 ENQ response 2021-07-24 23:36:20 -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
e3cadc5782 #133 AutomaticNewline mode 2021-07-24 23:15:24 -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
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
dcbbda7702 allow images to overlay text
This commit introduces a 4th draw pass for rendering sixel and
iterm images that are attached to cells.

Previously, a cell could container either text or an image from
the perspective of the renderer.  If it had an image then the glyph
bitmap would be ignored in favor of the image.

However, that causes sixel behavior to diverge from other terminals
(https://github.com/wez/wezterm/issues/942) so we need to be render
both of these.

The simplest way to achieve this is to add a distinct set of texture
coordinates for the attached image and then add a draw pass to alpha
blend it over the glyph content.

The sixel/iterm image processing stage is also adjusted to preserve
the prior cell information and "simply" attach the image info to
the cell.  Previously, the cell would be replaced with a blank cell
with the image attached.

The result of this is that the notcurses-demo intro section can
now render the orca "enveloped in the soft glow of glyphs" rather
than caged in a black box.

Note that there are some cases where the render turns blocky but
I suspect that that is due to some other misunderstanding between
wezterm and notcurses and that we'll root cause it as a follow up.
2021-07-22 09:46:08 -07:00
Wez Furlong
5076fe2dda term: fix rewrap issue for lines == terminal width
closes: https://github.com/wez/wezterm/issues/971
2021-07-22 07:49:18 -07:00
Wez Furlong
a2e882a7cb deps: cargo update, and a couple of dependabot suggestions 2021-07-18 19:10:46 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00
Wez Furlong
75eaaab6a1 Allow window config overrides to apply per-pane
This allows window-level config overrides to apply
to panes contained within the window.

For instance, this allows setting a window-level
color scheme.
2021-07-17 23:02:41 -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
Wez Furlong
020c0991e4 cleanup: remove term::Clipboard::get_contents method
This dates back to long ago, and is never called.
Remove it, and cleanup some state associated with it.
2021-07-17 07:38:48 -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
ab1cad0cbf #891 VT100 character set support 2021-06-20 08:29:31 -07:00
Autumn Lamonte
317d8d9725 #891 Fix format for CI 2021-06-20 08:29:31 -07:00
Autumn Lamonte
0b7f48256f Use black diamond U+25C6, not black diamond suit U+2666 2021-06-20 08:29:31 -07:00
Autumn Lamonte
6f680dc481 Flesh out DEC Special Graphics character set 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
b03e27adb1 deps: ordered-float 2.1 -> 2.5
closes: https://github.com/wez/wezterm/pull/831
2021-05-31 00:17:18 -07:00
Wez Furlong
2e924c9627 fix over-reporting of mouse drag events
neovim doesn't like it when multiple drag events with the same
coordinates are received; it appears to treat that as though
the mouse button was double clicked.

This commit teaches the mouse report encoding to suppress multiple
drag events in succession that have the same payload.

refs: https://github.com/wez/wezterm/discussions/823
2021-05-30 12:36:50 -07:00
Wez Furlong
dc4c8f07dd mux protocol sending alerts to client
refs: https://github.com/wez/wezterm/issues/748
refs: https://github.com/wez/wezterm/issues/489
2021-05-30 10:18:30 -07:00
Wez Furlong
f5f393bf2c term: notify embedding application when palette changes
refs: #748
2021-05-30 09:29:04 -07:00
Wez Furlong
46d4de7ad2 mux: make tardy/greyed out palette less jarring
Use a similar hsv transformation to that used to dim inactive panes
instead of the treatment that made the black look grey, which felt
like a flash instead of a dim.
2021-05-30 08:13:33 -07:00
Wez Furlong
01de37b709 fix Sixel HLS interpretation
Two issues here:

* The hue angles need adjusting to work with the palette library
* The resultant RGB color had the wrong gamma level, resulting in
  an overly bright image.

refs: https://github.com/wez/wezterm/issues/775
2021-05-09 11:43:26 -07:00
Wez Furlong
f9a6e265e9 avoid panics in a couple of cases
test case: `cat /dev/random`

refs: https://github.com/wez/wezterm/issues/769
2021-05-08 01:02:44 -07:00
Wez Furlong
ff153ba27f vtparse: recognize utf8 encoded c1 codes in more cases
There were two bugs here:

* \u8D (the utf8 encoded representation of 0x8d, aka: RI) was not
  recognized as a C1 code and was instead passed through as printable
  text.
* The \u8D is a zero-width sequence which means that a subsequent
  set_cell call on the new empty-by-default line wouldn't allocate
  any cells in the line array, and the assigment to the line would
  panic.

This commit avoids the panic for the second case, and then fixes up
the vtparser to correctly recognize the sequence as a C1 control.

refs: https://github.com/wez/wezterm/issues/768
2021-05-08 00:39:29 -07:00
Wez Furlong
0316dfeb83 term can now notify application about potential title updates
When the title, icon, OSC 7 and SetUserVars sequences are processed,
notify the embedding application.

The gui layer uses this to trigger a titlebar update.

refs: #647
2021-04-30 07:28:02 -07:00
Wez Furlong
6d7f9879ac be more aggressive at pruning trailing blanks 2021-04-29 16:00:33 -07:00
Wez Furlong
b01193e1a5 cap typical blank line length to a reasonable value
This has the effect of reducing the memory and scroll cost
for lines that are shorter than the physical width of the
terminal matrix.

refs: https://github.com/wez/wezterm/issues/740
2021-04-29 09:03:58 -07:00
Wez Furlong
acb4df4934 term: clear mouse button when focus is lost
refs: https://github.com/wez/wezterm/issues/744
2021-04-27 08:38:40 -07:00
Wez Furlong
87677a73bf Add support for iTerm2's SetUserVar escape
This doesn't propagate across wezterm's mux protocol
at this time.

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

https://iterm2.com/documentation-scripting-fundamentals.html#setting-user-defined-variables
2021-04-25 14:30:06 -07:00
Wez Furlong
b0f5e673c6 vtparse/termwiz: prep for release 2021-04-14 13:04:23 -07:00
Wez Furlong
3dfdd08b79 parse and respond to XTSMGRAPHICS queries
refs: https://github.com/wez/wezterm/issues/609
2021-04-01 22:42:28 -07:00
Wez Furlong
1a7d3828fd ensure lines are marked dirty when rewrapping
refs: https://github.com/wez/wezterm/issues/574
2021-03-25 16:02:27 -07:00
Wez Furlong
dc4676047e stronger invalidation when resizing
This seems to make it very difficult to reproduce the blanked
out regions in the related issue.

refs: https://github.com/wez/wezterm/issues/574
2021-03-25 15:16:50 -07:00
Aaron Abramov
786888ce0a update k9 to 0.11.0 to make it work with rustc@1.51.0
1.51.0 no longer takes non string literals in `panic()`. k9@0.11.0 fixes that
2021-03-25 10:39:00 -07:00
Wez Furlong
a2bad801d2 don't rewrap the alt screen on resize
It is only used by applications that repaint on a resize event,
and us rewrapping makes it harder to have an ideal view afterwards.

This change makes us more consistent with VTE's behavior in this case.

This helps with https://github.com/wez/wezterm/issues/574 but doesn't
completely resolve it.
2021-03-25 08:39:44 -07:00
Wez Furlong
8d4138bca6 fix X10 mouse encoding issue
This manifests under GNU screen when the window is large.

cc: @babar
2021-03-23 11:09:56 -07:00
Wez Furlong
7def5f07e3 more thorough ctrl key mapping
I didn't realize that xterm inherited some additional mappings from
the X server, so this commit should make us more comformant with
xterms behavior.

Verified this by comparing `showkey -a` under both xterm and wezterm:

```
wezterm -n --config disable_default_key_bindings=true --config debug_key_events=true start -- showkey -a
```

refs: https://github.com/wez/wezterm/issues/236
refs: https://github.com/wez/wezterm/discussions/556
2021-03-19 09:18:19 -07:00
Wez Furlong
693a717db2 improve output parsing performance and throughput
I've been meaning to do this for a while; this commit moves
the escape sequence parsing into the thread that reads the
pty output which achieves two goals:

* Large escape sequences (eg: image protocols) that span multiple
  4k buffers can be processed without ping-ponging between the
  reader thread and the main gui thread
* That parsing can happen in the reader thread, keeping the gui
  thread more responsive.

These changes free up the CPU during intensive operations such
as timg video playback.

This is a slight layering violation, in that this processing
really belongs to local pane (or any pane that embeds Terminal),
rather than generically at the Mux layer, but it's not any
worse a violation than `advance_bytes` already was.

refs: https://github.com/wez/wezterm/issues/537
2021-03-13 19:19:05 -08:00
Wez Furlong
fa7aa3a427 improve downscaling for single frame images
The default downscaling provided by the GPU can result in noisy
artifacts on highly detailed images.

This commit employs a cubic Catmull-Rom sampling filter for the
case where we have a single frame image that is being reduced
in size.  This isn't the highest quality filter but strikes
a good balance with speed vs appearance and is strictly better
than the GPU texture sampling options that I could try.
2021-03-13 16:22:44 -08:00
Wez Furlong
6133f88d6a term: avoid full image decode when parsing iterm2 protocol
Just decode the size

refs: https://github.com/wez/wezterm/issues/537
2021-03-13 13:34:44 -08:00
Wez Furlong
e5974ad86f iterm2 image protocol: make image fit to terminal dimensions
when the size is set to auto, we'd essentially take the image as-is
and overflow the terminal.

This commit makes auto scale down the image to fit the terminal dimensions
if it is too big.
2021-03-13 13:14:46 -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
Wez Furlong
98cb3a8191 adjust some errors -> warnings
These don't indicate that something is wrong with wezterm, so don't
appear to be so alarming.
2021-03-06 13:58:55 -08:00
Wez Furlong
76c7ef56df term: RIS must clear the scrollback
closes: #511
2021-03-03 07:44:57 -08:00
Wez Furlong
01f5df6729 term: ignore ShiftIn/ShiftOut
rather than logging an error.

closes: #509
2021-03-02 09:07:20 -08:00
Wez Furlong
651e536d87 term: plumb Bell through toast notification channel
Per my comment: https://github.com/wez/wezterm/issues/3#issuecomment-780750798

this routes the bell through to the GUI layer, where it currently
does nothing about it.
2021-02-18 22:34:05 -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
83da7216c3 toast: hook notifications up to OSC 9
refs: #489
2021-02-17 09:33:58 -08:00
Wez Furlong
ece9276624 term: large pastes could hang the terminal
Pasting a lot of text could cause a deadlock between writing
to the input side of the pty and consuming the output side.

Making the writer/input side non-blocking resolves this.
2021-02-11 23:32:19 -08:00
Wez Furlong
6371ec501a OSC 52: update it so that it we respect primary vs. clipboard selection 2021-02-08 08:56:06 -08:00
Wez Furlong
005b492a8b deps: update to ordered-float 2.1 2021-02-07 22:54:02 -08:00
Wez Furlong
d10f7bbb1b wezterm: add alternate_buffer_wheel_scroll_speed option and increase to 3
More details in the included docs.

closes: #432
2021-01-30 10:14:01 -08:00
Dylan Frankland
88f44f5b5f
Add erase mode to ClearScrollback action (#439)
* Add ClearBuffer action

Clears all lines, both visible and those scrolled off the top of the viewport, making the prompt line the new first line and resetting the scrollbar thumb to the full height of the window.

This is the behavior that Hyper / xterm has for clearing the terminal.

* Combine ClearBuffer into ClearScrollback as enum with associated erase mode

Makes it easier to manage the different options of clearing the terminal.
2021-01-25 21:26:23 -08:00
Wez Furlong
da3a41e018 wezterm: fix mapping scroll wheel to cursor up/down in alt screen
This appears to have been broken since the introduction of mouse
assignments :-/

This commit adds Pane::is_alt_screen_active so that the gui layer
can tell whether the alt screen is active, and allow passing down
the event.

refs: #429
2021-01-17 21:44:02 -08:00
Wez Furlong
b7b72646e3 term: when pasting on windows prefer CRLF line endings
TL;DR: on unix, or if bracketed paste is on, then we paste with
unix newlines.  If on windows && !bracketed paste then with CRLF.

See explanation in the code for more context.

refs: https://github.com/wez/wezterm/issues/411
2021-01-17 10:59:29 -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
Wez Furlong
dc2efb0b43 fix tests after 80411d7db9 2020-12-29 11:28:43 -08:00
Wez Furlong
80411d7db9 simplify passing the TerminalSize to the terminal
Following on from 8649056ac0,
this commit should make it harder to make a similar mistake
in the future, by introducing a new TerminalSize struct for
that purpose.
2020-12-29 09:06:26 -08:00
Wez Furlong
7cbbb49ab4 deps: ordered-float -> 2.0 2020-12-28 08:25:43 -08:00
Wez Furlong
b3ac77aa92 wezterm: allow adding images to termwiztermtab apps
Tidies up the plumbing around pixel dimensions so that ImageData
can be rendered via the termwiztermtab bits.

I put this together to play with sticking the wezterm logo in
the close confirmation dialogs.  I didn't end up using that though,
but have preserved the commented code for use in future hacking.
2020-12-26 14:01:48 -08:00
Wez Furlong
8649056ac0 term: fix longstanding bug with imagecat
Sometimes, I'd notice that imgcat would have a weird aspect.
I stumbled across the root cause while debugging something else:
the order of the pixel width and height was flipped here.
2020-12-26 13:58:08 -08:00
Wez Furlong
44b76e35df term: fix iterm2 image protocol size when only 1 dimension specified
when running eg: `wezterm imgcat assets/icon/terminal.png --width 3`
we were scaling the height up by the ratio between the physical
width and the specified width, instead of down.
2020-12-26 11:10:28 -08:00
Wez Furlong
61ce4cd954 fixup some more log levels 2020-12-21 22:13:41 -08:00
Wez Furlong
80214319ae adjust log levels
Revise logging so that we use info level for things that we want
to always log, and adjust the logger config to always log info
level messages.

That means shifting some warning level logs down lower to debug level so
that they aren't noisy.

closes: https://github.com/wez/wezterm/issues/388
2020-12-20 22:01:06 -08:00
Aaron Abramov
2eef556092
Update snapshot tests to use k9@0.10.0 (#384)
I'm gradually improving snapshot testing macro devx in k9 and preparing
to ship v1. Before i do this i'm changing the inline snapshot macro to be
just `snapshot!()` that takes `Debug` trait an an arg and figures out
serialization of it.
2020-12-19 16:43:25 -08:00
Wez Furlong
8eb0dac92c Update lru -> 0.6 2020-12-09 14:04:56 -08:00
Wez Furlong
dfde0c8809 term: revise color cube in the default palette
This commit adjusts the default color palette to use the same color
cube calculation as xterm; it isn't the ideal color cube calculation
and results in slightly brighter colors.

This commit also memoizes the default palette calculation so that
it isn't recomputed each time a palette is created.

refs: https://github.com/wez/wezterm/issues/348
2020-12-09 00:52:24 -08:00
Wez Furlong
eabfa3c0f8 term: fix ALT-Escape
This appears to have been accidentally broken as part of the churn
around building out CSI-u key encoding in
6289c08a4e

closes: https://github.com/wez/wezterm/issues/338
2020-11-23 14:20:43 -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
0b64683a60 term: allow embedding application to hook device control mode
refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:24:48 -08:00
Wez Furlong
fd3c062daf cargo fmt
latest rust changed the formatting options, so reformat to
avoid the CI being unhappy.
2020-11-20 09:06:21 -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
cfef4fd0ca wezterm: adjust pixel width and height when dragging splits
The drag would update the cell dimensions but not the pixel dimensions,
which results in weird image scaling.

refs: #312
2020-11-02 19:56:46 -08:00
Wez Furlong
7fb22d6968 term: correct cursor position after imgcat
I've had a FIXME in here for a while to check the positioning,
but never got around to it.

The onefetch folks have an app that does care about this,
so it's time to resolve it!

This commit adjusts the cursor position for the iterm case
(not the sixel case), and results in both:

running in xterm:

```
onefetch --image ~/Downloads/squirrel.png
```

running in wezterm:

```
TERM_PROGRAM=iTerm.app onefetch --image ~/Downloads/squirrel.png --image-backend=iterm
```

```
onefetch --image ~/Downloads/squirrel.png --image-backend=sixel
```

showing consistent positioning.

refs: https://github.com/wez/wezterm/issues/317
refs: https://github.com/o2sh/onefetch/pull/305
2020-11-02 18:06:05 -08:00
Wez Furlong
9614e117e0 term: restore original resize behavior on Windows
This reverts to the original resize behavior of padding out
the display when resizing taller, but only for Windows systems.

More explanation in the comments in the code.

refs: #138
2020-10-31 11:58:15 -07:00
Wez Furlong
75ce0fc822 term: improve cursor/viewport positioning on resize
This seems to make our resize behavior a bit nicer and more
consistent with eg: xterm.

Previously we'd consider the previously existing scrollback
as immutable and prefer to add excess blank lines of padding
when making the window taller.

In practice that meant that content would scroll back when
making the window taller, which is annoying.

This commit removes that constraint and instead will prefer
to maintain the cursor position relative to the top of the
viewport when the size changes.

refs: #138
2020-10-28 22:50:50 -07:00
Wez Furlong
5b9c86d836 colors: set cursor border to bg in the color schemes
This avoids having a green (by default) border around the cursor.
The dynamic color escape sequences have been updated to also
change the border color when the cursor background color is changed.
2020-10-27 09:17:20 -07:00
Wez Furlong
dab2dd5025 term: cache recently decoded images
This commit introduces a small, bounded, LRU cache for recently
decoded images.

This allows the same image ID to be used in the cache that the
same image bits are repeatedly sent to the terminal.

This is advantageous because it reduces the amount of texture
space required by the gui layer.
2020-10-25 11:59:44 -07:00
Wez Furlong
e2bf111426 wezterm: fix texture coordinates math for image protocols
There was an integer conversion happening when taking the
per-cell image texture coordinates and applying them to the
texture atlas image coordinates.

This commit replaces that math with floating point and corrects
the visual artifacts within squirrel.png.

refs: #292
2020-10-24 11:13:08 -07:00
Wez Furlong
91ce0b77ea wezterm: tidy up shader a bit
More properly annotate the types of the data used in the shaders.
Make the declarations more consistent with each other.
2020-10-24 10:42:23 -07:00
Wez Furlong
1978eba0a1 wezterm: make the split color configurable and darker
This makes the color of the split divider darker by default,
and configurable via the color scheme configuration file.

refs: #297
2020-10-19 22:05:13 -07:00
Wez Furlong
7767fbe88f termwiz: fixup tests after b3f51e8ee2 2020-10-11 17:21:16 -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
99df89eaa1 fix cargo doctest warning 2020-10-03 11:15:57 -07:00
Wez Furlong
6430952d74 cargo update 2020-09-09 09:31:37 -07:00
Wez Furlong
38277a9592 term: when setting both icon and window title, clear icon title
Clear the icon title and just set the window title processing
that event.

refs: https://github.com/wez/wezterm/issues/247
2020-08-12 22:37:46 -07:00
Wez Furlong
bb1e355b7d term: get_title prefers icon title over window title
When returning the title string we prefer to return the OSC 1 Icon
title (which is interpreted as "tab title" by some emulators and
shell toolkits) on the basis that it will have been setup for
display in a more limited width than the overall window title
and will thus likely be a better choice to show to the user.

If OSC 1 hasn't been set then we'll fall back to the OSC 2 window
title as before.

refs: https://github.com/wez/wezterm/issues/247
2020-08-12 22:34:41 -07:00
Wez Furlong
dd57f05774 Treat OSC 0 and OSC 1 the same as OSC 2: set the title
OSC 1 is defined as setting the "Icon Title".
OSC 2 is defined as setting the "Window Title".
OSC 0 sets both of those.

Some terminal emulators will display the Icon title as the tab
title.

Wezterm doesn't make a distinction between any of those things; the
title is applied (during escape sequence parsing) to the terminal
instance in isolation from any other terminals; when the GUI layer
renders the titlebar it is composed from the title in the active tab.

refs: https://github.com/wez/wezterm/issues/247
2020-08-02 22:52:04 -07:00
Wez Furlong
a9ee544d7c term: use BufWriter for writer
I'm wondering if the non-deterministic portion of
refs: https://github.com/wez/wezterm/issues/241
might be due to splitting of data across multiple write calls.

This commit adopts the use of BufWriter around the writer so that
we can buffer up and explicitly flush the responses to the terminal.
2020-07-12 09:08:39 -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
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
4e6357b218 term: enable DECSET 1004 Focus Reporting
This is enabled only for local terminals for now; the multiplexer
protocol will need to be extended to carry this signal.
2020-06-20 22:01:56 -07:00
Wez Furlong
59ca0da7ad term: fix representation of unmodified F5+
We were unconditionally adding the encoded form of the modifier
mask (eg: appending `;1~` to the sequence) and not all apps know
how to interpret that.

refs: https://github.com/wez/wezterm/issues/227
2020-06-20 12:11:35 -07:00
Wez Furlong
fded650ccb term: add DECRQSS DECSLRM response
While testing this with esctest, it was apparent that xterm deviates
from the DEC docs by allowing a minimum region size smaller than 2,
so adjust our restriction accordingly.
2020-06-20 11:12:18 -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
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
efe425c4f6 term: s/scroll_region/top_and_bottom_margins/ 2020-06-18 15:41:54 -07:00
Wez Furlong
bd3844d665 term: improve CUU conformance, pass CUU esctests 2020-06-18 07:45:33 -07:00
Wez Furlong
99108afa60 term: improve CUD conformance and pass CUD esctest 2020-06-18 07:19:49 -07:00
Wez Furlong
22f6ec0070 term: implement CBT and pass CBT esctests 2020-06-18 05:50:28 -07:00
Wez Furlong
1288819180 term: improve esctest BS test conformance 2020-06-18 05:43:47 -07:00
Wez Furlong
b6e9fb07d4 term: improve esctest ANSIRCTests conformance
These tweaks to cursor save/restore enable wezterm to pass my wezterm
enabled local branch of esctest.
2020-06-17 23:09:37 -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
8f1f1a65ea window: handle opengl context loss on windows.
With this commit, we now survive a reinstall or upgrade of the nvidia
drivers on my Windows sytem without crashing.

This commit allows notifying the application of the context loss
so the application can either try to reinit opengl or open a new
window as a replacement and init opengl there.

I've not had success at reinitializing opengl after a driver upgrade;
it seems to be persistently stuck in a state where it fails to allocate
a vertex buffer.

SO, the state we have now is that we try to reinit opengl on a new
window, and if that fails, leave it set to the software renderer.

This isn't a perfect UX, but it is better than terminating!

refs: https://github.com/wez/wezterm/issues/156
2020-06-16 21:17:48 -07:00
Wez Furlong
fad6e8cbc1 term: fix an off-by-one in clear-to-start-of-line
refs: https://github.com/wez/wezterm/issues/218
2020-06-14 10:31:49 -07:00
Wez Furlong
39f4985741 maybe fixup windows build for num/num_traits changes 2020-06-13 12:05:47 -07:00
Wez Furlong
24fdf27d65 misc: upgrade unicode-segmentation 2020-06-13 10:10:34 -07:00
Wez Furlong
2f3a508e99 term: make serde optional 2020-06-13 10:04:20 -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
d547d938d8 term: rename crate to wezterm-term in advance of publishing
Add some more docs and remove a couple of dead bits of code.
2020-06-13 09:55:16 -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
Wez Furlong
7c8b69e5a0 term: improve sgr mouse button up response
Rather than reporting the basic mouse reporting "button released"
event code, in SGR mouse mode we can report that actual mouse
button that was released.  So do it.

refs: https://github.com/wez/wezterm/issues/211#issuecomment-642877545
2020-06-11 20:48:10 -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
d5927c22fa term: expand scope of Primary DA response
We now claim to be vt320ish with support for selective erase and sixel
graphics.

refs: https://github.com/wez/wezterm/issues/217
2020-06-11 08:13:42 -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
9f1303fb8e term: fixup ctrl+ ambiguous ctrl code representation
This was originally intended to be swept in and dealt with as part of
adopting CSI-u (refs: https://github.com/wez/wezterm/issues/63) but the
default shift-space mapping is super irritating in vim (refs:
https://github.com/wez/wezterm/issues/126) so it got partially walked
back, but as a consequence we accidentally dropped the modifiers from
those keys (refs: https://github.com/wez/wezterm/issues/213 refs:
https://github.com/wez/wezterm/issues/214).

This commit restores the modifiers for that case.

In addition, since we now have a way to plumb configuration directly
into the term crate, this adds a config option to enable CSI-u for those
that want to use it.
2020-06-10 17:07:30 -07:00
Wez Furlong
afe0475ced term: improve support for AnyEvent and non-SGR mouse reporting
refs: https://github.com/wez/wezterm/issues/211
2020-06-10 12:00:14 -07:00
Wez Furlong
9c9933039d term: implement RIS Full Reset sequence
refs: https://github.com/wez/wezterm/issues/211#issuecomment-642056005
2020-06-10 08:38:04 -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
fd512da983 term: improve iterm2 image pixel->cell calculation
If the image is smaller than the cell size we could end up
rounding that dimension to zero and ultimately not render
the texture to the cell.

This commit adjusts the math to round up, which yields
better results for the test in refs: https://github.com/wez/wezterm/issues/211
2020-06-08 18:02:51 -07:00
Wez Furlong
42e2775f36 wezterm: more fun with SS3 vs CSI and cursor key encoding
I noticed that we still weren't quite right.
I think the net change is really just that we must force
the use of the CSI representation when using CTRL/SHIFT
modifiers.

refs: https://github.com/wez/wezterm/issues/203
2020-06-01 18:59:18 -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
cb3606d130 term: remove TerminalHost from api
This simplifies a bunch of things
2020-05-30 07:53:50 -07:00
Wez Furlong
b8acbac113 wezterm: add ClearScrollback key assignment
Bound to CMD-K and CTRL+SHIFT-K by default.  This also functions
while the output is filling up (eg: `find /` and hit the key binding
to keep pruning the scrollback).

closes: https://github.com/wez/wezterm/issues/194
2020-05-25 17:29:22 -07:00
Wez Furlong
33e387be7d term: implement EraseInDisplay::EraseScrollback
refs: https://github.com/wez/wezterm/issues/194
2020-05-25 17:13:08 -07:00
Wez Furlong
b67682ddc9 wezterm: move most click related mouse events to InputMap
The click/movement related events are now "table driven" with
defaults contained in the InputMap object.

This gives the the potential to be configured from the config
file, but there is not glue in the config layer to enable
this yet.

This also does not include mouse wheel events.
2020-05-21 18:51:20 -07:00
Wez Furlong
b00f383f2b Suppress logging about CSI 8 Y ; X t
neovim will try to force the window to resize after suspend/resume.
No other terminal allows this today, so rather than log it as an
unhandled event, explicitly ignore it.
2020-05-16 09:56:43 -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
ea401e1f58 term: add implicit SGR reset when switching alt screen
This was a bit of a pain to track down because this behavior
isn't specified anywhere or called out explicitly.

The issue is that if you use a true color escape sequence such as

```bash
printf "\x1b[38;2;255;100;0mTRUECOLOR\n"
```

the active color would remain active when switching between the
primary and the alt screen until something (eg: `ls --color`) changed
it again.

I hadn't run into this because in my prompt, many many years ago, I had
it set to perform an SGR reset (`\x1b[0m`) as the first thing to ensure
that the shell is in a saner state.

For users that don't do this they end up with a weird looking color
bleed effect.

refs: https://github.com/wez/wezterm/issues/169
2020-04-18 19:26:54 -07:00
Wez Furlong
5b700e4d5d wezterm: recognize MS terminal mode 25 for cursor visibility 2020-04-06 13:19:44 -07:00
Wez Furlong
54cc62ccf9 ctrl-space should send NUL 2020-03-28 18:32:20 -07:00
Wez Furlong
013288b1ef mux: grey out the terminal contents when tardy
The predictive echo feels pretty reasonable, but if the connection
is having problems and we're showing the tardiness indicator, the
echo can give the impression that your input is going to get processed.
That may not be (usually is not!) the case.

This commit makes it a bit more visually distinctive that something
isn't right by greying out the color palette in that case.

refs: https://github.com/wez/wezterm/issues/127
2020-03-14 08:57:35 -07:00
Wez Furlong
50caecfd9d fixup term tests for set_title cleanup 2020-01-26 10:02:07 -08:00
Wez Furlong
f41d82a254 remove some dead TerminalHost code 2020-01-26 08:55:56 -08:00
Wez Furlong
ee70ec3ae0 Add support for OSC 104 (ResetColors) 2020-01-26 08:26:01 -08:00
Wez Furlong
f125bd863a remove dead click_link method from terminal host
This is now handled by the gui layer
2020-01-25 23:17:45 -08:00
Wez Furlong
6ddf9ec3dd default dec auto wrap mode to on 2020-01-25 22:28:45 -08:00
Wez Furlong
1bb39835c0 vttest: respect dec auto wrap mode
refs: https://github.com/wez/wezterm/issues/133
2020-01-25 20:49:39 -08:00
Wez Furlong
2de60e3791 vttest: handle dec origin mode
This makes us pass the cursor positioning tests
(with the exception of the 132 column mode)

refs: https://github.com/wez/wezterm/issues/133
2020-01-25 20:35:33 -08:00
Wez Furlong
9d63d30fc0 vttest: make the E's show up on the cursor positioning test
Refs: https://github.com/wez/wezterm/issues/133
2020-01-25 20:20:31 -08:00
Wez Furlong
e45bace9eb shift-space now emits space
This isn't a 100% righteous fix, but is sufficient to reduce
the irritation in refs: https://github.com/wez/wezterm/issues/126

The full fix is pending another round of review of the CSI-u stuff
in refs: https://github.com/wez/wezterm/issues/63
2020-01-23 23:29:42 -08:00
Wez Furlong
4b455288dd track the full current dir URL for OSC 7
Matching against the current dir when it includes a host and a
path seems like a handy way to automate selecting appropriate
theme/color/profile settings, so I'd like to make sure that
we have the full URL content available for that.

Refs: https://github.com/wez/wezterm/issues/115
Refs: https://github.com/wez/wezterm/issues/117
2020-01-14 22:06:13 -08:00
Wez Furlong
41162f4361 fixup tests for the previous change
(also makes it easier to debug test failures without RUST_BACKTRACE=1)
2020-01-12 11:40:42 -08:00
Wez Furlong
e1f1f9cbd6 improve cursor positioning after a resize
The rewrap logic makes dealing with the cursor position a bit
more complex and we had a problem where resizing the window shorter
and then taller would allow the shell to cursor up into the scrollback
when displaying its prompt, and allow it to overwrite something that
was logically in the scrollback.
2020-01-12 10:15:53 -08:00
Jeremy Fitzhardinge
71eb27ccb5 Add get_current_working_dir to Tab 2020-01-11 18:25:17 -08:00
Jeremy Fitzhardinge
b53412d0cb Track current working dir via OSC 2020-01-11 18:25:17 -08:00
Wez Furlong
2e581252c1 refine vertical size adjustments when resizing the terminal 2020-01-11 09:40:36 -08:00
Wez Furlong
d91e384a7e improve cursor position adjustment on resize
Avoids accidentally moving the y position of the cursor; previously
we would keep it pinned to the physical viewport relative coordinate,
but we didn't account for the implicit scroll that happens when
making the window smaller, which meant that the shell would re-render
its prompt with some artifacts during a resize.
2020-01-11 08:44:28 -08:00
Wez Furlong
e13b4f7dc9 remove dead code
This logic has all moved to the render layer
2020-01-11 08:34:01 -08:00
Wez Furlong
afbd262740 rewrap: tweak how we consider row count 2020-01-11 08:08:42 -08:00
Wez Furlong
e6b4aa835a re-wrap lines when resizing
Adds logic to resize handling that will consider the original logical
line length when the width of the terminal is changed.

The intent is that this will cause the text to be re-flowed as if it had
been printed into the terminal at the new width.  Lines that were
wrapped due to hittin the margin will be un-wrapped and made into a
single logical line, and then split into chunks of the new width.

This can cause new lines to be generated in the scrollback when
making the terminal narrower.  To avoid losing the top of the buffer
in that case, the rewrapping logic will prune blank lines off the
bottom.

This is a pretty simplistic brute force algorithm: each of the lines
will be visited and split, and for large scrollback buffers this could
be relatively costly with a busy live resize.  We don't have much choice
in the current implementation.

refs: https://github.com/wez/wezterm/issues/14
2020-01-11 00:10:25 -08:00
Wez Furlong
4765ce60e5 mux: avoid overly aggressively dirtying lines
Still not perfect; there's a window invalidation missing from
the mux somewhere on higher latency connections that gets
resolved just by moving the mouse :-/
2020-01-09 06:39:00 -08:00
Wez Furlong
4687b3bb48 clippy 2020-01-05 15:14:32 -08:00
Wez Furlong
89f2023577 mux: invalidate StableRowIndex 0..rows when switching alt screen
We would leave a copy of the alt screen lines at the top of the
scrollback.

This commit ensures that those lines are marked dirty and that
the dirty bits are propagated to the client to invalidate its cache.
2020-01-05 15:07:00 -08:00
Wez Furlong
55e4050aa3 use LastMouseClick for paste click counting 2020-01-05 14:37:17 -08:00
Wez Furlong
6183434bda Track viewport in the gui layer
Use StableRowIndex to implement tracking the viewport in the gui layer.
This resolves an issue where a busy terminal would continue to scroll
through the scrollback when you were paging backwards and look weird.

There's still some cleanup though:

- This breaks the selection ui
- the cursor position is wrong when scrolling back
- shift-pageup/pagedown need to be processed in the gui layer

Refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
1b3ced2ab3 Add StableRowIndex concept
This will make it easier to manage both the viewport and the
selection in the gui layer.

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
a0ad0d0c34 terminalstate: remove middle click paste handling
This is safely performed 100% by the gui layer now.
2020-01-05 14:37:17 -08:00
Wez Furlong
5ba0c70cdb add Tab::is_mouse_grabbed concept
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
f0e94084d1 change backspace/delete handling
Previously we would try to pass through the Backspace and Delete
code points without interference, but that behavior wasn't quite
right.

With this commit our behavior is now:

- At the window layer: Classify a `Backspace` key press as logically
  `BS` and a `Delete` key press as logically `DEL` unless the
  `swap_backspace_and_delete` is true (macOS is true by default), in
  which case `Backspace` is mapped to `Delete` and vice versa.

- At the terminal input layer: A `Backspace` input from the Window sends
  the `DEL` sequence to the pty as that matches the default `VERASE` stty
  configuration.  A `Delete` input from the Window emits `\033[3~`,
  which matches up to the `TERMINFO` for `xterm-256color` which we
  claim to be compatible with, and is our default `$TERM` value.

The net result of this is that `Backspace` will now start to emit `^?`
which should match folks stty verase.   Heads up to @fanzeyi!

I've tested this only on a linux system so far and will follow up on
a macOS system a little later today.

Refs: https://github.com/wez/wezterm/issues/88
Refs: https://github.com/wez/wezterm/issues/63
2019-12-30 08:14:20 -08:00
Wez Furlong
682bb0d3fd add missing comment 2019-12-28 08:37:19 -08:00
Wez Furlong
68a2d9f159 Adjust default scroll thumb color
I think #222 looks much cooler than #444
2019-12-23 18:08:15 -08:00
Wez Furlong
f350b24220 fix tests 2019-12-23 14:52:49 -08:00
Wez Furlong
aac93e7f0a Improve palette handling w/ live config reloading
@fanzeyi ran into part of this issue when using multiplexing;
tabs from a remote domain always used the default color scheme
rather than the local configuration file color scheme.

Another variation on this is that making changes to the `[colors]`
section of the config only impacts tabs created after the change
was loaded, rather than updating the running tabs.

The root of this was that each terminal was keeping its own
copy of the palette that was updated at creation time to reflect
the config file.  Relatively recently I introduced a new trait
to allow the terminal state to reach out and obtain configuration
from another source.

This commit connects the terminal configuration layer to the
configuration file directly.

The color schemes are now pulled directly from the configuration
file, except in the case where a dynamic color scheme has been
applied: using escape sequences to change the colors causes
the palette to be forked away from the configuration file.

There's still a low pri TODO around this space: if we're connected
to a remote domain and someone uses dynamic color scheme escapes,
should we reflect those locally?  If so then we'll need to build
some plumbing to transport the palette to/from the remote system.

Closes: https://github.com/wez/wezterm/pull/60
2019-12-23 14:19:48 -08:00
Wez Furlong
f28d9e994f Enable mouse interaction with scroll bar
This commit:

* Removes the ability to drag the window by the tab bar.  I added
  that in anticipation of needing to do custom title bar dragging
  with Wayland, but it turned out both to be not required and not
  possible to drag windows around in that way.
* Replaces the drag logic with dragging the scrollbar thumb
* Clicking above the scrollbar thumb is equivalent to page up
* Clicking below the scrollbar thumb is equivalent to page down
2019-12-22 22:01:00 -08:00
Wez Furlong
ec609a2e41 Add optional scroll position UI
This commit adds a scrollbar that shows the scroll position but
that does not currently allow dragging to scroll.

The scrollbar occupies the right hand side window padding.

The width of the scrollbar can be set by explicitly configuring
`window_padding.right`.  If the right padding is set to 0 (which
is its default value), and the scroll bar is enabled then the cell
width will be used for the right padding value instead.

The scrollbar can be enabled/disabled via this config setting:

```
enable_scroll_bar = true
```

Its color by this:

```
[colors]
scrollbar_thumb = "#444444"
```

(Note that color palette config will be reloaded when the config
file is changed, but you'll need to spawn a new tab/window to
see the effects because we cannot assume that a config reload should
always replace a potentially dynamically adjusted color scheme in
a tab).
2019-12-22 20:12:56 -08:00
Wez Furlong
c961f934f2 renderer now renders different cursor styles
refs: https://github.com/wez/wezterm/issues/7
2019-12-22 13:08:57 -08:00
Wez Furlong
8135ce46a5 Blink the cursor when it is set to blink
The blink rate is configurable via a new option.

Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 10:08:31 -08:00
Wez Furlong
986095e6f5 connect DECTCEM to the stored cursor shape
We don't render the different types of cursor yet, but at least we're
tracking what it should be.
2019-12-22 09:07:34 -08:00
Wez Furlong
5abc4e543e rendering now respects cursor visibility
This commit adds some plumbing for describing the cursor shape
(block, line, blinking etc) and visibility, and feeds that through
the mux and render layers.

The renderer now knows to omit the cursor when it is not visible.
2019-12-22 08:52:51 -08:00
Wez Furlong
f493139305 clippy 2019-12-21 23:13:26 -08:00
Wez Furlong
9a2c7a1485 failure -> anyhow + thiserror 2019-12-14 21:43:05 -08:00
Wez Furlong
901dc9c395 re-structure clipboard handling for mux
The wayland changes rendered clipboard handling for remote multiplexers
broken, and this commit makes it work again.

It removes the clipboard concept from the the TerminalHost and
keeps it separated as the term::Clipboard concept.

The muxer now has plumbing for passing the Clipboard to its idea
of Windows and Tabs and this is hooked up at window creation and
domain attach time.
2019-12-01 13:31:12 -08:00
Wez Furlong
4ef20480c5 wayland: implement clipboard
This was honestly a PITA because of its complexity.  The `clipboard`
crate (now dropped as a dep) didn't support wayland, so I looked at
the `smithay-clipboard` crate, which caused all of my input to become
laggy just by enabling it--even without actually copying or pasting!

Both of those crates try to hide a number of details of working with
the clipboard from the embedding application, but that works against
our window crate implementation, so I decided to integrate it into
the window crate using Futures so that the underlying IPC timing and
potential for the peer to flake out are not completely hidden.

This first commit removes the SystemClipboard type from wezterm
and instead bridges the window crate clipboard to the term crate
Clipboard concept.

The clipboard must be associated with a window in order to function
at all on Wayland, to we place the get/set operations in WindowOps.

This commit effectively breaks the keyboard on the other window
environments; will fix those up in follow on commits.
2019-11-29 12:17:52 -08:00
Wez Furlong
fd78a0b3ce Allow reloading hyperlink rules from the config at runtime 2019-11-24 13:12:54 -08:00
Wez Furlong
7c7825c070 term: extract configuration to a trait
This isn't complete but begins the process of extracting
the embedding application configuration into a trait provided
by the application rather than passing the values in at
construction.

This allows the application to change configuration at
runtime.

The first option to handle this is the scrollback size.
2019-11-24 12:43:41 -08:00
Wez Furlong
517084ff2f clippy 2019-11-24 07:20:41 -08:00
Wez Furlong
d778d8b130 disable csi-u sequences by default
I keep holding shift while pressing space and seeing stuff get
undone in vim.  Super annoying.  I didn't see a good way to
teach applications about this via terminfo, so this is off
by default for now.

refs: https://github.com/wez/wezterm/issues/63
2019-11-23 15:04:54 -08:00
Wez Furlong
6289c08a4e Adopt CSI u modifier encoding for keypresses
See http://www.leonerd.org.uk/hacks/fixterms/ for the specification.

Refs: https://github.com/wez/wezterm/issues/63
2019-11-16 13:38:03 -08:00
Wez Furlong
9e3c6a4ef9 term: simplify key -> escape sequence mapping
refs: https://github.com/wez/wezterm/issues/63
2019-11-16 09:04:55 -08:00
Wez Furlong
ec3690d9c1 allow alt + punctuation
I noticed that alt-. wasn't working; it was an unintended
casualty of 03f51f7be2
2019-11-05 21:12:19 -08:00
Wez Furlong
11137aa613 alt + arrow keys 2019-11-05 20:14:49 -08:00
Pedro Rittner
579da93ded Support GNUReadline-style Alt-Backspace
Alt-Backspace is the GNUReadline-style shortcut for kill-previous-word.
In wezterm, this currently doesn't work, since this gets trapped by the generic `Backspace` match case.
This diff adds a more specific case for when Backspace is combined with Alt to produce the correct sequence.

This is definitely a hack and there should probably be a more general solution for GNUReadline combinations, but this solves the immediate problem.
2019-11-05 10:33:22 -08:00
Wez Furlong
1ab438c1e2 improve emoji width calculation
I noticed while scrolling `emoji-test.txt` that some of the combined
emoji sequences rendered very poorly.  This was due to the unicode
width being reported as up to 4 in some cases.

Digging into it, I discovered that the unicode width crate uses a
standard calculation that doesn't take emoji combination sequences
into account (see https://github.com/unicode-rs/unicode-width/issues/4).

This commit takes a dep on the xi-unicode crate as a lightweight way
to gain access to emoji tables and test whether a given grapheme is
part of a combining sequence of emoji.
2019-11-05 08:45:08 -08:00
Wez Furlong
a9bdca6d84 bump up to latest unicode segmentation crate 2019-11-04 22:12:21 -08:00
Wez Furlong
03f51f7be2 macos: fix alt+<ascii> key being passed to terminal
This was an unintended casualty of the recent gui layer refactoring.

If you press `option-h` macos generates DOT ABOVE which we pass through
to the terminal key processing layer.  It sees that ALT is set and emits
an escape byte (to indicate that ALT is set) followed by the UTF-8
sequence for DOT ABOVE.  `zsh` gets confused and treats this as
`<ffffffff>` in its line editor.

This diff restricts the emission of the ESC leader to ascii alphanumeric
characters only.

There needs to be a followup diff to allow configuring how we process
these ALT modified characters on macOS because our current behavior
breaks eg: `ALT-1` which is a hotkey that I use in tmux.  Granted that
I don't need tmux with end to end wezterm, but it does prevent me from
using that if I wanted to.
2019-11-04 18:46:40 -08:00
Wez Furlong
155a972425 add missing selection normalize calls
I saw

```
thread 'main' panicked at 'you forgot to normalize a SelectionRange', term/src/selection.rs:94:9
```
2019-11-03 22:01:35 -08:00
Wez Furlong
d80169ceff Avoid accidental application mode delete output in key processing
I thought that I'd broken something with the DEL processing in vim with
the new frontend but it turned out that the other frontend was emitting
BS always and that I'd actuall unbroken passing DEL through and that
other layers were translating DEL into an application cursor mode output
for DEL that emits a totally different sequence.

This diff preserves DEL and disables that other sequence.

Will follow up with some explicit configuration to control this
behavior, but in the short term, the default behavior should be much
closer to what people actually want and expect!

refs: https://github.com/wez/wezterm/issues/52
2019-10-27 23:59:15 -07:00
Wez Furlong
04d6fed848 fixup tests for recent api changes 2019-10-27 09:04:42 -07:00
Wez Furlong
12e71a594a teach the terminalstate about pixel sizes
This allows more accurate slicing of images when processing
iterm2 image sequences
2019-10-26 23:58:39 -07:00
Wez Furlong
d97a84f984 render iterm2 image protocol in the software renderer
This is still a bit rough because the terminal parser doesn't
understand the pixel sizes, so it relies on the hard coded
cell dimensions being accurate.
2019-10-26 23:30:39 -07:00
Wez Furlong
71b4f52e5e clippy 2019-10-26 13:22:16 -07:00
Wez Furlong
c30ffc2226 prevent terminal from sizing to 0 rows or cols 2019-10-26 12:36:18 -07:00
Wez Furlong
52a65370fa cargo fmt with rust 1.38 2019-09-28 21:40:40 -07:00
Wez Furlong
950a7d2b22 cargo fix dyn 2019-09-28 20:29:48 -07:00
Wez Furlong
5440cbe521 replace vte with our own vtparse crate
This enables using large OSC buffers in a form that we can publish
to crates.io without blocking on an external crate.  Large OSC
buffers are important both for some tunnelling use cases and for
eg: iTerm2 image protocol handling.
2019-06-29 16:28:39 -07:00
Wez Furlong
49894385dd update tests for clipboard changes 2019-06-21 09:12:01 -07:00
Wez Furlong
e993e5a625 allow capturing the clipboard impl from the terminal host
This should allow asynchronous access to the clipboard, which
in turn will allow the server to send the clipboard to the client
unilaterally.
2019-06-20 07:55:03 -07:00
Wez Furlong
764597851c allow collapsing mouse events in the mux protocol
Repeated moves or wheel events are collapsed so that we don't clog up
the queue.  The queue size doesn't matter as much as the latency of
processing a large queue.  For fast or repeated moves the queue can grow
rather quickly, and with what is currently ~25-50 ms round trip per
entry for a remote session, that is a poor UX.
2019-06-16 21:04:53 -07:00
Wez Furlong
302db2c976 a lighter way to pass selection ranges for client tabs 2019-06-16 21:04:53 -07:00
Wez Furlong
d061303bb4 don't forget to copy in the configured color palette! 2019-06-16 14:49:54 -07:00
Wez Furlong
86cd39eb4e we can now send input to a client tab 2019-06-09 16:33:57 -07:00
Wez Furlong
b43c207167 remove defunkt write_all function
This was from a time when we were miusing non-blocking io
2019-06-09 07:36:30 -07:00
Wez Furlong
8055957406 clippy 2019-06-09 07:33:00 -07:00
Wez Furlong
5bf2268292 more log changes 2019-06-08 15:30:47 -07:00
Wez Furlong
99919dc807 implement answerback for osc 4, 10-18
These codes are used to change the color palette, but if the `?`
string is used in place of a color spec, then we must respond with
the current color value string for that palette entry, so lets
implement that!
2019-06-02 12:19:58 -07:00
Wez Furlong
8f8d03fc05 support osc 10-19 dynamic color changing 2019-06-01 21:47:25 -07:00
Wez Furlong
276e9aef91 osc 4 accepts multiple parameters 2019-06-01 19:59:44 -07:00
Wez Furlong
4193442ec8 make OSC 4 actually change the palette 2019-06-01 16:15:37 -07:00
Wez Furlong
6e4db86f7e add palette to the terminal state 2019-06-01 15:55:08 -07:00
Wez Furlong
d18dbe9ff7 parse OSC 4
This code is used to change the color palette at runtime.
We can parse it but not do anything useful with it yet.
2019-06-01 15:39:46 -07:00
Wez Furlong
98bd82e212 bump some deps 2019-05-27 20:08:30 -07:00
Wez Furlong
0bb3714435 improve double-click selection of wrapped lines
This one has been bugging me for a while; we now know when we've
wrapped a line and can join it without a line break when double-clicking
to select a word.

This commit introduces a wrapped attribute to help record this
information, which could potentially help with when it comes
to looking at nicer resize behavior in refs: https://github.com/wez/wezterm/issues/14
2019-05-26 16:05:51 -07:00
Wez Furlong
09f168a0db plumbing for double click selection of wrapped lines 2019-05-26 14:52:03 -07:00
Wez Furlong
038100922a clippy 2019-05-26 12:49:10 -07:00
Wez Furlong
607e180122 Range::contains is now stable; use it. 2019-05-26 11:40:33 -07:00
Wez Furlong
f87901c484 tidy up some failure usage 2019-05-26 08:58:59 -07:00
Wez Furlong
8a76f27f9b remove some extern crates
These got overlooked when migrating from 2015->2018 edition syntax.
2019-05-26 08:27:43 -07:00
Wez Furlong
b83656b378 bump image crate dep
This avoids compiling two different versions of image
2019-05-26 08:13:24 -07:00
Mark Thomas
fb636995c8 separate application cursor keys
Application cursor keys are a separate set of encodings that applications can
ask the terminal to produce for cursor keys.

Unfortunately, PuTTY generates these for shift-modified cursor keys.  If an
application is to distinguish between normal and shift-modified cursor keys
on PuTTY then it will need to be able to distinguish between normal and
application cursor keys.

Add new `KeyCode` variants for application cursor keys.
2019-05-18 09:12:46 -07:00
Wez Furlong
acc895f1cd avoid deadlock while pasting large chunks of text
A big paste could saturate the input/output of the pty and
lead to an effective deadlock; the application wants to send
output to us but we are busy trying to write the paste to it.

Break up large pastes into chunks and send them piece by piece.
This does mean that a large bracketed paste is not an atomic
unit any longer, but it seems to work out ok when pasting into
vim.
2019-03-23 15:25:49 -07:00
Wez Furlong
3777da13d2 fix deprecation warnings 2019-03-22 22:17:54 -07:00
Wez Furlong
fa9bf57e86 fix line feed movement behavior
We were incorrectly treating it as \r\n, but it should only have
been moving vertically.

This fixes the positioning of the cursor when using eg:

`dialog --yesno hello 0 0`

Without this change, the cursor would be way over to the left.
With this change, the cursor is correctly positioned inside
the "YES" box.
2019-03-22 22:14:17 -07:00
Wez Furlong
49467515d6 when erasing the display ensure line size matches physical
In the case where the screen was enlarged, we don't eagerly resize
the line vectors.

If a subsequent erase display occurred, we'd only erase to the old
size of the lines, rather than the new size, which could result
in a black square in the upper right corner of the display.

Repro scenario is:

* resize window larger than initial height
* `dialog --yesno hello 0 0`

The dialog background should fill the display.
2019-03-22 21:59:54 -07:00
Wez Furlong
cbc1462bb4 fix color of erased characters
This was responsible for eg: dialog rendering a black (or whatever
the default background color was) strip behind the text in an
invocation like:

`dialog --yesno hello 0 0`

Rather than render a default cell, render a blank cell using the
current pen.
2019-03-22 21:45:51 -07:00
Wez Furlong
54324121f2 implement basic DEC Line drawing mode
This improves the rendering of eg: `dialog`
2019-03-22 21:28:42 -07:00
Wez Furlong
222e278720 adopt OneBased type for a number of row/col escape sequences 2019-03-22 20:41:50 -07:00
Wez Furlong
29c7610ead add OneBased helper 2019-03-22 20:41:50 -07:00
Wez Furlong
e68bf65b2f clean up some of the newer escape sequence processing 2019-03-22 20:41:50 -07:00
Wez Furlong
3003654cc8 fix apt upgrade scrolling issue
This was an off-by-one issue when using scroll margins just shorter
than the screen and when scrollback is enabled.

Added a unit test to verify the behavior.
2019-03-22 20:41:50 -07:00
Wez Furlong
6cbb3ba432 impl IRM insert mode and improve esctest conformance
I've had mixed results with esctest; the IRM and cursor save/restore
tests fail for me in terminal.app, iterm2 and xterm, and fail in the
same way on wezterm, so I'm not sure if I'm not running those tests
correctly.  However, they did encourage the discovery of some other
real issues in the wezterm emulation.
2019-03-22 20:41:50 -07:00
Wez Furlong
9702d1cf5a Add plumbing for running esctest 2019-03-22 20:41:50 -07:00