1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-13 07:22:52 +03:00
Commit Graph

2778 Commits

Author SHA1 Message Date
Wez Furlong
7767fbe88f termwiz: fixup tests after b3f51e8ee2 2020-10-11 17:21:16 -07:00
Wez Furlong
5b164bafd0 wezterm: show config error window if opengl fails to init
Previously we'd silently (well, we'd log to stderr) fall
back to the CPU renderer.

Let's instead pop up a config error window to make this
class of error more visible.

refs: #272
2020-10-11 17:17:35 -07:00
Wez Furlong
5257e34e2c window: update to latest glium version 2020-10-11 17:07:47 -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
bc1d4bba35 wezterm: avoid implausible font sizes in shaper metrics
In this scenario:

```lua
local wezterm = require "wezterm"

return {
  font_size = 12.0,
  font_dirs = {"/home/wez/.fonts"},
  font_locator = "ConfigDirsOnly",
  font = wezterm.font_with_fallback({
    -- this is an invalid font
     "does not exist",
    "Noto Color Emoji",
  }),
}
```

we'd take the metrics from the emoji font and the cell size would
be crazy huge.

With this change we filter out "outliers" based on the approximate
pixel size for a font given its size and dpi.  If a fallback position
is significantly larger or smaller than the theoretical size then
we skip it when considering the metrics.

The result of this is that with the above configuration we end up
with `{"Noto Color Emoji", "JetBrains Mono"}` as the font order;
most of the textual glyphs will render from `JetBrains Mono` but
the number glyphs prefer the `Noto Color Emoji` renditions which
are typically double width.  While the terminal looks a bit
cartoonish as a result of that selection, the sizes are much more
reasonable compared to the screenshot in #263.

refs: #263
2020-10-11 14:58:04 -07:00
Wez Furlong
b3f51e8ee2 termwiz: save 8 bytes per Cell in common case
Moved the image and hyperlink portion of CellAttributes out
to a separate heap structure, saving 8 bytes per Cell
for the common case of no hyperlink and no image.
2020-10-11 13:32:53 -07:00
Wez Furlong
2a87c1dec7 Change cell api to avoid direct access to hyperlink/image
This allows potentially changing the struct layout
to reduce the struct size.
2020-10-11 13:12:46 -07:00
Wez Furlong
96c4750a30 termwiz: reduce Cell memory consumption by 24 bytes
Replaces SmallVec with an internal TeenyString that only
occupies a single machine word and avoids heap allocation
in the common case on most architectures.  This takes the
textual portion of Cell from 32 bytes to 8 bytes.
2020-10-11 13:08:57 -07:00
Wez Furlong
7e232ae1af termwiz: add a test to assert size of cell structs
`cargo test -p termwiz`

(fixup color.rs test to run when serde feature is disabled)
2020-10-11 12:40:07 -07:00
Wez Furlong
dedfc4513b wayland: clear modifiers when keyboard focus changes
refs: #222
2020-10-11 10:02:37 -07:00
Wez Furlong
d33647dd97 ci: move source archive to run only for appimage build
The nightly builds seem to often trip over each other when
uploading the source tarball from ubuntu20.

Restrict it to being built only on the appimage build (ubuntu16).
2020-10-10 17:14:06 -07:00
Wez Furlong
807ed3ba1e wayland: fixup timing issue on startup
025732d00f introduced deferred
window creation; the creation would get scheduled into the
spawn queue and then get run again a few milliseconds later
on the main thread.

For reasons that I don't understand, returning to the scheduler
loop to flush or otherwise process messages causes a wayland
protocol error.

Adjusting the notify routine to dispatch immediately if we're
already on the mux thread seems to resolve this.

While looking at this, I cleaned up a destruction order issue
with the opengl state that was then causing a segfault on shutdown.

I also removed a bit of dead paint related code that doesn't
appear to be needed any more.

refs: #293
2020-10-10 16:09:04 -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
46651caaf8 ci: disable cache on macos 2020-10-10 12:00:18 -07:00
Wez Furlong
787f956e24 docs: add LEADER to changelog 2020-10-10 10:55:22 -07:00
Wez Furlong
59e1e9313d docs: add splits/panes to features list 2020-10-10 10:52:15 -07:00
Wez Furlong
6c12e2e981 docs: more pane related docs 2020-10-10 10:49:36 -07:00
Wez Furlong
87b4a525d3 docs: document LEADER mod 2020-10-10 09:57:38 -07:00
Wez Furlong
fef80735c8 docs: add various pane related key assignments 2020-10-10 09:50:18 -07:00
Wez Furlong
bfe87b6bec ci: more messing around with cache on macos
Something seems to poison the cargo cache between the PR
and continuous builds.  Turn off caches for continuous builds.
2020-10-10 09:25:11 -07:00
Wez Furlong
40d07088d9 docs: Update for confirm parameter when closing panes, tabs 2020-10-10 09:19:57 -07:00
Wez Furlong
ba9b98cd28 docs: fixup generated index page links 2020-10-10 09:07:56 -07:00
Wez Furlong
809bb53387 docs: split out the KeyAssignment enum variants
This makes the individual functions a bit easier to discover,
and a lot easier to link to.
2020-10-10 08:45:13 -07:00
Wez Furlong
7af4152275 docs: add a bit of exposition for the module/object sections 2020-10-10 08:00:08 -07:00
Wez Furlong
2463510a88 ci: more adjustments for actions/cache@v2 2020-10-10 07:36:34 -07:00
Wez Furlong
4c639c1d54 ci: invalid github caches
The mac builds started to fail with a crate resolution issue that I
can't reproduce locally shortly after I updated the cache action.  Let's
tweak the cache key to see if that clears things up.
2020-10-09 23:53:58 -07:00
Wez Furlong
b009e8c0d4 docs: add docs for the window object
refs: #225
2020-10-09 23:34:35 -07:00
Wez Furlong
850fdf40de docs: add docs for the Pane object
refs: #225
2020-10-09 23:22:52 -07:00
Wez Furlong
ccc0bf824d docs: lua: add undocumented wezterm.XXX items
Adds docs for some of the newer lua scripting functions.

refs: #222
refs: #223
refs: #225
2020-10-09 22:50:46 -07:00
Wez Furlong
6e0836d11a docs: Make it easier to split out docs into multiple pages 2020-10-09 22:03:59 -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
22b6123624 ci: update to actions/cache@v2 2020-10-09 21:02:00 -07:00
Wez Furlong
8ce2d2ba04 ci: remove deprecated and unused azure setenv 2020-10-09 21:01:17 -07:00
Wez Furlong
0cd17b0407 fix a post-fork issue that broke the mux server
One of the updates in the past week made the reactor/async-io
stuff sensitive to the fork performed by daemonizing.

We can "simply" re-exec ourselves post-fork to resolve this.
2020-10-09 18:53:54 -07:00
Wez Furlong
ab2b2cff45 Add pane:get_lines_as_text() lua method
Allows this:

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

wezterm.on("trigger-vim-with-scrollback", function(window, pane)
  -- Retrieve the current viewport's text.
  -- Pass an optional number of lines (eg: 2000) to retrieve
  -- that number of lines starting from the bottom of the viewport
  local scrollback = pane:get_lines_as_text();

  -- Create a temporary file to pass to vim
  local name = os.tmpname();
  local f = io.open(name, "w+");
  f:write(scrollback);
  f:flush();
  f:close();

  -- Open a new window running vim and tell it to open the file
  window:perform_action(wezterm.action{SpawnCommandInNewWindow={
    args={"vim", name}}
  }, pane)

  -- After vim is up and running we should remove the file,
  -- but we can't do this right now as the window and processing
  -- spawning are asynchronous and we'll probably delete the
  -- file while vim is starting up :-/
  -- os.remove(name);
end)

return {
  keys = {
    {key="E", mods="CTRL",
      action=wezterm.action{EmitEvent="trigger-vim-with-scrollback"}},
  }
}
```

refs: #222
2020-10-09 16:30:04 -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
5fb1414b69 fix clipboard on x11
This was broken by the changes in
aad493ab2a.  The issue was that the
channel send didn't wakeup the receiver.  I'm not sure why, and I tried
a couple of different async channel implementation.

Doing the simplistic solution here works reliably.
2020-10-09 11:07:18 -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
2d521e8f25 server/tab -> server/pane 2020-10-06 15:45:40 -07:00
Wez Furlong
24b290a5da localtab.rs -> localpane.rs 2020-10-06 13:42:51 -07:00
Wez Furlong
ecdc321ab8 ci: update PKGBUILD.template for license file addition
refs: #290
2020-10-06 13:24:35 -07:00
Wez Furlong
461826c8e0 ci: moar freebsd 2020-10-06 09:53:45 -07:00
Wez Furlong
86fd1eb502 ci: tweak freebsd rustup a bit 2020-10-06 09:14:23 -07:00
Wez Furlong
e6c9bcb7d8 ci: maybe have cirrus install rust via rustup
Its freebsd image appears to be stale, so try a more recent
version of rust to fix the build.
2020-10-06 08:48:54 -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