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

612 Commits

Author SHA1 Message Date
Wez Furlong
225e7a1243 introduce unicode_version config
This is a fairly far-reaching commit. The idea is:

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

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

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

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

I expect to raise that default version in the future.

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

refs: #1231
refs: #997
2021-11-25 09:00:45 -07:00
Luis Javier Merino Morán
65e2c1f914 Fix DECRPTUI response
DECRPTUI, the response to DA3, should be:
 DCS ! | D...D ST
not
 CSI = D...D ST
2021-11-21 07:49:35 -08:00
Wez Furlong
24875004f6 add canonicalize_pasted_newlines config option
refs: #1213
2021-10-17 13:14:16 -07:00
Wez Furlong
d461c1c0b6 deps: lru 0.6 -> 0.7 2021-10-10 19:29:42 -07:00
Wez Furlong
0ee1f7529b fonts: Fix shaping metrics
This was a bit of a PITA to run down; the essence of the problem
was that the shaper was returning an x_advance of 0 for U+3000,
which caused wezterm's shaping layer to elide that glyph.

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

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

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

This:

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

Now correctly renders on screen as "x  x".

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

refs: #892
2021-09-12 09:30:14 -07:00
Greg V
ce5615082c gui: cancel mouse click streak when the cursor has moved to a different cell (fixes #910)
Fast-clicking users generally expect to be able to rapidly do regular selections
or otherwise cancel double/triple/quad clicks, so significant mouse movement should end the streak.

Allowing tiny pixel movements to account for touchpads is necessary.
Fortunately, the position here is already in character grid cells, which provides enough margin for this.
Other code editors like gedit also seem to do this based on the character grid.
2021-09-08 17:38:59 -07:00
Wez Furlong
545a8fc8a7 deps: ordered-float -> 2.8 2021-09-05 23:25:37 -07:00
Wez Furlong
311bd78902 Fix SU (scroll up) using default-blank cells
closes: https://github.com/wez/wezterm/issues/1102#
2021-09-04 17:35:33 -07:00
Wez Furlong
67e8bdc5c2 term: fix DCH removing cells instead of setting to current bg color
refs: #789
2021-09-03 16:21:15 -07:00
Wez Furlong
c5d1f67853 term/termwiz: move key encoding to termwiz
This will enable eg: a lua helper function to serialize keycodes to
assist in some key rebinding scenarios (see:
https://github.com/wez/wezterm/pull/1091#issuecomment-910940833 for the
gist of it) but also makes it a bit easier to write unit tests for key
encoding so that situations like those in #892 are potentially less
likely to occur in the future.
2021-09-03 11:12:42 -07:00
Wez Furlong
24d971c87d Defend against crazy big images sent via iterm image protocol
This also handles a Nan case and allows us to survive term-crash-tests as of fb6fa3192a65e8862c3c743ba102f7e2af45b519

refs: https://github.com/wez/wezterm/issues/1031
2021-08-16 23:44:31 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
aa9cbd4552 refactor: update a couple of callers to Cell::blank 2021-08-15 15:42:35 -07:00
Wez Furlong
6f78ee4f14 deps: update unicode-segmentation to 1.8 2021-08-11 23:06:17 -07:00
Wez Furlong
6c2f9f2d18 term: restore line length pre-allocation
A while back I made the line lengths lazily grown; the reduction
in memory was nice, and it helped with render performance for
really wide screens.

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

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

Make blank TeenyString and Cell initializations const.
2021-08-11 23:06:17 -07:00
Wez Furlong
1e7c7e7059 term: micro optimize flush_print: directly call grapheme_column_width
Saves an additional call through unicode segmentation
2021-08-11 23:06:16 -07:00
Wez Furlong
80d261977f term: avoid dirtying lines when the cursor moves
Tag CursorPosition with the seqno of the cursor move instead.
This should avoid over-invalidating lines and the selection
if it was just the cursor that moved.
2021-08-08 22:47:10 -07:00
Wez Furlong
eae327efcc model: replace LineBits::DIRTY with a sequence number
Terminal now maintains a sequence number that increments
for each Action that is applied to it.

Changes to lines are tagged with the current sequence number.

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

refs: https://github.com/wez/wezterm/issues/867
2021-08-08 12:45:08 -07:00
Wez Furlong
6d9957e6e3 term, gui: allow tracking multiple buttons
We were previously only remembering the most recently pressed
button, but that's a lossy thing to do.

This commit remembers the button presses so that we can correctly
report all press/release events.

refs: #973
2021-08-07 18:37:38 -07:00
Wez Furlong
6a7e6596b9 kitty img: make allowances for permanence of image attachments
An implementation detail in wezterm is that it doesn't model
image placements as a separate entity; they are all bound to
the image cells in the terminal model.

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

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

refs: #986
2021-08-06 09:01:18 -07:00
Wez Furlong
3ea13fb530 kitty img: tidy up blit and bounds check, skip 0 duration root frame 2021-08-05 23:59:35 -07:00
Wez Furlong
815e24c24d kitty img: slightly improve protocol responses
Make a helper function for these, but there is still room
for improvement.

refs: #986
2021-08-04 13:53:54 -07:00
Wez Furlong
f3d4b59139 kitty img: flesh out some todos with anim composition
refs: #986
2021-08-04 13:31:18 -07:00
Wez Furlong
a726a170ff kitty img: support for removing all placements
and do that when the terminal is reset

refs: #986
2021-08-04 09:15:09 -07:00
Wez Furlong
6d702275df kitty img: don't move the cursor when requested not to
We were actually moving it during placement, and then restoring
the original placement.  That could potentially lead to the
screen being scrolled, so we want to avoid that.

refs: #986
2021-08-04 09:14:58 -07:00
Wez Furlong
02b5defac1 kitty img: parse and implement basic anim frame composition
This is just enough for notcurses-demo to run, and is definitely
missing various cases.

refs: #986
2021-08-03 21:57:27 -07:00
Wez Furlong
0c5753eb58 kitty img: round out support for animation frame parameters
As of this commit, `kitty +kitten icat ~/Downloads/fast-parallax.gif`
(wherein the icat kitten decodes the gif into frames and sends them
to the terminal to animate) behaves equivalently in wezterm and kitty.

(There appears to be an issue with the background color/deltas in
the icat kitten in kitty-0.21.1-1.fc33.x86_64 which I have installed,
so both wezterm and kitty have a funky black background for this
particular gif).

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

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

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

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

refs: #986
2021-08-02 09:18:25 -07:00
Wez Furlong
7f9d96328c kitty img: parser support for animation frame transmission
refs: #986
2021-08-01 23:33:27 -07:00
Wez Furlong
0f5494db98 refactor: split terminalstate into modules
Long overdue!  Move the various image protocols into their own files,
and the performer too!
2021-08-01 20:51:36 -07:00
Wez Furlong
1f49147560 kitty img: prune unreferenced images when RAM utilization is high
This adds a simple garbage collection scheme; when adding an image,
check to see if we're over budget on the total amount of RAM used
by the image data.

If we are, remove unreferenced images (images that are not placed)
until we're below the budget.

refs: #986
2021-08-01 15:43:48 -07:00
Wez Furlong
4d5d5a7516 kitty img: fix deletion by image_id with no placement_id
refs: #986
2021-08-01 15:12:29 -07:00
Wez Furlong
94d409d340 prefer to hold rgba8 rather than png data for kitty, sixel
I noticed when running the notcurses demo that we're spending a
decent amount of time decoding png data whenever we need to
re-do the texture atlas.

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

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

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

refs: #986
2021-07-31 14:03:27 -07:00
Wez Furlong
fb9338f0e7 default disable kitty graphics until support is improved
You can run `wezterm --config enable_kitty_graphics=true` to do ad-hoc
tests with the protocol enabled.

refs: #986
refs: #1998
2021-07-31 10:23:44 -07:00
Wez Furlong
71e88a4fea conceptually allow for multiple image attachments in a cell
refs: #986
2021-07-29 19:41:52 -07:00
Wez Furlong
96f15a065c kitty img: add deflate support
Untested... it compiles!

refs: #986
2021-07-28 09:29:40 -07:00
Wez Furlong
62cc64f293 incomplete, basic implementation of kitty image protocol
This isn't complete; many of the placement options are not supported,
and the status reporting is missing in a number of cases, including
querying/probing, and shared memory objects are not supported yet.

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

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

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

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

refs: #986
2021-07-28 09:04:52 -07:00
Wez Furlong
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