Commit Graph
949 Commits
Author SHA1 Message Date
Wez Furlong fa7a007a9f Don't hang when using middle mouse button to paste
A while back I moved the clipboard related processing mostly out
of the term processing code, but since I mostly use the keyboard
for pasting, I'd overlooked the middle mouse button paste flow.

This is problematic because fetching the clipboard requires a
degree of inter process communication and needs the event loop
to be pumped.  Since the terminal callbacks are dispatched from
an event loop callback, attempting to block on the clipboard
future causes a deadlock.

This commit resolves that issue by anticipating that we'll need
the clipboard contents for the majority of middle mouse button
clicks and scheduling a fetch and cache ahead of passing that
event down to the terminal layer.

Why don't we simply use the same technique as the Paste key
assignment?  If the terminal is currently using SGR mouse
tracking mode then the application on the other end of the
pty will want the raw button press.   Our layering doesn't
allow for passing up the concept of whether a middle button
does paste or sends the raw event.

tricksy!

Refs: https://github.com/wez/wezterm/issues/87
2019-12-28 09:15:24 -08:00
Wez Furlong c8cd600706 wayland: fix unintentional blend with other windows
@jsgf mentioned this to me, and since I've started running "proper"
wayland gnome-shell/mutter on my pixelbook go, I'm seeing it too.

The issue is that the alpha values are potentially <1.0 when they
are committed to the frame buffer and the mutter compositor is
faithfully blending wezterm with the window behind it, leading to
weird looking effects such as varying brightness of text, or for
cases where the window behind wezterm is bright white, a halo
effect that makes the text less sharp.

This commit addresses this issue by asking glium to ask opengl to
set the destination alpha to 1.0 in the final draw stage.
2019-12-27 19:12:19 -08:00
Wez Furlong de3ffb3428 fix min underline height
I noticed this for small enough sizes of Fira Code the border width
for the cursor would round to zero, and then looking at eg: `man ls`,
the underlined portions had no underline.

Ensure that the underline size is at least 1 pixel.
2019-12-27 12:03:45 -08:00
Wez Furlong 0a6e3fda30 move scrollbar bits to their own module 2019-12-27 11:37:45 -08:00
Wez Furlong ba2caa815d Allow omitting window_padding fields
Closes: https://github.com/wez/wezterm/issues/85
2019-12-27 09:58:51 -08:00
Wez Furlong 11b79827de Add script that can produce a full source tarball
Full means "including git submodules" and makes it easier for folks to
download and build a release without sucking down large repos from
various locations, especially for folks with bandwidth constraints.

Upload the source tarball to the associated release.

Refs: https://github.com/wez/wezterm/issues/81
Refs: https://github.com/wez/wezterm/pull/46
Refs: https://github.com/wez/wezterm/pull/48
2019-12-24 09:41:15 -08:00
Wez Furlong fc6d80af0e opengl: make it easier to track quads
The offset math around the scroll thumb made me uncomfortable
so this commit introduces a struct to keep track of the vertex
indices and make it easier to recall them later.
2019-12-23 19:20:07 -08:00
Wez Furlong 66b0cf24d1 scrollbar: set a min height for the scroll thumb 2019-12-23 15:14:38 -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 1ff76e1c3c fix scrollbar rendering on X11 + opengl
Needed to also set the foreground otherwise it appeared invisible
on that particular system!
2019-12-23 08:08:30 -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 5471729b07 add some cursor util sprites
Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 11:34:08 -08:00
Wez Furlong 3be4c9c0d7 allow specifying the default cursor shape
Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 10:23:34 -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 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 ce45a0ee01 fixup IME/cursor positioning for padding changes 2019-12-22 08:21:36 -08:00
Wez Furlong f493139305 clippy 2019-12-21 23:13:26 -08:00
Wez Furlong 5eeed56b1a add window padding options
@jsgf suggested that it would be nice to have a degree of padding
around the terminal cells.  This commit adds some plumbing for this;

```
[window_padding]
left = 10
top = 0
right = 10
bottom = 0
```

The left and top padding are used top compute the top-left coordinates
of the terminal cells.  The right and bottom padding act as minimum
values; the actual padding used may be larger depending on the size
of the window and the number of cells that fit the available space.

top padding > 0 and the tab bar needs some work.
2019-12-21 22:35:23 -08:00
Wez Furlong 3e3bfcb4d7 fix typo in config name 2019-12-21 17:28:35 -08:00
Wez Furlong 01f50102ab fonts: suppress error when a font is not found in font_dirs
... and the font locator will use a system locator as a follow up.
2019-12-21 17:18:53 -08:00
Wez Furlong 7783d124e5 font-loader: avoid panic on windows
The upstream library panics for long family names
2019-12-21 17:08:01 -08:00
Wez Furlong a5b7747559 Replace enable_ligatures option with expanded harfbuzz_features option 2019-12-21 16:16:36 -08:00
Wez Furlong 291800b49a fonts: refine scaling factor
The ongoing saga from a465378dc4,
f204ad9a82, and others!

Only do scale adjustment here for glyphs that are taller rather than
wider.

This makes the ligatures in fira code look good again, and still
works with the v1 of the operator mono fonts.
2019-12-21 14:40:26 -08:00
Wez Furlong 5c1b78c17c fonts: allow disabling ligatures via config option
@sunshowers requested a way to turn this off, so here's a top level
config option to control whether we perform ligature substitution.

Ideally this would be associated with the font rather than globally,
but threading that information through the various layers is more
difficult than a global setting.
2019-12-21 09:38:33 -08:00
Wez Furlong ef582a8955 DRY: add FontAttributes::new() for defining font fallbacks 2019-12-21 09:20:00 -08:00
Wez Furlong 8f3d5f238b use default config if config file is broken on startup
Show the error message using a toast notification, but fall back to
the defaults; this makes it easier to get in and fix the issue,
rather than silently failing.
2019-12-19 11:12:02 -08:00
Wez Furlong fe4f0bf57a catch panic -> toast notification
This is useful when launched from a gui launcher and the stderr is
not conveniently visible.

If a panic occurs, generate a toast notification with the panic
message so that there is a breadcrumb to follow if the application
does terminate in this way.

Every so often I encounter this situation on my windows machine during
a graphics card driver update, so this should help to run that down.
2019-12-19 11:03:50 -08:00
Wez Furlong bd71db6450 refactor toast notification code
We now use this both for config loading issues and an errors
that bubble up out from the main loop.
2019-12-19 10:26:24 -08:00
Wez Furlong fc9e5ea0f5 Add font hinting and antialiasing config options
Adds the following options for the top level configuration,
which allow manipulating the quality of hinting and AA that
occurs for freetype:

```
font_antialias = "Subpixel" # None, Greyscale, Subpixel
font_hinting = "Full" # None, Vertical, VerticalSubpixel, Full
```

Refs: https://github.com/wez/wezterm/issues/79
2019-12-19 09:13:29 -08:00
Wez Furlong 26ac488c20 fix toml parse error reporting
The move to anyhow changed the nature of the error objects
that get passed through to the notification system; since
we use the `context` method and used the normal display
presentation (via `to_string`) we were only reporting the
context and not the nature of the error.

Switching to alternate output makes the error messages more
useful by including the underlying problem and line number.

Refs: https://github.com/wez/wezterm/issues/78
2019-12-17 21:52:17 -08:00
Wez Furlong 8950c6cc24 fonts: improve diagnostics around locating font_dirs fonts 2019-12-15 16:09:49 -08:00
Wez Furlong dab667ffc4 fonts: locator that only uses wezterm font_dirs config
This is useful when checking to make sure that your config works
independent of the system fonts.
2019-12-15 15:43:41 -08:00
Wez Furlong 0accf24181 finess some dead/unused code annotations 2019-12-15 08:38:52 -08:00
Wez Furlong a465378dc4 fonts: readjust the glyph scaling code
As mentioned in f204ad9a82, this has
gone back and forth a few times.

This version avoids some artifacts by avoiding scaling in most cases.
The test scenario for this is to tab complete a directory name in
zsh; that causes a bold `/` glyph to be rendered which selects a
typeface with different metrics and would render a horizontal line
at either the top of bottom of the glyph.

Similarly, a `/` in italics (eg: comments in vim) would select a
third different font and have different artifact properties.

Now both of those artifacts are eliminated.
2019-12-15 08:07:13 -08:00
Wez Furlong 9a2c7a1485 failure -> anyhow + thiserror 2019-12-14 21:43:05 -08:00
Wez Furlong 16cfe58d50 clippy 2019-12-14 16:41:17 -08:00
Wez Furlong f7bc9d536a font: teach rasterizer to load a font only on demand 2019-12-14 15:36:50 -08:00
Wez Furlong 50f72c43b3 fonts: manage fontconfig and freetype associated files better
I noticed a lot of things bleeding into the process and its children,
so work a bit harder to trim the resource usage back
2019-12-14 15:22:47 -08:00
Wez Furlong 990d12fdf4 fonts: defer loading and setting font size
There's a lot of overhead for doing the size setting on each shaper
call!
2019-12-14 14:00:15 -08:00
Wez Furlong 21ab0887db fonts: freetype: metrics: skip sizing an undefined glyph 2019-12-14 13:16:57 -08:00
Wez Furlong 51c2646eee fonts: remove some unused code and fixup some warnings 2019-12-14 12:29:38 -08:00
Wez Furlong f204ad9a82 fonts: fixed up shaping using allsorts
The issue mentioned from the prior commit was due to not breaking
out of the inner fallback loop, so we'd stack up multiple glyphs
with the same cluster value, causing the earlier versions to be
obscured by the later versions.

Adjust glyph width calculation: the metrics we were getting from
harfbuzz were synchronized with the font render size.  When we're
configured to use allsorts, the shaper metrics are not connected
to the render metrics and we can end up with the raw emoji glyph
width being much larger than the font advance metric value and
then render a giant heart emoji.   The revised calculations trigger
scaling if the glyph width is too wide.  I've gone back and forth
on that particular line a couple of times in the past: hopefully
this time we've got the right calculation?

I "fixed" the font metrics we compute and return from allsorts
by rounding them to the nearest integer value.  That makes the
spacing look better at my normal font size (8.3 -> 8) and makes
things look tighter.  It feels a bit magical IMO.
2019-12-14 10:17:31 -08:00
Wez Furlong a9b0197075 fonts: add an Allsorts shaper
Adds the ability to specify `--font-shaper Allsorts` and use that
for metrics and shaping.

It is sufficient to expand things like ligatures, but there's something
slightly off about how the metrics are computed and they differ slightly
from the freetype renderer, which leads to some artifacts when rendering
with opengl.

One of my tests is to `grep message src/main.rs` to pull out the line
that has a selection of emoji.  The heart emoji is missing from that
line currently.

Refs: https://github.com/wez/wezterm/issues/66
2019-12-14 08:46:06 -08:00
Wez Furlong 72f4ec58e4 font: allsorts add helpers for shaping 2019-12-11 23:05:57 -08:00
Wez Furlong 414d465208 font: load more font metadata using allsorts 2019-12-11 22:20:46 -08:00
Wez Furlong 6ef899ddba fonts: simplify obtaining and stash the otf table 2019-12-11 22:05:11 -08:00
Wez Furlong ad72362cbc eliminate dep on rental
Trading a lot of gross for a single line of gross
2019-12-11 21:40:07 -08:00
Wez Furlong 5696ce6304 fonts: add types for various font units
The idea is that this will make it easier to deal with alternate
rasterizers and shapers in later commits.
2019-12-10 09:01:55 -08:00