With the revised native windows console renderer using the various
console APIs more deeply, I've seen a couple of cases where those
API calls fail inside eg: wezterm running via the new pty machinery.
Using the virtual terminal APIs and the terminfo renderer is the
right thing to do in that case.
This commit probes for virtual terminal support and uses the builtin
xterm terminfo, unless the environment has
`TERMWIZ_BYPASS_VIRTUAL_TERMINAL=1` set. This allows forcing the
use of the windows console layer.
Some windows APIs have inclusive dimensions and some exclusive;
we were off by one for the height of the display which led to some
weirdness with eg: `sp` and the line editor.
When it comes to scrolling: if the scroll request is for the entire
viewport then we simply adjust the viewport; this is desirable because
it allows data to scroll back into the history in the native console.
This fixes the math around cursor positioning for the edge case where
the width of text and the cursor position are close to the width of
the terminal.
This reduces flickering updates in the native windows console;
it works by taking a copy of the screen buffer, applying the
Change's to that buffer and then copying back to the console.
This is unfortunately a bit of a muddy commit and I'm too lazy to split
it up.
* Removed `Position::NoChange`; use `Position::Relative(0)` instead
* Added missing cursor positioning cases in the terminfo renderer
* Taught line editor about the cursor position when the line spans
multiple physical lines
* Taught the Windows input layer to process escape sequences for eg:
the arrow keys when running with virtual terminal enabled.
* Removed the hack that under-reported the terminal width; the hack
was present to make some aspects of rendering with the native windows
console logic easier, but it was getting in the way of the line
editor. This may well break something, but it fixed up the line
editor :-/
cc: @markbt
This commit changes the behavior on Windows:
* If $TERM is set and the `terminfo` crate is able to
successfully initialize and locate a terminfo database (this also
requires that $TERMINFO be set in the environment), then we'll
use the `TerminfoRenderer` instead of the `WindowsConsoleRenderer`
* If $TERM is set to `xterm-256color` and no terminfo database was
found, use our modern compiled-in copy (look in the `termwiz/data/`
directory for the source and compiled version of this) and use
the `TerminfoRenderer`.
* Otherwise use the `WindowsConsoleRenderer`.
In practice, this allows termwiz apps to opt in to features such as
true color support on Windows 10 build 1903 an later by setting their
`TERM=xterm-256color`. This happens to be the default behavior when
`ssh`ing in to a windows host via `wezterm`.
You can see the truecolor mode get applied by running this example:
```
cargo run --example widgets_basic --features widgets
```
with TERM set as above the background region that is painted by the app
will be a blueish/purplish color, but with it unset or set to something
invalid, it will fall back to black.
I'd like to eventually make termwiz assume the equivalent configuration
to `TERM=xterm-256color` by default on Windows 10 build 1903 and later,
but it's worth getting some feedback on how this works for clients such
as `streampager`.
cc: @quark-zju and @markbt
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
This should allow some basic reasoning about how in sync we are with
the remote system.
The immediate application of this is to try to avoid wiggling the
text cursor when the predictive echo updates the position locally.
I need to push this in order to test it on my higher latency setup,
so I don't know if this is totally effective yet.
This is used to indicate timeout/retries during connection establishment
and also to count down to the automatic window close.
The UI will render a progress bar underneath the reason text to show
the passage of time, as well as counting down the provided duration.
Extends the "predictions" to allow for some basic cursor movement
via cursor keys and text deletion.
In addition, show predictions for pasted text.
refs: https://github.com/wez/wezterm/issues/127
This is a mosh-like feature, but not as sophisticated.
The goal is to reduce perceived latency by making a reasonable
guess about how the line where the cursor is located will change
in response to a key press.
At the moment the guess has some very basic heuristics:
* The key is an unmodified (no CTRL, ALT, SUPER) `char` value
* The line containing the cursor doesn't appear to be a
password prompt (using a very simple English specific test)
In those conditions, we'll update the local line cache and cursor
position with how we think the text will appear, but we set the
underline attribute (which is relatively rarely used) to make it clearer
that this is synthetic.
For low latency environments (eg: local network) the underline
rarely appears unless you are able to type very quickly.
I've yet to test this on a higher latency link, but think
this is good enough to land and build out so that I can test
that scenario with my work systems.
refs: https://github.com/wez/wezterm/issues/127
I made this unbounded originally because I wanted to do something
smarter around config reloading. I'm still too lazy to make it
do that, but do recognize that we should have some limit on the
line cache size, so we just pick the value of the scrollback
size at the time we started.
This used to be effectively the same thing, but now that the launcher
menu allows attaching to other domains, it is best if the hotkey
matches the behavior of the + button on the tab bar and uses the
domain of the current tab instead.
* Increase timeout from 2 to 10 seconds, giving you more time to read it
* Make the timeout work even if the UI object is unexpectedly destroyed
* When attaching via the launcher, don't reconnect when the server
version mismatches the client version.
This adjusts the mux protocol so that we can tell when a remote tab
has been closed; previously we couldn't distinguish between an IO
error and the tab going away.
Similarly, if the remote mux has shut down (which we detect via an EOF),
then we won't try to reconnect and will proceed to detach that domain.
Hadn't noticed this until just now because the systems I've been
using have all had a pretty similar filesystem layout.
This commit avoids a failure to spawn a child process when the
desired directory doesn't exist locally.
This is accessible by right-clicking on the `+` button in the tab bar
and switches to an overlay offering options to spawn tabs and attach
domains.
The intent is to allow the configuration file to expand this list of
options, and on Windows, to auto-populate with the various combinations
of `cmd`, `powershell`, `elevated` and available `wsl` instances, but
for the moment the main value of this feature is the ability to attach
domains that were not set to connect automatically at startup.
This makes things more convenient when launching wezterm via the
gui: it is awkward to have to set up shortcuts that run
`wezterm connect foo`, or to type in the full path to `wezterm` when
you might want to run that manually.
Now you can double-click the icon and right-click the `+` and attach
the domain. (cc: @rjwalsh)
The launcher is a good candidate for being implemented on top of
native context menus where available... but we don't have any
such API plumbed through the `window` crate, so all platforms
get the wonderful terminal based overlay menu right now.
refs: https://github.com/wez/wezterm/issues/159
This commit tackles a couple of things in related areas:
Makes it possible to reference the KeyAssignment type directly from the
KeyAction action type. Previously, due to limitations in how TOML is
serialized, the enum values could be used here; while the compiler would allow
it, it is impossible to construct a TOML value for this sort of enum. Now that
we have lua we have more flexibility in the table type and this is unblocked.
In practical terms this means that we can do away with the janky `arg` field
and just use the `action` field directly, which also means that we can do away
with a whole extra enum that duplicates just the enum variants and makes
maintenance easier!
Adds `wezterm.action` to lua which helps to construct these enum variants. The
helper is used like this in the `.wezterm.lua` file:
```lua
local wezterm = require 'wezterm';
return {
keys = {
{key="{", mods="SHIFT|CTRL", action=wezterm.action{ActivateTabRelative=-1}},
{key="}", mods="SHIFT|CTRL", action=wezterm.action{ActivateTabRelative=1}},
}
}
```
the above creates values like `KeyAssignment::ActivateTabRelative(-1)`
in a not totally awful syntax.
On top of this, which was the main reason for doing this work, this
commit adds two new variants to KeyAssignment that are accessible
on from lua (because of the TOML limitations mentioned above);
`SpawnCommandInNewWindow` and `SpawnCommandInNewTab` that take a
`SpawnCommand` struct as their parameter. These actions are
conceptually similar to the existing `SpawnTab` key assignment
but allow specifying the program to be run as well as its cwd
and environment.
For example, this key assignment spawns `top` in a new window:
```lua
{key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={
args={"top"}
}}},
```
The intent is to use this as a building block for saved/canned
commands.
refs: https://github.com/wez/wezterm/issues/159
implementing the `ToLua` and `FromLua` traits allows `create_function`
to automatically apply the appropriate conversions to the parameters
and return values in a callback function.
That makes it possible (and nicer!) to write properly typed callbacks.
Make a reasonable suggestion to the user based on similarity with
possible field names, but don't error out.
This facilitates evolving the configuration over time, and makes
the config more forgiving of typos.