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

329 Commits

Author SHA1 Message Date
Wez Furlong
9ca428c4e1 wezterm-font: remove font-loader dep on windows
There are a number of cases where font-loader might panic on windows,
and the optional font-loader dep causes problems with `cargo vendor`
in #337, so this is a step to removing that dep.

This commit makes direct GDI calls to enumerate monospace truetype
fonts from the system and then applies our normal matching on the
result.
2020-11-22 10:27:48 -08:00
Wez Furlong
e8ad765ff5 wezterm: add SelectionMode::SemanticZone
This makes it possible to configure wezterm to eg: triple click
on command input (or output) to select the entire input or output
without messing around trying to find the bounds.

The docs have an example of how to configure this; it requires
setting up shell integration to define the appropriate semantic
zones.
2020-11-15 22:23:18 -08:00
Wez Furlong
37a3f7db5f wezterm: add ScrollToPrompt key assignment
Adds some supporting methods for computing the `SemanticZone`s
in the display and a key assignment that allows scrolling the
viewport to jump to the next/prev Prompt zone.
2020-11-08 09:58:02 -08:00
Wez Furlong
5619eb718c wezterm: default inactive_pane_hsb to dim/desaturate
Let's make the suggested config in the docs the default
and dim/desaturate inactive panes slightly.
2020-10-30 23:12:35 -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
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
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
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
f2cbc182cd wezterm: add window background image and opacity options
I thought it would be cute to add an option to add a background image to
the window.

While playing around with the parameters, I accidentally implemented
window transparency on X11/Wayland, provided that you have a compositing
window manager.  I don't know of the transparency also works on macOS or
Windows as of yet; will try that out once I push this commit.

This commit introduces three new configuration options explained below.

In the future I'd like to allow specifying equivalent settings in a
color scheme, and then that would allow setting per-pane background
images.

```lua
return {
    --[[
     Specifies the path to a background image attachment file.
     The file can be any image format that the rust `image`
     crate is able to identify and load.
     A window background image is rendered into the background
     of the window before any other content.
     The image will be scaled to fit the window.
     If the path is not absolute, then it will taken as being
     relative to the directory containing wezterm.lua.
    ]]
    window_background_image = "/some/file",

    --[[ Specifies the alpha value to use when rendering the background
     of the window.  The background is taken either from the
     window_background_image, or if there is none, the background
     color of the cell in the current position.
     The default is 1.0 which is 100% opaque.  Setting it to a number
     between 0.0 and 1.0 will allow for the screen behind the window
     to "shine through" to varying degrees.
     This only works on systems with a compositing window manager.
     Setting opacity to a value other than 1.0 can impact render
     performance.
     ]]
    window_background_opacity = 1.0,

    --[[
    Specifies the alpha value to use when applying the default
    background color in a cell.  This is useful to apply a kind
    of "tint" to the background image if either window_background_image
    or window_background_opacity are in used.

    It can be a number between 0.0 and 1.0.
    The default is 0.0

    Larger numbers increase the amount of the color scheme's
    background color that is applied over the background image.

    This can be useful to increase effective contrast for text
    that is rendered over the top.
    ]]
    window_background_tint = 0.0,
}
```

refs: https://github.com/wez/wezterm/issues/141
2020-10-18 09:47:55 -07:00
Wez Furlong
b7e303f39c Windows: prefer to use Direct3D11 via ANGLE
This is similar in spirit to the work in 4d71a7913a
but for Windows.

This commit adds ANGLE binaries built from
07ea804e62
to the repo.  The build and packaging will copy those into the same
directory as wezterm.exe so that they can be resolved at runtime.

By default, `prefer_egl = true`, which will cause the window
crate to first try to load an EGL implementation.  If that fails,
or if `prefer_egl = false`, then the window crate will perform
the usual WGL initialization.

The practical effect of this change is that Direct3D11 is used for the
underlying render, which avoids problematic OpenGL drivers and means
that the process can survive graphics drivers being updated.

It may also increase the chances that the GPU will really be used
in an RDP session rather than the pessimised use of the software
renderer.

The one downside that I've noticed is that the resize behavior feels a
little janky in comparison to WGL (frames can render with mismatched
surface/window sizes which makes the window contents feel like they're
zooming/rippling slightly as the window is live resized). I think this
is specific to the ANGLE D3D implementation as EGL on other platforms
feels more solid.

I'm a little on the fence about making this the default; I think
it makes sense to prefer something that won't quit unexpectedly
while a software update is in progress, so that's a strong plus
in favor of EGL as the default, but I'm not sure how much the
resize wobble is going to set people off.

If you prefer WGL and are fine with the risk of a drive update
killing wezterm, then you can set this in your config:

```lua
return {
  prefer_egl = false,
}
```

refs: https://github.com/wez/wezterm/issues/265
closes: https://github.com/wez/wezterm/issues/156
2020-10-17 19:08:16 -07:00
Wez Furlong
13cd24d9b5 Windows: improve ALT + dead key handling, part 2
This changes the ALT/dead key behavior a little bit more,
and in a way that is likely more useful to terminal users.

The default behavior is that system dead key processing is enabled.
For example, with DEU keyboard layout activated:

* `^` `<SPACE>` results in a single `^`
* `^` `e` result in those two characters combining into an e with a
  diacritic.

If the config sets `use_dead_keys = false` then the behavior changes;
wezterm probes the active keymap to determine which keys are marked
as dead keys and computes their single character expansion.  When
the dead key is pressed then that expansion is substituted instead.
So `^` is simply `^`.

In order to pull this off, the window layer needs to selectively
call `TranslateMessage` for the system dead key expansion case
instead of unconditionally in the global message loop.

As a result of *that*, it means that we don't perform the default ALT
key translation for every key press any more.  I looked to see how old
friend putty handles this and found that it only allows default system
processing for ALT-space and ALT-F4.  I was resistent to selectively
processing system shortcuts because the full set are effectively
unknowable to an application and I didn't want to try to replicate
a wide selection of varying keypresses.  I'm fine to only allow
these two, so this commit does that, and reverts the portion of
the prior commit that prevented passing general ALT key combinations
through.

refs: #275
refs: #296
2020-10-15 17:06:09 -07:00
Wez Furlong
ba096771ef wezterm: show config error window when fonts fail to load
This commit teaches the config layer to distinguish between
explicitly configured fonts and automatic fallback fonts.

Font loading now maintains the set of loaded fonts.  If after
loading from all configured sources a non-fallback font is
not present in the loaded set, wezterm will now pop up the
configuration error window to explain what is happening.

closes: #263
2020-10-11 16:54:51 -07:00
Wez Furlong
ab6cda81aa Add permute_any_mods and permute_any_or_no_mods functions
refs: #288
2020-10-10 15:11:21 -07:00
Wez Furlong
5a8fc09336 lua: add wezterm.sleep_ms
This will delay for the specified number of milliseconds.
This is an async function; it won't block the gui thread,
it will deschedule running the script and resume it once
the timeout has expired.

refs: #222
2020-10-09 21:11:30 -07:00
Wez Furlong
9d9f3c3c1a lua: add GuiWin and PaneObject proxies for use in script
This commit adds very basic first passes at representing the Pane
and GuiWindow types in lua script.

The `open-uri` event from 9397f2a2db
has been redefined to receive `(window, pane, uri)` parameters
instead of its prior very basic `uri` parameter.

A new key assignment `wezterm.action{EmitEvent="event-name"}` is
now available that allows a key binding assignment to emit an arbitrary
event, which in turn allows for triggering an arbitrary lua callback
in response to a key or mouse click.

`EmitEvent` passes the `(window, pane)` from the triggering window and
pane as parameters.

Here's a brief example:

```lua
local wezterm = require 'wezterm';

wezterm.on("my-thingy", function(window, pane)
  local dims = pane:get_dimensions();
  wezterm.log_error("did my thingy with window " .. window:window_id() ..
    " pane " .. pane:pane_id() .. " " .. dims.cols .. "x" .. dims.viewport_rows);
  window:perform_action("IncreaseFontSize", pane);
end)

return {
  keys = {
     {key="E", mods="CTRL", action=wezterm.action{EmitEvent="my-thingy"}},
  }
}
```

refs: #223
refs: #225
2020-10-09 13:55:36 -07:00
Wez Furlong
9397f2a2db wezterm: allow overriding the default open-uri event
This builds on the new lua event handler plumbing added
in ccea650a93 to co-opt
the default URI opening action:

```lua
wezterm.on("open-uri", function(uri)
  if uri:find("jira") then
    wezterm.log_error("do something with jira")
    wezterm.run_child_process({
      "wezterm",
      "start",
      "--",
      "jira",
      "view",
      extract_task_from_uri(uri)
    })
    -- prevent the default action from opening in a browser
    return false
  else
    -- log but allow the uri to be opened in the browser
    wezterm.log_error("clicken " .. uri)
  end
end)
```

This doesn't allow exactly the sketched out option from
issue #223 to be implemented, but may be close enough
to be useful.

refs: #223
refs: #225
2020-10-07 18:26:16 -07:00
Wez Furlong
882f47f4ad wezterm.glob is now async capable 2020-10-07 09:00:37 -07:00
Wez Furlong
15b6a7c355 wezterm.read_dir is now async capable 2020-10-07 08:55:37 -07:00
Wez Furlong
c7f95cac72 wezterm.run_child_process is now async capable 2020-10-07 08:51:54 -07:00
Wez Furlong
ccea650a93 add wezterm.on(), wezterm.emit()
* `wezterm.on("event-name", func)`
* `wezterm.emit("event-name", "arg1", "arg2")`

`on` allows registering multiple functions.
`emit` will call each of the registered functions in turn, passing
a copy of the arguments.  If a handler returns false, no additional
handlers are called and `emit` will return false.  Otherwise,
once all the handlers have been called, `emit` will return true.

`emit` is capable of being called by async code.

These functions are available to the config layer, but nothing in
wezterm uses them at this time.

refs: #225
2020-10-07 08:42:06 -07:00
Wez Furlong
4acf1e3935 Upgrade mlua to 0.4, lua to 5.4 2020-10-06 18:34:29 -07:00
Wez Furlong
8d1af908bf fixup starting mux on windows
* Taught wezterm-mux-server how to `--daemonize` on windows
* Removed pty based command spawn used to spawn unix domain servers.
  This was present because it was the only way to successfully spawn
  wsl in the past.  What I'm finding today is that it doesn't work
  at all for me, generating an `0xc0000142` Application failed to
  initialize error.  A plain command builder spawn seems to work,
  so that's what we're going with.
* Ensure that we put `.exe` on executable name on windows, otherwise
  the spawn may fail.
* `Path::exists()` always returns false for unix domain sockets on
  Windows, so unconditionally try to remove the socket before binding,
  otherwise the bind will falsely fail, claiming that another process
  is already bound.

The docs for mux will need to be updated to show how to revise them
for the new mux server invocation:

```lua
  unix_domains = {
    {
      name = "wsl",
      serve_command = {"wsl", "wezterm-mux-server", "--daemonize"}
    },
  }
```
2020-10-05 20:29:47 -07:00
Wez Furlong
bf266a326d maybe fixup build for windows 2020-10-05 11:57:08 -07:00
Wez Furlong
5eb4d32004 upgrade misc deps, notably, async-task 2020-10-05 00:06:01 -07:00
Wez Furlong
e8be716cb3 clean up mux server startup
kindof a lot going on in this commit, unintentionally:

* Need the lua context set to be moved into the config crate
  otherwise configs cannot be parsed by the server and we end
  up with the default configs
* Make the server use smol for async io
* Drop the use of the daemonize crate, which I had forked anyway.
  Just inline our own tighter daemonize module
* Improve daemon spawning synchronization, however, it still needs
  work for windows to avoid blocking forever where we don't do
  daemonizing.
2020-10-04 09:39:28 -07:00
Wez Furlong
0c32963f1c Move server to its own wezterm-mux-server binary 2020-10-03 11:15:57 -07:00
Wez Furlong
2af699fe79 move running_under_wsl to config crate 2020-10-03 11:15:57 -07:00
Wez Furlong
ee6864c217 move config into its own crate 2020-10-03 11:15:57 -07:00