Commit Graph
1344 Commits
Author SHA1 Message Date
Wez Furlong 242adbbcfe wezterm: kill processes attached to panes when detaching from mux 2020-09-27 19:26:45 -07:00
Wez Furlong b744d986af wezterm: break out of pty reader loop when pane is removed
If a pane is killed via mux manipulation, the reader didn't have
a way to notice this and could keep reading the data in a loop.

This commit adds an atomic boolean to signal back from the mux
to the reader.

This isn't perfect; the reader thread may still be blocked in
read until the underlying process is really killed.
2020-09-27 18:38:48 -07:00
Wez Furlong c5efd94bb8 wezterm: improve pane resize logic
This uses a similar approach to that used by tmux; when resizing,
a size delta is computed in each axis and that value is distributed
across the splits in that dimension.

For a small resize by 1 cell this tends to bias towards adjusting
the top/left node.

For a large resize (eg: maximizing/restoring) the distribution tends
to share across the splits in that dimension, effectively scaling
them approximately proportionally, more or less preserving the relative
scale of the splits.

refs: https://github.com/wez/wezterm/issues/157#issuecomment-699672914
2020-09-27 16:07:08 -07:00
Wez Furlong 6eccd6d2d7 wezterm: un-zoom while calculating pane sizes in resize 2020-09-27 14:07:56 -07:00
Wez Furlong 957cc592a6 wezterm: allow using {} (an empty table) to represent None in lua
`wezterm.action{ExtendSelectionToMouseCursor=nil}` doesn't produce an
`ExtendSelectionToMouseCursor(None)` value because a table value of
`nil` is equivalent to that key not being present and lua sees just
an empty table.

Instead we need to accept `ExtendSelectionToMouseCursor={}` a valid
way to indicate an `Option::None` which is what this commit does.

Due to weirdness that I haven't had a chance to run down, passing
that value through `wezterm.action` doesn't produce the intended
value, so I'm adjusting the docs to show to specify an alternative
syntax for this as part of this commit.

refs: https://github.com/wez/wezterm/issues/282
2020-09-27 10:45:11 -07:00
Wez Furlong 85dddc0ef1 wezterm: add some trace diagnostics for font render metrics
refs: https://github.com/wez/wezterm/issues/263
2020-09-27 09:48:33 -07:00
Wez Furlong 1eab37b677 wezterm: fix panic when a large paste is chunked in an emoji
wezterm splits pastes into chunks of 1KB.  If that chunk was in
the middle of a UTF8 multibyte sequence, the rust string library
would panic.

This commit rounds the chunk size up to the next character
boundary.

closes: https://github.com/wez/wezterm/issues/281
2020-09-27 09:38:34 -07:00
Wez Furlong 9d33073d70 wezterm: fix infinite recursion when no valid fallbacks are present
This config reproduces the issue:

```lua
local wezterm = require "wezterm"

return {
  font_size = 12.0,
  font_dirs = {"fonts"}, -- relative to this config file
  font_locator = "ConfigDirsOnly",
  font = wezterm.font_with_fallback({
    -- this is an invalid font
    "does not exist",
    -- this is a valid font, with only symbols
    "Font Awesome 5 Free Solid",
  }),
}
```

the existing protections were a bit simplistic, so now we have a
dedicated error type for this case and that stops fallback processing
from recursing.

closes: https://github.com/wez/wezterm/issues/279
2020-09-27 09:02:43 -07:00
Wez Furlong 0e8ac1851d wezterm: fixup per-pane overlay rendering and handling
refs: https://github.com/wez/wezterm/issues/157
2020-09-27 00:19:05 -07:00
Wez Furlong 146b4465ba wezterm: update mux protocol for splits
refs: https://github.com/wez/wezterm/issues/157
2020-09-26 20:14:28 -07:00
Wez Furlong 2901473314 wezterm: rename CloseActivePane to CloseCurrentPane
refs: https://github.com/wez/wezterm/issues/157#issuecomment-699532484
2020-09-26 11:52:12 -07:00
Wez Furlong 2d3f4f9bf9 wezterm: guess at cwd associated with pty on linux
We still prefer to consume the OSC 7 value, but can fall back
to guessing the cwd for a target process.
2020-09-26 11:51:21 -07:00
Wez Furlong 5031a53ff9 wezterm: add CloseActivePane key assignment
This removes the active pane from the current tab, causing the
tab to close if it was the last remaining pane in the tab.

```lua
  {key="W", mods="CTRL", action="CloseActivePane"},
```

refs: https://github.com/wez/wezterm/issues/157
2020-09-26 10:30:17 -07:00
Wez Furlong 81ba73d5b8 wezterm: display tab indices in tab bar by default
More details in the included changelog update

refs: https://github.com/wez/wezterm/issues/157#issuecomment-699520149
2020-09-26 09:52:16 -07:00
Wez Furlong 6708ea4b36 window: normalize SHIFT modifier state
When a keypress is ASCII uppercase and SHIFT is held, remove SHIFT
from the set of active modifiers.

refs: https://github.com/wez/wezterm/issues/157#issuecomment-699516096
2020-09-26 09:17:51 -07:00
Wez Furlong 121c090f22 wezterm: implement leader key binding support
This commit introduces a new `leader` configuration setting
that acts as a modal modifier key.

If leader is specified then pressing that key combination
will enable a virtual LEADER modifier.

While LEADER is active, only defined key assignments that include
LEADER in the `mods` mask will be recognized.  Other keypresses
will be swallowed and NOT passed through to the terminal.

LEADER stays active until a keypress is registered (whether it
matches a key binding or not), or until it has been active for
the duration specified by `timeout_milliseconds`, at which point
it will automatically cancel itself.

Here's an example configuration using LEADER:

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

return {
  -- timeout_milliseconds defaults to 1000 and can be omitted
  leader = { key="a", mods="CTRL", timeout_milliseconds=1000 },
  keys = {
    {key="|", mods="LEADER|SHIFT", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
    -- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
    {key="a", mods="LEADER|CTRL", action=wezterm.action{SendString="\x01"}},
  }
}
```

refs: https://github.com/wez/wezterm/issues/274
2020-09-25 21:38:49 -07:00
Wez Furlong 3383bc5684 wezterm: add TogglePaneZoomState key binding (ctrl+shift+Z)
This toggles the zoom state for the active pane in the current tab.

refs: https://github.com/wez/wezterm/issues/157
2020-09-24 22:20:33 -07:00
Wez Furlong 6469cba8e1 wezterm: fix overlays to fill whole tab, not active pane size
refs: https://github.com/wez/wezterm/issues/157
2020-09-24 10:30:16 -07:00
Wez Furlong d66ee6a5c6 wezterm: tab navigator: show number of panes in list
refs: https://github.com/wez/wezterm/issues/157
2020-09-24 10:30:05 -07:00
Wez Furlong 7b855fbd05 wezterm: fixup tests 2020-09-23 21:20:48 -07:00
Wez Furlong 74b10996dc wezterm: simplify AdjustPaneSize
refs: https://github.com/wez/wezterm/issues/157
2020-09-23 21:10:26 -07:00
Wez Furlong 84753a8261 wezterm: add ActivatePaneDirection key assignment
This allows moving to an adjacent pane in the specified direction.

refs: https://github.com/wez/wezterm/issues/157
2020-09-23 21:01:40 -07:00
Wez Furlong 97ff359a18 wezterm: add AdjustPaneSize keyassignment
This allows resizing a pane directionally.
2020-09-23 20:26:25 -07:00
Wez Furlong 86cc214344 wezterm: allow dragging pane edges to resize them
refs: https://github.com/wez/wezterm/issues/157
2020-09-23 18:01:48 -07:00
Wez Furlong f9c9510691 wezterm: improve split positioning
The math for computing the position for nested splits was a bit off.
2020-09-23 09:19:23 -07:00
Wez Furlong c2100d96c3 wezterm: Implement basic splits in the UI.
This commit provides the heart of the split functionality.
It adds a couple of key assignments (that are not finalized)
for splitting the active pane horizontally or vertically.

Clicking in a pane will activate it.
Selection is constrained to the active pane.
Resizing a window will grow/shrink the right/bottom side of a split.
The scrollbar applies to the active split.

There's not yet a way to resize a split at all.
There's not yet a key assignment for changing the active split.

The software renderer doesn't know how to render the splits correctly.

refs: https://github.com/wez/wezterm/issues/157
2020-09-22 22:12:11 -07:00
Wez Furlong ec468acb40 panes: adopt zipper based bintree for managing panes
This simplifies the logic in the tab.rs module
2020-09-20 10:20:40 -07:00
Wez Furlong 3d54a542bf wezterm: add PaneNode tree to Tab
This expands the data model for Tab so that it can record a binary
tree of panes; this allows for conceptually splitting a Pane either
horizontally or vertically.

None of the other layers know about this concept yet.

refs: https://github.com/wez/wezterm/issues/157
2020-09-20 08:27:44 -07:00
Wez Furlong a6316315bb wezterm: introduce concept of Pane to the Mux model
This adds an extra level of indirection to the Mux model;
previously we allowed for Windows to contain an ordered
collection of Tabs, where each Tab represented some kind
of pty.

This change effectively renames the existing Tab trait to Pane
and introduces a new Tab container, so the new model is that
a Window contains an ordered collection of Tabs, and each Tab
can have a single optional Pane.

refs: https://github.com/wez/wezterm/issues/157
2020-09-20 08:27:32 -07:00
Wez Furlong 3484478ba2 wezterm: speculative workaround for RDP disconnect panic
Attempt to recover in the case where we cannot re-allocate
our vertex buffers; try to restore the prior dimensions
and resize the OS window to match.

refs: https://github.com/wez/wezterm/issues/265
2020-09-12 22:33:35 -07:00
Wez Furlong 94fb5094a4 wezterm: compile in default color schemes
Rather than scanning directories and reading in ~230 files on startup,
do the scan at build time so that we're parsing from memory rather
than local storage.

This should shave a bit of time off the startup, although I
haven't measured this, and I've only run this on a remote
linux system thus far.

refs: https://github.com/wez/wezterm/issues/264
2020-09-10 21:46:45 -07:00
Wez Furlong 3090c9bb68 fix build for windows 2020-09-10 15:00:43 -07:00
Wez Furlong aae287c4f2 fix filedescriptor::poll on macos
Need to use the subsecond microsecond value, rather than the total
microsecond value, otherwise `select(2)` will yield EINVAL.

The wezterm changes show where this error was bubbling up
and breaking the tls client code.
2020-09-10 13:58:14 -07:00
Wez Furlong 99b8fb2612 wezterm: add tab_max_width config option
This allows setting the maximum width of a tab in the tab tab.
It defaults to 16 glyphs in width.

refs: https://github.com/wez/wezterm/issues/255
2020-08-29 10:45:01 -07:00
Wez Furlong 5457c09590 wezterm: enable_wayland = false by default
refs: https://github.com/wez/wezterm/issues/224
2020-08-16 09:50:00 -07:00
Wez Furlong 1209cde2b1 Add bold_brightens_ansi_colors configuration option
refs: https://github.com/wez/wezterm/issues/244
2020-07-18 09:02:56 -07:00
Wez Furlong 8266d40944 maybe fixup build 2020-07-13 23:13:38 -07:00
Wez Furlong 888cded0e3 x11: remove Rc cycle between XConnection, Window, bitmaps
refs: https://github.com/wez/wezterm/issues/238

It's not a smoking gun, but helps clean up the valgrind output
2020-07-13 09:00:00 -07:00
Wez Furlong 5b654710cb wezterm: fix already mutably borrowed: BorrowError when switching tabs
Not sure why this didn't bubble up earlier, but the issue was introduced
by https://github.com/wez/wezterm/commit/4e6357b21829d8549ebbb0750d8f7faad9fffc70

And it was not setting focus=true on the new tab either :-/

refs: https://github.com/wez/wezterm/issues/232
2020-06-22 17:08:29 -07:00
Wez Furlong 2b2555c62a wezterm: avoid extraneous work in search overlay
viewport changes could do a little bit more than they needed
to when the search overlay was active.  Guard against that by
checking to see if the viewport is already set to the new position.
2020-06-21 22:44:11 -07:00
Wez Furlong 076cf3d177 wezterm: teach renderer about overline
This commit adds an overline glyph which is simply a line drawn at
the top of the cell.

Due to the way that we use a single glyph for the line layer, this
actually adds a handful of combination glyphs for the different
underline, overline and strikethrough possibilities.

It's getting a bit hefty.  Adding another similar attribute in
the future (eg: maybe wiggly underlines?) might prove to be too
much for the simple approach we have right now.

```bash
printf "\x1b[53moverline\x1b[0m\n"
```
2020-06-20 23:18:52 -07:00
Wez Furlong 4e6357b218 term: enable DECSET 1004 Focus Reporting
This is enabled only for local terminals for now; the multiplexer
protocol will need to be extended to carry this signal.
2020-06-20 22:01:56 -07:00
Wez Furlong 843ce152ec wezterm: ActivateTab now accepts negative numbers
This allows setting up shortcuts relative to the final tab in
a window, rather than always being relative to the first.

The default assignment for CTRL+SHIFT+9 is now `ActivateTab=-1`
as a convenient way to always reach the last tab.

refs: https://github.com/wez/wezterm/issues/228
2020-06-20 12:45:09 -07:00
Luben Karavelov 5a76302c84 Update to allsorts-0.4 2020-06-20 12:31:11 -07:00
Wez Furlong 8f1f1a65ea window: handle opengl context loss on windows.
With this commit, we now survive a reinstall or upgrade of the nvidia
drivers on my Windows sytem without crashing.

This commit allows notifying the application of the context loss
so the application can either try to reinit opengl or open a new
window as a replacement and init opengl there.

I've not had success at reinitializing opengl after a driver upgrade;
it seems to be persistently stuck in a state where it fails to allocate
a vertex buffer.

SO, the state we have now is that we try to reinit opengl on a new
window, and if that fails, leave it set to the software renderer.

This isn't a perfect UX, but it is better than terminating!

refs: https://github.com/wez/wezterm/issues/156
2020-06-16 21:17:48 -07:00
Wez Furlong d9f84da6ec fonts: fix second parameter of wezterm.font
The following configuration now works as intended:

```lua
local wezterm = require 'wezterm';
return {
  -- font = wezterm.font('JetBrains Mono'),
  font_rules = {
    {
      italic = false,
      intensity = "Normal",
      font = wezterm.font("JetBrains Mono"),
    },
    {
      italic = true,
      font = wezterm.font("JetBrains Mono", {italic=true}),
    },
    {
      intensity = "Bold",
      font = wezterm.font("JetBrains Mono", {bold=true}),
    },
    {
      italic = true,
      intensity = "Bold",
      font = wezterm.font("JetBrains Mono", {bold=true, italic=true}),
    }
  },
}
```
2020-06-16 08:27:35 -07:00
Wez Furlong 500e404db4 window: move opengl post-init to a callback on the trait
This allows potentially automatically re-initializing the
state if the context is lost.
2020-06-14 21:47:40 -07:00
Wez Furlong a5270c767f wezterm: make sure we don't lose alt on !macos 2020-06-13 23:06:08 -07:00
Wez Furlong 2803e8fc58 wezterm: improve left vs right alt behavior on macos
This commit allows distinguishing between left and right alt
modifiers at the window layer.  So far only macos provides
this additional information.

Expand the logic that decides whether Alt should emit the
composed key or act as the raw key with the Alt modifier flag
set so that we can set that behavior separately for the left
and right modifiers on systems that support it, and use the
existing config for systems that don't support it.

The default settings for these flags is that Left Alt will
send the uncomposed key + Alt modifier while the Right Alt
will behave more like AltGr (which is typically on the RHS
of the keyboard) and send the composed key.

This gives more flexibility by default and hopefully matches
expectations a bit better.

refs: https://github.com/wez/wezterm/issues/216
2020-06-13 22:45:13 -07:00
Wez Furlong 8250f9e4cf wezterm: set a reasonable default LANG on macos
If LANG isn't set then ask NSLocale for the language and country code
and see if we can conjure up a valid UTF-8 locale name.  If so,
export that in the LANG environment for our children to inherit.

refs: https://github.com/wez/wezterm/issues/220
refs: https://github.com/wez/wezterm/issues/216
2020-06-13 20:41:52 -07:00