1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00
Commit Graph

2760 Commits

Author SHA1 Message Date
Wez Furlong
dab2dd5025 term: cache recently decoded images
This commit introduces a small, bounded, LRU cache for recently
decoded images.

This allows the same image ID to be used in the cache that the
same image bits are repeatedly sent to the terminal.

This is advantageous because it reduces the amount of texture
space required by the gui layer.
2020-10-25 11:59:44 -07:00
Wez Furlong
198c40103b wezterm: fix iterm2/sixel images rendering in wrong pane
The quad selected for the image cells didn't account for
the pane origin.
2020-10-25 10:30:15 -07:00
Wez Furlong
f8c35f191b wezterm: add env bootstrap to mux server, too 2020-10-24 23:33:31 -07:00
Wez Furlong
83d604fe29 wezterm: .desktop launches wezterm
I changed this to `wezterm-gui` thinking it would be a hair more
efficient, but it makes it difficult to access the cli side of
things from the appimage.
2020-10-24 23:25:48 -07:00
Wez Furlong
21dbeb6f83 wezterm: fixup APPIMAGE environment consistently
Need to apply the same logic in wezterm-gui as we do
in the wezterm-cli.
2020-10-24 23:21:03 -07:00
Wez Furlong
ea0d8d6f11 wezterm-font: remove font-kit dep
This wasn't used by anything and the version was getting pretty stale.
Upgrading is awkward because newer versions pull in an incompatible
freetype library version.
2020-10-24 22:01:00 -07:00
Wez Furlong
284a4ebfbb window: fix mouse wheel reporting on Windows
Wheel events wouldn't get reported to eg: vim in wsl if the
window's X position was larger than the window width due to
mouse wheel messages being reported with screen coordinates
rather than client coordinates.

This commit addresses that.
2020-10-24 21:41:11 -07:00
Wez Furlong
89257c73bb wezterm: a few more wezterm-gui fixups
These parts of packaging are likely sensitive to the change also
2020-10-24 17:17:45 -07:00
Wez Furlong
b2dcc233c0 wezterm: improve error reporting in imgcat
This just includes the filename in the error message
if we're unable to read a file.
2020-10-24 17:07:19 -07:00
Wez Furlong
7d843c6b24 wezterm: fixup win32 build for wezterm-gui changes
refs: #301
2020-10-24 17:00:07 -07:00
Wez Furlong
2ec12b5426 wezterm: fixup packaging for wezterm-gui split
refs: #301
2020-10-24 16:54:36 -07:00
Wez Furlong
442c9a26d1 wezterm-gui: partial revert of 91ce0b77ea
Apparently macOS/ANGLE doesn't like the shader changes, so
roll them back.

refs: #292
2020-10-24 16:47:38 -07:00
Wez Furlong
7e8c5a06bb split gui into wezterm-gui executable
This commit moves a bunch of stuff around such that `wezterm` is now a
lighter-weight executable that knows how to spawn the gui, talk to
the mux or emit some escape sequences for imgcat.

The gui portion has been moved into `wezterm-gui`, a separate executable
that doesn't know about the CLI or imgcat functionality.

Importantly, `wezterm.exe` is no longer a window subsystem executable
on windows, which makes interactions such as `wezterm -h` feel more
natural when spawned from `cmd`, and should allow
`type foo.png | wezterm imgcat` to work as expected.

That said, I've only tested this on linux so far, and there's a good
chance that something mac or windows specific is broken by this
change and will need fixing up.

refs: #301
2020-10-24 16:40:15 -07:00
Wez Furlong
52908712c6 wezterm: add excess padding for image protocols
When allocating space in the texture atlas, we typically use
a small padding to avoid accidentally interpolating textures
into glyphs.

When it comes to rendering images via iterm2 or sixel image
protocols, the image emitted by the user may not exactly fill
the cell dimensions, and due to the how the shader works to
apply those textures we could end up revealing nearby images
in the texture when displaying an unrelated image.

This commit adjusts the texture atlas allocation when making
space for image protocol textures; excess padding based on
an overestimate of the cell dimensions is added to the right
and bottom of the image, guaranteeing that that border will
be filled with transparent pixels.

This is a bit wasteful of texture space, but isn't egregiously
bad and is easy to reason about and makes things look less
janky.

refs: #292
2020-10-24 12:46:49 -07:00
Wez Furlong
e2bf111426 wezterm: fix texture coordinates math for image protocols
There was an integer conversion happening when taking the
per-cell image texture coordinates and applying them to the
texture atlas image coordinates.

This commit replaces that math with floating point and corrects
the visual artifacts within squirrel.png.

refs: #292
2020-10-24 11:13:08 -07:00
Wez Furlong
91ce0b77ea wezterm: tidy up shader a bit
More properly annotate the types of the data used in the shaders.
Make the declarations more consistent with each other.
2020-10-24 10:42:23 -07:00
Wez Furlong
b49b82ae89 wezterm: add a linear scaling sampler for graphics
The fragment shader was set to use nearest texel sampling
because that made for sharper lines when rendering the
cursor bar or outlines.

This commit adds a supplemental sampler over the same
texture that is set to merge nearby texels.  We now
use this sampler for the background image and cells
marked as having full color textures (eg: emoji,
image protocol).

This makes the window background image look better
when it is scaled.  I'm not 100% sure about image
protocol cells, but I'm looking into that in general
at the moment.
2020-10-24 10:01:10 -07:00
Wez Furlong
7f82f333f1 wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.

* `window_background_opacity` controls the overall window capacity,
  whether a background image is present or not.
* When a background image is present, or if the window is transparent,
  then text whose background color is the default background is
  changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
  text whose background color is NOT the default background.
  It defaults to 1.0 (fully opaque), but can be set to be
  transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
  have been factored out into their own struct which changes
  that set of options to:

```lua
return {
  inactive_pane_hsb = {
    hue = 1.0,
    saturation = 1.0,
    brightness = 1.0,
  },
}
```

* `window_background_image_hsb` is a new option that can apply
  a hue, saturation, brightness transformation to a background
  image.  This is primarily useful to make a background image
  darker:

```lua
return {
  window_background_image = "/some/pic.png",
  window_background_image_hsb = {
    brightness = 0.3,
  },
}
```

refs: #302
refs: #297
2020-10-23 23:16:00 -07:00
Wez Furlong
18c2c6838a wezterm: tidy up atlas reallocation code path
refs: #306
2020-10-23 18:00:11 -07:00
Wez Furlong
f4066747d2 wezterm: improve texture atlas allocation
This commit uses the guillotine algorithm to assign rectangles,
which is superior to the dumb algorithm previously in use.

In addition, in the first pass of painting, if we get a texture
space error, we clear the atlas and try again without increasing
it size, which should serve as the ultimate defrag.

Subsequent passes will cause the texture to grow if needed.

refs: #306
2020-10-23 13:57:58 -07:00
Wez Furlong
e665bdb139 wezterm: reduce initial texture atlas size
Reduce the initial atlas size from 4096*4096*4 to
128*128*4.

Fixup an issue with rendering image cells that would
prevent the render from propagating a texture space
error and keep wezterm busy.

refs: #306
refs: #292
2020-10-23 09:07:51 -07:00
Wez Furlong
627d21cbac cargo fmt 2020-10-23 09:07:11 -07:00
Wez Furlong
e2311aaa73 window: more fun with dead keys on Windows
This is a bit more involved than I'd like, but it seems more
deterministic than using `TranslateMessage` or `ToUnicode` in all cases.

This commit expands the depth of the keyboard layout probing that
is performed when we detect a changed keyboard layout.

We know detect starting `(Modifier, VK) -> char` for a dead key press,
as well as the map of terminating `(Modifier, VK) -> char` for valid
dead key presses.

This information allows us to simply lookup the mapping without
calling `ToUnicode`.  Avoiding `ToUnicode` is desirable because it
maintains a global state and it is unpredictable what else is
manipulating that same state.  In particular, for the ESP keyboard
layout where `~` is a dead key that is reached via `AltGr 4`, there
doesn't appear to be a reliable way to extract the correct mapping
from it when calling `ToUnicode` in response to the various KEYUP,
KEYDOWN messages.   We could get it if we always called
`TranslateMessage` and only looked at `WM_CHAR`, but that means that
we cannot decompose `WM_CHAR` back to the raw key events when we
need to.  Bleh!

Test Plan for this commit:

* With ENG layout active, check that CTRL, ALT and so on have the
  intended effect in the terminal; eg: CTRL-C, CTRL-W (in vim).
* Switch to pinyin layout, check that typing still invokes the
  IME and that it can insert text
* Switch to DEU.  Check that `AltGr m` produces a `mu` symbol.
  Check that grave (`\``) (a dead key) doesn't immediately output
  anything, then press `e`; that produces an `e` with a grave
  diacritic.  Grave followed by space emits grave.  Grave
  followed by grave emits a grave and holds the second grave; pressing
  `e` at this point now emits `e` with a grave diacritic.
  (This is a difference from the "normal" system behavior, which
  would just emit two graves in a row, then a regular `e`).
* Switch to ESP.  Check that `AltGr 4` (tilde) doesn't immediately
  output anything, then press `n`; that produces an `n` with the
  tilde diacritic.
* Change `use_dead_keys = false`.  Now verify in DEU that `grave`
  just emits grave.  In ESP, verify that `AltGr 4` just emits
  a tilde.
* Switch back to ENG.  Verify that `ALT-space` pops up the system
  menu.

refs: #275
refs: #305
2020-10-23 08:47:11 -07:00
Wez Furlong
f12df0be9b window: add cursors for resizing up/down left/right
Change the cursor to an appropriate one of these when hoving
over and dragging a split.

Fix an issue where we wouldn't always change the cursor when
hovering over a split when multiple splits are present.
2020-10-22 09:23:05 -07:00
Wez Furlong
b0fdd15d35 wezterm: add [Z] prefix to titlebar for zoomed panes
refs: #297
2020-10-20 23:20:22 -07:00
Wez Furlong
fb9fb8230d wezterm: fix an issue refreshing inactive panes
If you split and run top in one pane, then switch to another pane, the
inactive `top` pane display would only repaint when moving the mouse or
typing.

This commit fixed the periodic task to consider all renderable panes
rather than just the active pane.
2020-10-20 21:20:42 -07:00
Wez Furlong
9e53462348 docs: adjust screenshots to include cursor color
Make sure the window is active when capturing all the screenshots.
2020-10-20 09:55:32 -07:00
Wez Furlong
83c52ef27a docs: format and wording tweak for color schemes 2020-10-20 00:55:35 -07:00
Wez Furlong
2c5275142a docs: another tweak for color schemes linkage 2020-10-20 00:52:42 -07:00
Wez Furlong
df1206fc37 docs: fixup case of title 2020-10-20 00:46:12 -07:00
Wez Furlong
30fc374ad8 docs: add colorschemes + screenshots
This includes a script to generate a screenshot from a wezterm
running the default config under X11.

It expects the iTerm2-Color-Schemes to be checked out alongside
the wezterm repo as it uses the dynamic color schemes scripts
to activate the schemes one by one and capture the display.
2020-10-20 00:40:25 -07:00
Wez Furlong
95ab1b34e1 Update color schemes
Sync with 0966005b77
2020-10-19 22:51:48 -07:00
Wez Furlong
8d6274887f More fun with font fallback
After 41b6c4a5ad, I was able to
experience a panic on a linux system.

This commit gives us one last fallback to plain ? glyphs.
2020-10-19 22:43:34 -07:00
Wez Furlong
1978eba0a1 wezterm: make the split color configurable and darker
This makes the color of the split divider darker by default,
and configurable via the color scheme configuration file.

refs: #297
2020-10-19 22:05:13 -07:00
Wez Furlong
eb9f7aefc6 wezterm: add options to dim inactive panes
refs: #297
2020-10-19 20:59:22 -07:00
Wez Furlong
7314daa875 wezterm: refactor: move shapecache into own module 2020-10-19 09:34:58 -07:00
Wez Furlong
eaa6536325 wezterm: remove OldSoftware frontend
Upcoming changes to the GUI mean that it will be double
the work to keep maintaining this, and it is already lagging
behind on pane support.

With the Mesa llvmpipe fallback we should be in a pretty
good state to not need another non-GL implementation.
2020-10-19 09:22:02 -07:00
Wez Furlong
80e36f93b9 docs: add a screenshot demonstrating background image 2020-10-19 08:59:53 -07:00
Wez Furlong
5b92167d19 wezterm: fix transparency for splits
refs: #141
2020-10-19 08:39:36 -07:00
Wez Furlong
aa660d5d06 wezterm: apply transparency tint to all background colors
refs: https://github.com/wez/wezterm/issues/141#issuecomment-711442986
2020-10-18 21:51:12 -07:00
Wez Furlong
2df66cbdbe wezterm: pass config via params struct
Shaves a little bit of work off when the cursor is visible
2020-10-18 21:19:54 -07:00
Wez Furlong
689eaa0ee9 wezterm: compute_cell_fg_bg args/result to structs
These were definitely awkward, and now they're differently
awkward and slightly easier to manage.
2020-10-18 21:15:42 -07:00
Wez Furlong
df086976b1 wezterm: tidy up a little bit of drawing
Rename a method to better reflect panes.
move a global clear outside of the pane drawing.
2020-10-18 17:50:49 -07:00
Wez Furlong
c47b86b78a wezterm: fix an issue with opacity when making the window wider
The inferred background color for the cells in this case didn't
account for the tint.

refs: #141
2020-10-18 16:24:48 -07:00
Wez Furlong
21eab3430b docs: add docs on background/opacity configs
refs: #141
2020-10-18 14:32:17 -07:00
Wez Furlong
cabb8ca903 docs: macos: note about dead keys and IME
refs: https://github.com/wez/wezterm/issues/300
2020-10-18 14:07:23 -07:00
Wez Furlong
191b047126 macos: implement opacity for CGL and Metal
There's a few different knobs to turn, but this
commit turns them and we're now able to respect
opacity settings for both OpenGL/CGL and Metal
renderers.

closes: #141
2020-10-18 14:00:06 -07:00
Wez Furlong
2364b0a20e Windows: enable window_background_opacity
This causes DWM to respect the alpha channel we set during rendering,
allowing the window opacity to be respected on Windows.

refs: #141
2020-10-18 11:13:34 -07:00
Wez Furlong
41b6c4a5ad wezterm: don't give up if we run out of fallbacks
9d33073d70 improved how we handle
the case where we run out of fallbacks, but with the unintended
consequence that we'd just give up on rendering the current frame,
which isn't super useful.

Since that commit landed we now bundle JetBrains Mono so that
means that we can guarantee to find our fallback glyph in case
we can't locate the font holding the requested glyph.

This commit causes us to unconditionally recurse and shape
the replacement character to use in this situation.

refs: #299
2020-10-18 11:00:01 -07:00
Wez Furlong
6cee020c89 linux/freebsd: avoid random fontconfig fallbacks
This is the same class of problem as c32de40978
but on X11/Wayland systems.

In this case, the 100 or so "random" fontconfig fallbacks were
taking precedence over our locally configured emoji fallback.

This commit filters the fontconfig results to more exact matches,
with less surprising results.

This may come at the cost of magically resolving fallback fonts
for unusual scripts, however.
2020-10-18 10:12:19 -07:00