1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-26 06:42:12 +03:00
Commit Graph

1650 Commits

Author SHA1 Message Date
Wez Furlong
a5ece82d69 fix compilation on macos
refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:31:02 -08:00
Wez Furlong
6787512d62 avoid busy looping over the spawn queue
Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:20:59 -08:00
Wez Furlong
824ec691fe revise ratelimit_output_bytes_per_second default
I've found that 10_000/s strikes a reasonable balance between
output speed and the ability to interrupt the output.

Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:20:30 -08:00
Wez Furlong
06da330087 add low pri spawn queue
Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:20:17 -08:00
Wez Furlong
b3032f8a5a window: macos: yes starvation fix
Similar to b83a63126c, this helps
to avoid starving the gui events.

Refs: Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 17:34:01 -08:00
Wez Furlong
6461dc15f0 ci: nightly rust isn't installable and is broken
I can't install it locally either, so let's just turn it
off in the CI
2019-11-22 01:20:02 +00:00
Wez Furlong
b83a63126c fix a starvation issue on linux/x11 systems
The `SpawnQueue::run_impl` would loop until it had exhausted
all queued items.  This prevents returning to the main loop
and resulted in the UI hanging while eg: `yes` was running,
and could also block accepting keyboard input, which is
pretty bad.

In addition, the queue implementation could fill up a pipe
and block the write side while it held a lock, which in
turn would prevent the read side from making room for the
write to succeed!

This commit changes the behavior on linux to change the wakeup
behavior of the queue from having a 1:1 relationship between
enqueue:wakeup to n:m where n and m are both >= 1.  This is
sufficient to wake a sleeping gui thread.  The gui thread
can then pop and process a single item at a time, interleaved
with dispatching the gui events.

The result is a bit more responsive, however, there is no
backpressure from the gui to the read side, so if the read
side is eating 2MB/s of data and the GUI side is processing
less than this, then an interrupt signal may still take a
few seconds to take effect.

I have mixed feelings about adding backpressure, because
I'm not sure that it is worth actually rendering all of
the parsed output text when there is a lot of it.

I need to follow up and verify these changes on macOS
and Windows too.

Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 16:53:01 -08:00
Wez Furlong
a031b5b9eb improve the rate limiter
when over the budget, this reduces to a trickle of 1 byte per
appropriate sub-second interval.  For example, if the limit is
set to 100 bytes per second, we admit 1 byte every 10ms.

Refs: https://github.com/wez/wezterm/issues/65
Refs: https://github.com/wez/wezterm/pull/67
2019-11-21 14:42:33 -08:00
Wez Furlong
a26a94b5bb config: allow specifying NONE or "" for key modifiers
previously, we would raise an error for these, which made it
awkward to eg: bind just F1 to an action.
2019-11-21 10:25:14 -08:00
Wez Furlong
ac028da1b6 fix an issue with rate limiting data from the child pty
We need to chunk the data that we read from the child otherwise
we may potentially try to admit more data in a single action
than the ratelimiter will ever allow (eg: if we read 4k of data
and the limit is 100 bytes per second, we can never send that
4k of data in a single write).

Our handling of that situation was not good: we'd panic and kill
the background thread that was reading the data, but the rest
of the app was still running.

This commit upgrades to the most recent rate limiter crate
and performs explicit chunking of the output so that we
behave more sanely.

Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 08:36:16 -08:00
Wez Furlong
371e07838d tab bar: set mouse to arrow when in tab bar 2019-11-21 07:08:31 -08:00
Wez Furlong
c6b62d8055 tab bar: default mouse coords outside of view
This helps to prevent a spurious hover styled tab caption being rendered
in some cases.
2019-11-21 00:11:51 -08:00
Wez Furlong
ac7a509dbb allow configuring the tab bar
The defaults are pretty neutral.  You can get a little more fancy
with something like this:

```
[colors.tab_bar]
background = "#0b0022"

[colors.tab_bar.active_tab]
bg_color = "#2b2042"
fg_color = "#c0c0c0"

[colors.tab_bar.inactive_tab]
bg_color = "#1b1032"
fg_color = "#808080"

[colors.tab_bar.inactive_tab_hover]
bg_color = "#3b3052"
fg_color = "#909090"
italic = true
```
2019-11-21 00:04:49 -08:00
Wez Furlong
d716578735 Add optional basic tab UI at the top of the window
This is a little ghetto feeling because we're just stealing the top
line from the terminal model, rather than rendering anything
particularly native, but it is relatively quick and easy to do,
and helps improve the feel when using wezterm on a chromebook
inside crostini; in that environment, the system doesn't render
any text in the window titlebars (WTF!?) so it is desirable
to show something to help navigate the UI.

The tab bar is off by default for now; we'll definitely want to
add options to configure at least the colors, and perhaps add
a keybinding to toggle it at runtime.

```
enable_tab_bar = true
```

While adding support for the tab bar, I found a couple of little
bugs relating to computing the number of rows and columns; one
was during resize where we'd use the prior size instead of
the current size.  Another was during tab spawning where we'd use
a slightly different calculation to determine the size and end
up raising an error about being confused about the screen size.
2019-11-20 21:57:41 -08:00
Wez Furlong
cdc77840b7 Add wezterm.desktop file to the debian package
This makes it a bit more convenient to launch wezterm, especially
on eg: a chromebook
2019-11-20 06:37:32 +00:00
Wez Furlong
d397976acf fix rendering of the cursor position in the line editor 2019-11-16 13:58:01 -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
b79ccb50c4 Add option to swap Backspace and Delete
This defaults to true on macOS

Fixes https://github.com/wez/wezterm/issues/64
2019-11-15 19:52:44 -08:00
Wez Furlong
fccb855837 Document the windows hotkeys
Closes https://github.com/wez/wezterm/issues/34
2019-11-14 22:11:58 -08:00
Wez Furlong
58d4a0a020 remove local workaround for core-foundation UB issue
My fixes landed upstream in 0a3ac83c1b
and are released already to crates.io
2019-11-13 00:05:55 -08:00
Wez Furlong
3ec3caf8f4 fix type in callback definition 2019-11-11 20:23:38 -08:00
Wez Furlong
398f333c32 macos: workaround UB and undefined instruction issue
The compiler emitted `ud2` right around this code, effectively
breaking wezterm on startup.

In talking this through with @dtolnay, the definition of the
structs in the core_foundation crate makes it undefined behavior
to pass a null pointer to its fields, despite that being a valid
and documented way to use the struct.

This commit works around this by defining our own local versions
of the types and functions with the safe signature.

I'll follow up with the owners of the core_foundation crate
to submit an equivalent patch upstream.
2019-11-11 19:10:20 -08:00
Wez Furlong
7323e30be7 try to normalize the shift state in the keymap handling code
We weren't recognizing ctrl+shift+c for example on linux.
2019-11-11 09:11:52 -08:00
Wez Furlong
5370e88520 implement explicit Copy keybinding action
previously we would only ever copy to the clipboard when the selection
was changed.

Now we respect the Copy keypress and have it re-copy the selection
into the clipboard.
2019-11-11 08:54:47 -08:00
Wez Furlong
a83851dcca fix warning 2019-11-11 08:41:59 -08:00
Wez Furlong
e1069e0a7d linux: allow specifying fallback fonts explicitly
previously, if you had defined a list of fonts, we'd show a todo error
and ignore everything but the first entry on linux.

We now parse the list into a set of fontconfig patterns and compose
them together, giving prefernce to the explicitly listed fonts.
(details in the comments in the code).

This allows color emoji to render for user defined fonts without
forcing the user to muck around in fontconfig config.

Added Noto Color Emoji to the fallback; this is used in our
ssh password prompting UI when available.
2019-11-10 00:13:35 -08:00
Wez Furlong
8a07a66e97 refine deps on fedora 2019-11-09 19:46:37 -08:00
Wez Furlong
a26cab3833 add wezterm imgcat subcommand to output images to the terminal
This subcommand parses its input and outputs an iTerm2 compatible
img escape sequence (https://iterm2.com/documentation-images.html)

Usage is straightforward:

```
$ wezterm imgcat  assets/windows/terminal.ico --width "10%" --height "10%"
```
2019-11-09 15:50:59 -08:00
Wez Furlong
3eb1ebf915 GH actions: source cargo env prior to running rustup 2019-11-08 23:07:13 -08:00
Wez Furlong
63c558e281 GH actions -> macos-latest 2019-11-08 22:31:59 -08:00
Wez Furlong
5514a69fa3 tweak GH actions config
update to latest macos release (GH actions are removing 10.14).

Explicitly update the toolchain; some instances are still on 1.38
but the current version is 1.39.
2019-11-08 22:17:15 -08:00
Wez Furlong
15a86b77bd replace most tinyfiledialogs usage with our own prompts 2019-11-08 21:11:22 -08:00
Wez Furlong
86ec66bb6c macos: transmute -> MaybeUninit 2019-11-08 20:35:23 -08:00
Wez Furlong
ea75474650 macos: place windows in the center of the screen
previously we'd place relative to the top left of the screen,
but that looks ridiculous on a 49" ultrawide monitor.
2019-11-08 20:24:26 -08:00
Wez Furlong
6da7b3ecd0 internalized password/auth UI for ssh
This is a bit of a large commit because it needed some plumbing:

* Change mux creation to allow deferring associating any domains,
  and to change the default domain later in the lifetime of the
  program
* De-bounce the empty mux detection to allow for transient windows
  during early startup
* Implement a bridge between the termwiz client Surface and the
  frontend gui renderer so that we can render from termwiz to
  the gui.
* Adjust the line editor logic so that the highlight_line method
  can change the length of the output.  This enables replacing
  the input text with placeholders so that we can obscure password
  input
2019-11-08 19:55:12 -08:00
Wez Furlong
fda9671197 rustfmt 1.39 2019-11-08 18:51:37 -08:00
Wez Furlong
7afd77976a macos: when scheduling timer, schedule first call for later
we were running it immediately which is too soon: the empty
mux check would fire before some of the scheduled jobs would
have run and registered tabs/windows.
2019-11-08 18:50:12 -08:00
Wez Furlong
6c2fbd43db update ssh2 dep 2019-11-08 18:49:31 -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
bc7363465e suppress C build warnings for font related deps 2019-11-05 21:04:37 -08:00
Wez Furlong
3af9a6e626 macos: allow reporting Alt-Backspace
The IME was mapping this to Delete (equivalent to Fn-Delete).
Special casing this allows Alt-Backspace to delete a word in
the shell.
2019-11-06 00:51:12 -08:00
Wez Furlong
b651d8bd61 macos: add missing deleteForward: action
on mac the `Delete` key is really `Backspace` and should generate the
`BS` sequence.

`Fn-Delete` is equivalent to the `Delete` key on other keyboards and
should generate the `DEL` sequence.

BS maps to deleteBackward
DEL maps to deleteForward

heads up to @fanzeyi: this partially reverses 8c26b77057
2019-11-06 00:34:31 -08:00
Wez Furlong
fea35978c4 macos: add un-shifted keycode for raw_key
The NSEvent::charactersIgnoringModifiers method ignores modifiers
except for shift, which is unfortunate because it produces eg: `!`
instead of `1`.

This commit adds a mapping from the underlying `keyCode` to the
corresponding letter position.
2019-11-06 00:18:55 -08:00
Wez Furlong
a9a0f463e6 windows: improve default key bindings
refs https://github.com/wez/wezterm/issues/34

A number of key bindings that used super on macos are also
aliased with bindings that use CTRL+SHIFT for improved
compat with windows.
2019-11-05 22:47:34 -08:00
Wez Furlong
3b93442590 config: add send_composed_key_when_alt_is_pressed option
On macos, allow sending eg: ALT-F as ALT-F rather than the composed
graphics character (ƒ) that is the default for that combination in
the macos IME.

This is controlled by a new config option which defaults to false
so that we have the expected terminal behavior by default.
2019-11-05 22:29:22 -08:00
Wez Furlong
eb1bc7f736 allow binding opt + key based on pre-composed key presses
This diff adds some plumbing to track the `raw_key` in the KeyEvent;
this is the key prior to composing or eg: mapping dead keys.

With that field in place, we can teach the termwindow layer to attempt
looking up that key mapping from the user defined key bindings.

If we get a match then we can stop further key processing.
2019-11-05 21:32:23 -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