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

1579 Commits

Author SHA1 Message Date
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
Wez Furlong
a9bdca6d84 bump up to latest unicode segmentation crate 2019-11-04 22:12:21 -08:00
Wez Furlong
8c26b77057 macos: fixup IME generated enter and backspace sequences
Rather than \n and bs these need to be \r and del respectively otherwise
we can end up triggering the wrong ctrl based key mappings in a remote
tmux session.
2019-11-04 18:54:41 -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
44d1b031e2 windows: fix ambiguous module import for tests 2019-11-04 09:40:27 -08:00
Wez Furlong
09e70357b3 don't link test executable entrypoint into libpng 2019-11-04 09:40:27 -08:00
Wez Furlong
ceba08cb59 fixup build on windows 2019-11-04 09:40:27 -08:00
Wez Furlong
a199ced513 build libz, libpng, freetype, harfbuzz without cmake
use the cc crate to compile them directly
2019-11-04 09:40:27 -08:00
Wez Furlong
e288ecce7c windows: avoid panic when clicking on links
The `open` crate causes us to recurse into our wndproc and re-borrow,
so avoid that and schedule a separate call later.
2019-11-04 08:56:11 -08:00
Wez Furlong
c8f34aa81b windows: use application icon in window title bar 2019-11-04 08:09:52 -08:00
Wez Furlong
b644b5ac6c windows: bump embed-resource version 2019-11-04 08:01:14 -08:00
Wez Furlong
fdacb4b7bc windows: set the ime position to the cursor position
leveraging the plumbing from the prior commit, this sets the
IME window to the current terminal cursor position.
2019-11-04 00:19:53 -08:00
Wez Furlong
cb5e351187 macos: try to set the IME cursor position a bit better
Use the current terminal cursor position as the basis for the position
of the IME.
2019-11-04 00:11:27 -08:00
Wez Furlong
e3f6375551 fix brightness/color of emoji in the opengl renderer 2019-11-03 22:01:35 -08:00
Wez Furlong
ca5db29695 add a fallback font for chinese text on macos
I'm no expert, but this at least allows me to mash the IME
in pinyin mode and see chinese characters.
2019-11-03 22:01:35 -08:00
Wez Furlong
405cd3be36 fix key repeat with IME 2019-11-03 22:01:35 -08:00
Wez Furlong
23b4876d75 fix an issue with utf-8 in OSC sequences
I've noticed this off and on for a while, and thought it was something
fishy with my shell dotfiles.

Tracing through I found that the final byte in the "Face with head
bandage" emoji 🤕 U+1F915 was being interpreted as the MW control
code and causing the vt parser to jump out of the OSC state.

The solution for this is to hook up proper UTF-8 processing in the
same way that it is applied in the ground state.

Since we don't have enough bits to introduce new state values (we're
pretty tightly packed in the 16 bits available), I've introduced a
memory of the state to which the utf8 parser needs to return once
a complete sequence is detected.
2019-11-03 22:01:35 -08:00
Wez Furlong
40386b964c only print unhandled IME commands 2019-11-03 22:01:35 -08:00
Wez Furlong
ea25055d42 add a couple of missing IME operations -> KeyCode 2019-11-03 22:01:35 -08:00
Wez Furlong
819faa3f85 remove unused get_dpi_scale method 2019-11-03 22:01:35 -08:00
Wez Furlong
8d32bbf49e remove some key debug prints on macos 2019-11-03 22:01:35 -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