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

223 Commits

Author SHA1 Message Date
Wez Furlong
91cd2e22e4 prefer local/specific config for a couple more cases
Avoid using `configuration()` when there may be a more specific
config with overrides that we can resolve.
2021-04-16 09:04:51 -07:00
Wez Furlong
76353a6240 fix: InputMap reading global config instead of window overrides
refs: #656
2021-04-16 08:59:49 -07:00
Wez Furlong
67d8848676 ls-fonts: refine output a bit
It now outputs something that you could conceivably put into
your config file, although the intent is to show the canonical
way to reference the individual fonts that were found, rather
than to specify a fully baked list to paste into a config.

eg:

```
; ./target/debug/wezterm ls-fonts
Primary font:
wezterm.font_with_fallback({
  -- /home/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
  {family="Operator Mono SSm Lig", weight="DemiLight"},

  -- /home/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontConfig
  {family="Operator Mono SSm Lig", weight="DemiLight"},

  -- /home/wez/.fonts/MaterialDesignIconsDesktop.ttf, FontDirs
  "Material Design Icons Desktop",

  -- /home/wez/.fonts/terminus-bold.otb, FontDirs
  {family="Terminus", weight="Bold"},

  -- /home/wez/.fonts/JetBrainsMono-Regular.ttf, FontDirs
  "JetBrains Mono",

  -- /home/wez/.fonts/NotoColorEmoji.ttf, FontDirs
  "Noto Color Emoji",

  -- /home/wez/.fonts/MaterialDesignIconsDesktop.ttf, FontConfig
  "Material Design Icons Desktop",

  -- /usr/share/fonts/terminus-fonts/ter-u32n.otb, FontConfig
  "Terminus",

  -- /home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig
  "JetBrains Mono",

  -- /home/wez/.fonts/NotoColorEmoji.ttf, FontConfig
  "Noto Color Emoji",

  -- <built-in>, BuiltIn
  "Last Resort High-Efficiency",

})
```
2021-04-14 09:06:02 -07:00
Wez Furlong
3fae59b01b fonts: use cap-height metric to scale fallback fonts
we now compute the ratio of the cap height (the height of a capital
letter) vs. the em-square (which relates to our chosen point size) to
understand what proportion of the font point-size that a given font
occupies when rendered.

When rendering glyphs from secondary fonts we can use the cap height
ratios of both to scale the secondary font such that its effective
cap height matches that of the primary font.

In plainer-english: if you mix say bold, italic and regular text
style in the same line, and you have different font families for
those fonts, then they will now appear to be the same height where
previously they may have varied more noticeably.

For emoji and symbol fonts there may not be a cap-height metric
encoded in the font.  We can however, improve our scaling: prior
to this commit we'd use the ratio of the cell metrics of the two
fonts to scale the icon/emoji glyph, but this could cause the glyph
to be slightly oversized as seen in https://github.com/wez/wezterm/issues/624

If we know the cap-height of the primary font then we can additionaly
apply that factor to scale the emoji to better fit the cell.

While looking at this, I noticed that the aspect ratio calculation
for when to apply to the allow_square_glyphs_to_overflow_width option
had width and height flipped :-(

See also: https://tonsky.me/blog/font-size/
refs: https://github.com/wez/wezterm/issues/624
2021-04-13 23:02:27 -07:00
Wez Furlong
776aedf97e fonts: allow specifying weight/stretch/italic for each fallback font 2021-04-12 22:30:55 -07:00
Wez Furlong
2e34f1a8dd Add wezterm ls-fonts subcommand
At this time it just shows you the fonts that your config matches
and where they came from:

```
; wezterm -n ls-fonts
Primary font:
  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Italic=true:
  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=true)
    (/home/wez/.fonts/JetBrainsMono-Italic.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Intensity=Bold:
  wezterm.font("JetBrains Mono", weight="Bold", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Bold.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Intensity=Bold Italic=true:
  wezterm.font("JetBrains Mono", weight="Bold", stretch="Normal", italic=true)
    (/home/wez/.fonts/JetBrainsMono-Bold-Italic.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

```

refs: #347
2021-04-12 09:44:27 -07:00
Wez Furlong
e5665e80a1 add window:toast_notification method
refs: https://github.com/wez/wezterm/issues/619
2021-04-11 22:01:06 -07:00
Wez Furlong
16701f61b4 fix new-tab hover calculation
refs: https://github.com/wez/wezterm/issues/677
2021-04-11 16:10:14 -07:00
Wez Furlong
180f125830 fix gaps in multi-cell ligatured glyphs
refs: https://github.com/wez/wezterm/issues/614
2021-04-10 13:59:59 -07:00
Wez Furlong
c312983643 Ensure that we propagate OutOfTextureSpace errors
otherwise we won't be able to show many glyphs beyond those that
fit in the initial texture atlas!

refs: https://github.com/wez/wezterm/discussions/672
refs: https://github.com/wez/wezterm/issues/671
2021-04-10 07:26:19 -07:00
Wez Furlong
b825f86380 avoid incomplete paints if loading a glyph fails
This addresses the render artifacts aspect of https://github.com/wez/wezterm/issues/671

For whatever reason, some font(s) cannot be loaded on that system
and that results in the paint routine erroring out.

This commit avoids the error by substituting a blank glyph
instead of the glyph that failed to load.

refs: https://github.com/wez/wezterm/issues/671
2021-04-10 00:21:00 -07:00
Wez Furlong
16e7457049 x11: notice dynamic changes to Xft.dpi
This commit allows the x11 window implementation to detect changes
in the DPI that occur after a window is created.

These can occur when changing desktop resolution or when changing
the accessibility option for "Large Text" in gnome.

In order to avoid continually polling for the value on every resize,
we look for the `_GTK_EDGE_CONSTRAINTS` atom in our property change
notifications.  This seems to be sent at least as often as the
dpi/scaling changes.

It's also worth noting that some dpi changes don't generate resize
events, so we can't just read the dpi value on every resize, because
we'd miss some of those changes.

Part of this commit changes the font scaling logic: previously
we'd keep a notion of "dpi scale" to apply.  That dates from an
earlier time in wezterm where we didn't think that we knew an
actual dpi value.

The way that worked was that we'd compare our current guestimate
of the DPI against what we though the baseline OS dpi should be to
produce a scaling factor.

On X11 that dpi value is global and we'd effectively always produce
a revised scaling factor of 1 after we'd set up the initial window.

This commit changes that logic to just pass down the actual DPI value
to the font code.  That DPI value already accounts for HiDPI scaling
so this is hopefully a NOP change for the other systems.

refs: https://github.com/wez/wezterm/issues/667
2021-04-09 09:23:25 -07:00
Wez Furlong
ecc500af05 ssh: don't override the ssh config User value 2021-04-08 16:17:49 -07:00
Gus Wynn
dee10c2f21 Support unicode charaters in 2021-04-08 15:42:39 -07:00
Wez Furlong
6830d171cf fixup metrics when line_height==1.0
This was broken by b441be3ac9

For whatever reason, the breakage was only visible with the Iosveka
font on Windows.  I couldn't reproduce it on my other systems, even
though the code technically applies to any system.

The breakage was: the metrics resulted in a difference of about 0.4
pixels being used for the descender with that particular font, resulting
in weird vertical alignment problems.

The offset needs to be computed against the ceil of the cell height,
which removes the fractional offset.

refs: https://github.com/wez/wezterm/issues/661
refs: https://github.com/wez/wezterm/issues/582
2021-04-08 09:48:47 -07:00
Wez Furlong
81946d0144 fix under-invalidation of the selection
The repro scenario for this case was:

* open GNU nano
* hit enter twice
* type hello
* move the text cursor to the top line
* double click on hello
* hit enter

Prior to this commit, the selection would remain on the now-blank line
that previously held `hello`.

refs: #644
2021-04-07 08:43:45 -07:00
Wez Furlong
5cc29d1d8c wezterm-mux-server: keep running after all panes are gone
This has been a commonly requested feature in the past week,
and it's a reasonable one.  The mux server inherited the
close-when-done behavior from when it used to be an alternate
front-end in the same executable as the gui, but it doesn't
need to be that way any more.

We also need to accomodate that case in the client: if the
newly attached domain doesn't result in any panes being imported,
we need to spawn a new command there in order to keep the client
alive.  The pre-existing check for whether the mux was empty had
false positives because the local mux may still reference the
pane from the connection UI, which would finish closing out shortly
after we had decided not to spawn anything, and then the client
would close.

refs: https://github.com/wez/wezterm/issues/631
refs: https://github.com/wez/wezterm/issues/507
2021-04-03 15:00:08 -07:00
Wez Furlong
b441be3ac9 gui: vertically center cell within adjusted line height
When line_height is specified, rather than applying the offset
to just the top of the cell, apply it in equal parts to the top
and the bottom so that the cell is vertically centered.

closes: https://github.com/wez/wezterm/issues/582
2021-04-03 10:41:28 -07:00
Wez Furlong
4112b74f8a spawn local domain when starting gui in mux mode
This allows explicitly spawning commands locally, rather than
in the target mux.

this is similar to 12225a099a

refs: https://github.com/wez/wezterm/issues/468
2021-04-03 09:18:24 -07:00
Wez Furlong
298e0b8d76 hide mouse cursor each time we send key input to a pane
Mouse movement will show the cursor again.

macOS: fix hiding the cursor

refs: https://github.com/wez/wezterm/issues/618
2021-04-02 22:34:58 -07:00
Wez Furlong
4a3e0615f5 tweak ActivateLastTab and add a changelog entry for it
refs: https://github.com/wez/wezterm/pull/610
2021-04-02 09:29:52 -07:00
Alex Gartrell
ee4b4b598c Add ActivateLastTab command
This replicates `last-window` in tmux. To pull this off, I
deliberately store the last tab whenever I'm activating a new one or
spawning a new one. I had to do this explicitly rather than hooking
set_active, because we end up setting the active tab briefly for some
common operations like moving a tab.
2021-04-02 09:14:59 -07:00
Wez Furlong
d45bbed3fd ssh: fix handling wezterm ssh user@host:22 2021-03-29 21:21:31 -07:00
Wez Furlong
32fa186c99 wezterm-gui: add wezterm ssh -oIdentityFile=/some/thing
Allow overriding ssh config options from the command line.

I don't want to replicate the many options that `ssh(1)` has;
this just exposes the `-oNAME=VALUE` syntax.  The config names
are those from `man ssh_config`; `IdentityFile` rather than `-i`.

refs: #457
2021-03-28 08:24:35 -07:00
Wez Furlong
12225a099a fix spawning new tabs via launcher menu
I wonder how long this has been broken... rather than spawning
into domain "local" it would try to spawn into "`local`" and fail
silently because the error message wasn't logged.

So let's log it, and let's fix it.

refs: https://github.com/wez/wezterm/issues/468
2021-03-27 19:00:55 -07:00
Wez Furlong
53a13e60f5 start up "local" domain when spawning ssh
allows defining launch_menu items to spawn explicitly locally:

```lua
return {
  launch_menu = {
    {
      label = "Local zsh",
      args = {"zsh", "-l"},
      domain = {DomainName="local"},
    },
  }
}
```

refs: https://github.com/wez/wezterm/issues/468
2021-03-27 18:35:28 -07:00
Wez Furlong
e103653923 RemoteSshDomain now uses wezterm-ssh crate
There are a few notable changes as a result:

* A number of `.ssh/config` options are now respected; host matching
  and aliasing and identity file are the main things
* The authentication prompt is inline in the window, rather than
  popping up a separate authentication window

Refs: https://github.com/wez/wezterm/issues/457
2021-03-27 18:12:34 -07:00
Wez Furlong
c6308202cb hyperlinks, selection by word and line deal with wrapping better
These now operate in terms of logical lines so they deal with
lines that have wrapped outside the viewport better than in
previous releases.

closes: https://github.com/wez/wezterm/issues/408
2021-03-26 14:52:00 -07:00
Wez Furlong
0f23c140d1 partial revert of prior commit; it's not quite right
https://github.com/wez/wezterm/issues/408
2021-03-26 13:52:39 -07:00
Wez Furlong
d827be990d speculatively apply hyperlinks to logical lines
This might be all that is needed to make multiline implicit hyperlinks
function, but I need to transfer this commit to another machine to try
it.

refs: https://github.com/wez/wezterm/issues/527
refs: https://github.com/wez/wezterm/issues/408
2021-03-26 13:47:27 -07:00
Wez Furlong
0643e8b0ed add window:get_selection_text_for_pane
refs: https://github.com/wez/wezterm/issues/575
2021-03-25 22:10:29 -07:00
Wez Furlong
b876fbabd6 remove the config bridge and have window -> config directly 2021-03-23 21:56:57 -07:00
Wez Furlong
f301fc6ecc avoid potential panic when processing double wide cells 2021-03-23 08:13:26 -07:00
Wez Furlong
5d96db3349 fix tests 2021-03-22 20:54:01 -07:00
Wez Furlong
8f856d0b81 font: make system fallback async wrt. rendering
If shaping can't resolve some glyphs, queue the font locator
fallback resolution to another thread; meanwhile, a last resort
glyph is used.

That thread can trigger an invalidation once the fallback resolve
is complete, the window is invalidated and the last resort glyph
is replaced by the resolve glyph.

refs: https://github.com/wez/wezterm/issues/559
refs: https://github.com/wez/wezterm/issues/508
2021-03-22 20:42:03 -07:00
Wez Furlong
22522dc39e render more symbol/icon/emoji at double width by default
Default `allow_square_glyphs_to_overflow_width="WhenFollowedBySpace"`,
and expand its meaning from mostly square glyphs to glyphs that are
also wider than they are tall.

refs: https://github.com/wez/wezterm/issues/565
2021-03-22 11:36:45 -07:00
Wez Furlong
4fa85e7037 gui: avoid closing pty pane when double-activating search overlay
This is another variation on dcb6fec28f

refs: #572
2021-03-22 08:35:10 -07:00
Wez Furlong
a5f4803b0b fix panic when egl doesn't have OPENGL_API
refs: #566
2021-03-21 20:51:02 -07:00
Wez Furlong
a0d39989df simplify Color data type
There's something fishy with colorspaces and blending.
This commit removes the `window::Color` type and replaces
it and the confusing array of color types exposed by the
`palette` crate with a pair of much simpler types:

`LinearRgb` - a tuple of f32 linear color components
`SrgbaPixel` - the u32 sRGBA pixel representation

This doesn't change anything about rendering, it just
makes it a bit simpler and makes the SrgbaPixel -> LinearRgb
conversion happen slightly earlier which shaves off some
ad-hoc conversions.

Refs: https://github.com/wez/wezterm/issues/544
2021-03-21 16:54:22 -07:00
Wez Furlong
59ec969a26 gui: micro-optimize some aspects of rendering
hoist the underlyine glyph retrieval out of the loop.
Precompute some color conversions (less effective until
the gamma branch is merged).

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 13:40:24 -07:00
Wez Furlong
20e3d4d982 gui: use triple-buffering of vertexbuffers
The internet says that this is a recommended way to avoid stalling
when updating the vertex data.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 12:01:30 -07:00
Wez Furlong
1994a2ea2d gui: improve vertex buffer map/write/release performance
Switches from using a dynamic vertex buffer to an immutable
vertex buffer.  This feels counter-intuitive to me; the purpose
of dynamic is to sustain frequent updates, but mapping the buffer
needs to synchronize with the GPU, and if we are rapidly invalidating
the window that can stall painting by tens of milliseconds.

Switching to an immutable buffer avoids the stall and makes
quad mapping more consistently < 10ms, but its still not
ideal.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 10:28:17 -07:00
Wez Furlong
4767fcc28c windows: some minor performance improvements
* Make window invalidation more efficient by avoiding spawning a call
  that spawns a call to invalidate the window.  Just directly mark as
  invalidated.

* Suppress default background erase

* hoist the bg_color calc for quads that don't have Cells outside of
  its loop.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 10:06:43 -07:00
Wez Furlong
8015791dd0 fixup initial pty dimensions to account for font/dpi size
refs: https://github.com/wez/wezterm/issues/563
2021-03-20 13:17:32 -07:00
Wez Furlong
3d0f3eaeec gui: avoid doing work when WM sends spurious resize events
refs: #557
2021-03-19 08:11:39 -07:00
Wez Furlong
ba7add140e Attach gui window invalidation to pty output event
I'm not convinced that this is 100% good, but @fanzeyi reported
some latency when using tmux to mirror two sessions.  The session
that was accepting interactive input responded quickly, but the
mirroring session was laggy.

This change connects the mux pane output event to window invalidation,
which should cause repaints to happen more often.

I couldn't reproduce the scenario above on my M1 mac, but that may
just be because M1 has dark magicks.
2021-03-17 20:20:08 -07:00
Wez Furlong
5681cd9b64 gui: update windows dep to 0.4 2021-03-14 15:25:33 -07:00
Wez Furlong
04b7cedd02 fix animated gif playback
A casualty of b8dcfba9a4 was that
the decoded gif would get reset each time the texture filled up.

Take care to move that cached into the newly minted glyphcache.
2021-03-14 10:29:02 -07:00
Wez Furlong
09081d2189 improve texture upload performance, part 2
Continuing along the same lines as the prior commit, the goal
of this commit is to remove the buffer transformation that was
part of uploading the texture to the GPU provided surface.

In order to do so:

* The sense of our local textures needs to change from bgra32 to rgba32.
  bgra32 was a hangover from earlier versions of our window crate that
  allowed direct-to-fb writes in software mode.  We had to pick bgra32
  for that for the broadest OS compatibility.  I believe that that
  constraint has been totally removed, although there is a chance that
  this will flip the colors on macos.
* There was an additional linear-to-srgb conversion inlined in that
  buffer transformation.  I have no idea where that is needed because
  the source data is carefully constructed as SRGB.  I don't yet know
  how to signal that, but for now I've moved that gamma correction
  into the shader when we sample the texture.

With this change, timg playback now has vtparse as the hottest
region of code.

refs: #537
2021-03-14 09:14:30 -07:00
Wez Furlong
b8dcfba9a4 improve texture upload performance
Two issues highlighted by profiling:

* Clearing the texture takes a non-trivial percentage of the profile.
  The docs suggest that it is better to create a new texture than
  to update large portions of a texture, so add some plumbing so
  that we can do that in the first texture-full case.

* Next on the list is the code that translates from linear BGRA to
  SRGBA.  This is present for reasons that I believe are now legacy,
  but for the moment: those two primitives now have faster and
  easier implementations, so simplify to those.

This improves the timg video playback performance by ~10% for me.

refs: #537
2021-03-13 23:18:15 -08:00