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

964 Commits

Author SHA1 Message Date
Wez Furlong
1212865974 use titlebar bg for right status background
We were using the tab background, which is a bit awkward.

refs: https://github.com/wez/wezterm/issues/2356
2022-08-04 20:45:05 -07:00
Wez Furlong
3f7443f4c1 showkeys/docs: generate copy_mode defaults from the code
Uses `wezterm show-keys --lua --key-table copy_mode` to dump the
actual copy mode key table.  Include that in the docs.

Same for search_mode.
2022-08-04 06:28:32 -07:00
Wez Furlong
decde7c3be wezterm show-keys --lua to print a lua version of the config
This is handy for eg: copying and pasting out the default config.

I think I'll use this to update some parts of the docs in a more
automated fashion.
2022-08-03 18:14:00 -07:00
aznhe21
63d5c00af9 Add new action CopyMode('ClearSelectionMode') 2022-08-03 08:21:04 -07:00
Wez Furlong
1df1f166ca copy mode: move by semantic zone, select by zone
Allows the following assignment actions; I was just over-using z for
no real reason, I'm not suggesting that these are good assignments.

```
      -- move the cursor backwards to the start of the current zone, or
      -- to the prior zone if already at the start
      { key = 'z', mods = 'NONE', action = act.CopyMode 'MoveBackwardSemanticZone' },
      -- move the cursor forwards to the start of the next zone
      { key = 'Z', mods = 'NONE', action = act.CopyMode 'MoveForwardSemanticZone' },
      -- start selecting by zone: both the start point and the cursor
      -- position will be expanded to the containing zone and the union
      -- of those two will be used for the selection
      {
        key = 'z',
        mods = 'CTRL',
        action = act.CopyMode { SetSelectionMode = 'SemanticZone' },
      },
      -- like MoveBackwardSemanticZone by only considers zones of the
      -- specified type
      { key = 'z', mods = 'ALT', action = act.CopyMode { MoveBackwardZoneOfType ='Output' }},
      -- like MoveForwardSemanticZone by only considers zones of the
      -- specified type
      { key = 'Z', mods = 'ALT', action = act.CopyMode { MoveForwardZoneOfType ='Output' }},
```

refs: https://github.com/wez/wezterm/issues/2346
2022-08-02 21:56:53 -07:00
Wez Furlong
aed0e3ebf8 populate pixel dims + dpi in PaneEntry
This makes those fields usable in `wezterm cli list --format json`.

This doesn't change the ABI of the mux protocol, but prior to
this commit, those fields were always 0.

refs: #2319
2022-07-31 11:25:39 -07:00
Wez Furlong
bd846975fa allow wheel events with no mods. allow mouse events in mouse reporting mode
Adjusts how mouse events are matched so that we can now indicate whether
mouse reporting and alt-screen should be considered as part of the event
trigger criteria.

refs: #2173
refs: #581
2022-07-31 09:15:02 -07:00
Funami580
cf423dc614 lua: WheelUp and WheelDown support for mouse_bindings 2022-07-31 07:10:56 -07:00
Wez Furlong
10121790df copy mode: pressing v while in v mode toggles off v mode. Add yank.
refs: https://github.com/wez/wezterm/discussions/2246
refs: https://github.com/wez/wezterm/issues/993#issuecomment-1118512595
2022-07-29 05:00:35 -07:00
Wez Furlong
7e3b35303c gui: allow specifying colors for copy mode and quickselect
refs: https://github.com/wez/wezterm/issues/2320

```lua
return {
  colors = {
    copy_mode_active_highlight_fg={Color="red"},
    copy_mode_active_highlight_bg={Color="blue"},
    copy_mode_inactive_highlight_fg={AnsiColor="Black"},
    copy_mode_inactive_highlight_bg={AnsiColor="White"},
    quick_select_label_fg={Color="white"},
    quick_select_label_bg={Color="blue"},
    quick_select_match_fg={Color="grey"},
    quick_select_match_bg={Color="skyblue"},
  }
}
```
2022-07-28 17:54:07 -07:00
Wez Furlong
4c30131a6f lua: expose metrics to lua 2022-07-26 22:33:52 -07:00
Wez Furlong
bc083ee470 termwiz: ColorSpec now allows for alpha to be tracked
This doesn't really change any behavior, but adjusts the types
such that CSIs that set colors have the potential to track the
alpha channel and that can make it through to the GUI/render layer.
2022-07-26 19:39:53 -07:00
Wez Furlong
39adbb984d Pane::search: expose range, limit. Limit quickselect by default
The recent work on the scrollback made it easier to constrain the
search region, so expose those parameters to the Pane::search
interface and to the mux protocol.

Use those new parameters to constrain quickselect search to
1000 rows above and below the current viewport by default, and
add a new parameter to QuickSelectArgs that allows overriding that
range.

A follow-up commit could make the search/copy overlay issue a series
of searches in chunks so that it avoids blocking the UI when
searching very large scrollback.

refs: https://github.com/wez/wezterm/pull/1317
2022-07-25 18:31:27 -07:00
Wez Furlong
dd6d2e1971 search: debounce searches by ~350ms
In order to avoid searching for "c", "ca", "cat" when typing "cat",
this commit introduces a hard-coded 350ms debounce.

refs: https://github.com/wez/wezterm/issues/1569
2022-07-24 13:30:08 -07:00
Wez Furlong
6d61ceac47 search: fix incorrect highlight in search results
If you typed "cat" in the search, the chances are that wezterm
would kick off a search for "c" before you finished typing,
then "ca" and then finally "cat".

There was a race:

clear by_line highlights,
queue search for "c"
clear by_line highlights,
queue search for "ca"
clear by_line highlights,
queue search for "cat"
accumulate highlights for "c" into by_line
accumulate highlights for "ca" into by_line
accumulate highlights for "cat" into by_line

so the final result was a superposition of all of those results,
which was weird!

The fix is simple: clear by_line when we get the results of
an async search.
2022-07-24 13:15:09 -07:00
Wez Furlong
565b03b1c5 localpane: revise search method implementation
Avoids allocating strings for the non-wrapped line case,
has bounded memory usage compared to prior implementation.
2022-07-24 11:38:06 -07:00
Wez Furlong
c2dfba27f3 termwiz: don't claim that visible_cells is double-ended
It's not; there's important state that only works in forward iteration.
2022-07-24 08:11:11 -07:00
Wez Furlong
d5d161b510 termwiz: add clustered line storage for line
Adds the option to use an alternative clusted line storage for
the cells component of the line.

This structure is not optimal for mutation, but is better structured
for:

* matching/extracting textual content
* using less memory than the prior simple vector

For some contrast: the line "hello" occupies 5 Cells in the cell based
storage; that 5 discrete Cells each with their own tiny string
and a copy of their attributes.

The clustered version of the line stores one copy of the cell
attributes, the string "hello" and some small (almost constant size)
overhead for some metadata.  For simple lines of ascii text, the
clustered version is smaller as there are fewer copies of the cell
attributes.  Over the span of a large scrollback and typical terminal
display composition, this saving is anticipated to be significant.

The clustered version is also cheaper to search as it doesn't require
building a copy of the search text for each line (provided the line is
already in clustered form).

This commit introduces the capability: none of the internals request the
new form yet, and there are likely a few call sites that need to be
tweaked to avoid coersion from clustered to vector form.
2022-07-23 12:03:00 -07:00
Wez Furlong
614900f85c line: introduce possibility of alternate cell backing
Uses an enum as a way to use an alternative to Vec<Cell>, but
doesn't provide that alternative in this commit.
2022-07-23 08:18:34 -07:00
Wez Furlong
e26d634da1 termwiz: refactor Line::visible_cells()
Don't promise that we iterate Cell directly, but things that smell
like Cell.  That makes it easier to adjust internal storage in
a later commit.
2022-07-23 07:03:34 -07:00
Wez Furlong
355f3d3975 fix reloading the global config when the appearance changes
We didn't actually update the global config, just the per-window
configs, which led to weird stale throwbacks to earlier versions
of the config when spawning windows or new panes.

Fix that up by explicitly reloading the global config when the
window appearance is changed.  That isn't ideal as we will reload
once per window, but it's "OK".

While poking at this, I noticed that the get/set config methods
on the termwiztermtab overlay weren't hooked up, and also made
a point of calling those for any overlays during a window config
reload event, so that per-window overrides are more likely to get
picked up and respected.

refs: https://github.com/wez/wezterm/issues/2295
2022-07-22 20:23:04 -07:00
Wez Furlong
67ae0e021f fix tab x button being obscured by tab title text
Need to explicitly pop it in front of the tab text layer so that
the button is physically rendered on top of the tab title.

refs: https://github.com/wez/wezterm/issues/2269
2022-07-21 18:51:21 -07:00
Wez Furlong
badfae7d23 gui-startup event now accepts SpawnCommand
This allows the hook to choose how to handle eg: `wezterm start -- top`.
Previously, if you had implemented this event you would essentially lose
the ability to specify a command that you wanted to launch.

refs: https://github.com/wez/wezterm/issues/284
2022-07-19 19:45:27 -07:00
Wez Furlong
aee66daccb key table activation timeout is now reset on matching key presses
refs: https://github.com/wez/wezterm/issues/1129
2022-07-19 06:18:26 -07:00
Wez Furlong
112feb3374 add MuxTab:set_zoomed and SetPaneZoomState keyassignment
refs: #2284
2022-07-19 05:52:38 -07:00
Wez Furlong
1c32ac95bf cargo update
and address deprecation warnings for csscolorparser
2022-07-17 21:14:47 -07:00
Wez Furlong
ec65b64f30 lua: add tostring impls for window, tab and pane objects 2022-07-16 08:22:10 -07:00
Wez Furlong
910879642f retro tab bar: use resolved palette for colors
This allows tab bar colors to be defined in the toml file and
take effect on the fancy tab bar!

an example can be found at: https://github.com/catppuccin/wezterm/blob/main/dist/catppuccin-frappe.toml

refs: https://github.com/catppuccin/wezterm/issues/6
2022-07-16 06:20:26 -07:00
Wez Furlong
2450fed071 fix padding to the right of retro tab bar
refs: https://github.com/wez/wezterm/issues/2210
2022-07-15 18:40:43 -07:00
Wez Furlong
e277183cb9 overlays: handle resize better
We need to actually tell them that the pane has been resized
so now we do.
2022-07-15 16:32:26 -07:00
Wez Furlong
dba7932e3e add wezterm.gui.get_appearance to retrieve dark mode
This simplifies the "change scheme based on dark mode" example
a lot.  This was previously impossible to do because we didn't
have a lua module associated with the gui until recently, so
the only way to reference a gui-related object was via an
event callback.

refs: https://github.com/wez/wezterm/issues/2258
2022-07-14 16:46:18 -07:00
Wez Furlong
49ab340a92 debug overlay: remember last log line globally
It can be confusing to see the same log lines when re-opening
the debug overlay, so this commit remembers the last line
in a global to make that feel more natural.

Because that causes the initial `OpenGL Initialized!` log to
show only in the first instance of the overlay, that log line
is now changed to debug level and the overlay will now
explicitly log the version information, along with some
brief usage text:

```
Debug Overlay
wezterm version: 20220714-001416-810512c2
OpenGL version: AMD BEIGE_GOBY (LLVM 14.0.0, DRM 3.46, 5.18.10-200.fc36.x86_64) 4.6 (Compatibility Profile) Mesa 22.1.3
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
```
2022-07-14 06:53:41 -07:00
Funami580
cfa95db0cc lua: add pane:is_alt_screen_active() 2022-07-12 17:06:16 -07:00
Wez Furlong
179ec9faaf wezterm.mux.set_active_workspace now updates the gui
Attach the mux events to the frontend workspace reconciliation function
so that the window is updated to match the new workspace.

Ensure that we correctly clear out any overlay panes as part of the
switch: we need to remove them from the mux so that the mux will
correctly identify that the mux is empty when the main panes from
the workspace are closed.  The problem case was that the debug overlay
state was forgotten by the gui when activating the new workspace, but
we didn't tell the mux to kill it off, so subsequently CTRL-D'ing
the windows closed the windows but left the wezterm process running with
no head.

refs: #2248
2022-07-12 09:15:38 -07:00
Wez Furlong
79d2f8197b quickselect: select bottom-most match
We don't really know which of the on-screen matches the user was
looking at when they selected the text, but assume that the one
nearest the bottom of the viewport is the one they want to select,
rather than the one closest to the top.

refs: https://github.com/wez/wezterm/issues/2250
2022-07-12 08:17:14 -07:00
Wez Furlong
8e9546fb04 repl: suppress "nil" results
When evaluating an assignment expression like `foo = "bar"` the result
of the expression is nil and we'd print nil on the next line,
which often startles me as I'm used to other languages where the
result of such an expression is the rvalue that was just assigned.

Let's just suppress nil when it is the result of an evaluation
in the repl for a cleaner look.
2022-07-12 07:45:08 -07:00
Wez Furlong
870ffdf59a ensure that we spawn open calls on a background thread
Otherwise we can block the gui waiting for eg: a freshly opened firefox to
terminate.

See also comment worrying about this in
75066cb522.
That fear was realized but now resolved!

refs: https://github.com/wez/wezterm/issues/2245
2022-07-11 08:03:37 -07:00
Wez Furlong
7a5440694d add distro-defaults feature
The intent is that when set, it changes defaults to something
more suitable for distributions.

I've also added a readme for distro maintainers.

refs: https://github.com/wez/wezterm/issues/1795
2022-07-10 16:34:43 -07:00
Wez Furlong
af5938d414 gui: fix padding color when there are splits
refs: https://github.com/wez/wezterm/issues/2210
2022-07-09 14:53:21 -07:00
Wez Furlong
39e727db58 tab bar: invalidate on resize to avoid gaps on the RHS 2022-07-09 10:45:43 -07:00
Wez Furlong
5913783d1e wayland: fix transparent gap under tab bar
Not sure why this only really showed up with Wayland, because the
issue was that the computed tab bar height ended up being 1 or 2
pixels shorter than the area we had allotted.

This commit resolves it by forcing the height to match, and
then aligning the content to the bottom of that region to avoid
having an undesirable line under the tab.

refs: #1256
2022-07-09 10:29:46 -07:00
Wez Furlong
520a8e306f invalid tab bar on scaling changes
refs: #2208
2022-07-09 07:17:03 -07:00
Wez Furlong
61f01f6ed7 allow parsing attributes from launcher labels 2022-07-08 19:28:33 -07:00
Wez Furlong
8f44dc46d9 exec_domains: allow async callbacks. can now also set label for launcher
The fixup callback can now by async, which makes it possible to use
other async functions in the callback.

There is an additional parameter to wezterm.exec_domain that allows
setting the label that is shown in the launcher menu.
It accepts either a string value or an async callback function
that can be used to compute the label dynamically.
2022-07-08 18:46:09 -07:00
Wez Furlong
d78cc6edb8 new: exec_domains
An ExecDomain is a variation on WslDomain with the key difference
being that you can control how to map the command that would be
executed.

The idea is that the user can define eg: a domain for a docker
container, or a domain that chooses to run every command in its
own cgroup.

The example below shows a really crappy implementation as a
demonstration:

```
local wezterm = require 'wezterm'

return {
  exec_domains = {
    -- Commands executed in the woot domain have "WOOT" echoed
    -- first and are then run via bash.
    -- `cmd` is a SpawnCommand
    wezterm.exec_domain("woot", function(cmd)
      if cmd.args then
        cmd.args = {
          "bash",
          "-c",
          "echo WOOT && " .. wezterm.shell_join_args(cmd.args)
        }
      end
      -- you must return the SpawnCommand that will be run
      return cmd
    end),
  },
  default_domain = "woot",
}
```

This commit unfortunately does more than should go into a single
commit, but I'm a bit too lazy to wrangle splitting it up.

* Reverts the nil/null stuff from #2177 and makes the
  `ExtendSelectionToMouseCursor` parameter mandatory to dodge
  a whole load of urgh around nil in table values. That is
  necessary because SpawnCommand uses optional fields and the
  userdata proxy was making that a PITA.
* Adds some shell quoting helper functions
* Adds ExecDomain itself, which is really just a way to
  to run a callback to fixup the command that will be run.
  That command is converted to a SpawnCommand for the callback
  to process in lua and return an adjusted version of it,
  then converted back to a command builder for execution.

refs: https://github.com/wez/wezterm/issues/1776
2022-07-07 16:38:14 -07:00
Wez Furlong
dbc2c85361 add window:toggle_fullscreen()
You can start a window in full screen mode using something like:

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():toggle_fullscreen()
end)

return {
}
```

refs: #177
refs: #284
2022-07-06 23:57:32 -07:00
Wez Furlong
8853df02ca lua: add window:maximize() and window:restore() methods
Implemented on macOS only for the moment.

refs: https://github.com/wez/wezterm/issues/284
2022-07-06 23:11:02 -07:00
Wez Furlong
533e52c589 lua: make gui_window() reconcile workspace
reconciling causes gui windows to be created and allows for stuff like
this, that would otherwise fail because the gui window hadn't been
created yet.

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():set_inner_size(1200, 1200)
end)

return {
}
```
2022-07-06 18:52:14 -07:00
Wez Furlong
3e01d44ece add window:set_position window:set_inner_size 2022-07-06 18:49:39 -07:00
Wez Furlong
87ce88b924 lua: add wezterm.gui.gui_window_for_mux_window()
This is the inverse of wezterm.mux.get_window()
2022-07-06 15:39:43 -07:00