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

239 Commits

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