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

65 Commits

Author SHA1 Message Date
Wez Furlong
37055d2fab
expose some mux domain stuff to lua
refs: https://github.com/wez/wezterm/issues/2933
2023-01-09 08:38:05 -07:00
Wez Furlong
02eb0b4294
mux: rename Mux::get() -> try_get(), add "infallible" Mux::get()
This allows removing a bunch of unwrap/expect calls.

However, my primary motive was to replace the cases where we used
Mux::get() == None to indicate that we were not on the main thread.

A separate API has been added to test for that explicitly rather than
implicitly.
2022-12-19 11:55:35 -07:00
Wez Furlong
478cc59be3
mux: Mux is now Send+Sync 2022-12-19 11:54:02 -07:00
Wez Furlong
920ee853b3
mux: switch RefCell to RwLock internally
This is a step towards making it Send+Sync.

I'm a little cagey about this in the long term, as there are some mux
operations that may technically require multiple fields to be locked for
their duration: allowing free-threaded access may introduce some subtle
(or not so subtle!) interleaving conditions where the overall mux state
is not yet consistent.

I'm thinking of prune_dead_windows kicking in while the mux is in the
middle of being manipulated.

I did try an initial pass of just moving everything under one lock, but
there is already quite a lot of mixed read/write access to different
aspects of the mux.

We'll see what bubbles up later!
2022-12-19 11:52:38 -07:00
Wez Furlong
696148941c
Rc<Tab> -> Arc<Tab> 2022-12-19 11:52:38 -07:00
Wez Furlong
6e06b9af02
mux: Pane is now required to be Send+Sync. Use Arc<dyn Pane> 2022-12-19 11:52:33 -07:00
Theo Beers
a135f53659 Fix compiler warning 2022-11-05 09:05:35 -07:00
Wez Furlong
b1faba9d8a deps: upgrade finl_unicode to 1.2 2022-10-23 12:07:00 -07:00
Wez Furlong
4e5945c061 Add ResetTerminal and pane:inject_output method
refs: https://github.com/wez/wezterm/discussions/2606
2022-10-08 10:25:22 -07:00
Wez Furlong
cd9376d923 tab:panes() and tab:panes_with_info() now return all panes
and not just the zoomed pane if a pane is zoomed
2022-09-20 08:10:06 -07:00
Wez Furlong
85db555b37 deps: update finl_unicode 2022-09-16 07:47:33 -07:00
Wez Furlong
42e4a51a28 lua: no longer distinction between gui and mux panes
There is no gui-specific functionality for PaneObject, so
just fold everything into MuxPane and use that.
2022-09-11 07:05:48 -07:00
Wez Furlong
a99920da0b lua-api-crates/mux: refactor
split out multiple multiples
2022-09-11 06:44:55 -07:00
Wez Furlong
96c4e7e9b9 Switch to finl_unicode for grapheme clustering
According to its benchmarks, it's almost 2x faster than
unicode_segmentation.  It doesn't appear to make a visible
difference to `time cat bigfile`, but I'll take anything
that gives more headroom for such little effort of switching.
2022-09-10 07:15:49 -07:00
unrelentingtech
c1225281dc colors: add base16 indexed colors 16-21 like base16-shell sets 2022-09-08 06:51:01 -07:00
unrelentingtech
9a72c03631 colors: fix base16 cursor having the same bg and fg 2022-09-08 06:51:01 -07:00
Wez Furlong
4fead3171e macos: report max_fps in ScreenInfo
Other platforms can be added later
2022-08-19 21:02:51 -07:00
Wez Furlong
cab7feb48c deps: update serde_yaml 2022-07-31 20:37:19 -07:00
Wez Furlong
742fe5f462 wezterm.format: now supports rgba colors
```
> wezterm.format{{Background={Color="rgba(255,0,0,0.5)"}}, {Text="wat"}}
"\u{1b}[48:4::255:0:0:127mwat\u{1b}[49m"
```
2022-07-26 21:12:12 -07:00
Wez Furlong
23f36b2afb json: fix visited hash set
We were skipping scalars/primitive values, which wasn't the intent.

refs: https://github.com/wez/wezterm/issues/2302
2022-07-25 07:25:41 -07:00
Wez Furlong
50d5f94ab0 color schemes: add alias concept
Various color schemes have been duplicated as they have been added to
different scheme collections.  They don't always have identical names
(eg: some remove spaces) and sometimes they have very different names
(eg: _bash vs. nightfox, or Miu vs. Blazer).

We already detected duplicates from different collections but previously
we would omit those dupes.

This commit allows us to track those duplicates by recording their
aliases.

When we write out our data, we only include "interesting" alias names;
those where the name isn't trivially identical.

Some scheme collections (eg: iterm2 color schemes) have duplicates
(eg: zenbones and zenbones_light are identical) and we have previously
shipped with both of those names, so we special case to emit dupes
for which we have prior version information in order to avoid
breaking backwards compatibility for our users.

In the doc generation we can generate links to the aliases if we
included them, but also note about the other names and how we don't
include them.  That is so that someone searching the docs for say
"_bash" can discover that it is actually a duplicate of "nightfox" and
use nightfox instead.
2022-07-20 07:32:46 -07:00
Wez Furlong
112feb3374 add MuxTab:set_zoomed and SetPaneZoomState keyassignment
refs: #2284
2022-07-19 05:52:38 -07:00
Wez Furlong
dd327617b1 lua: add wezterm.time.call_after and wezterm.reload_configuration
These allow setting up some basic timers and constructing time-dependent
config files.

Needs to be used respsonsibly!
2022-07-18 07:37:41 -07:00
Wez Furlong
c81dabd76b rustfmt 2022-07-17 21:55:39 -07:00
Wez Furlong
1c32ac95bf cargo update
and address deprecation warnings for csscolorparser
2022-07-17 21:14:47 -07:00
Wez Furlong
85fb78d788 lua: add wezterm.time and Time object
Includes a method for determining sunrise/sunset.
2022-07-17 11:38:02 -07:00
Wez Furlong
5e60743519 lua: add wezterm.procinfo module 2022-07-16 08:49:58 -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
8484248010 add wezterm.color.save_scheme for exporting color schemes 2022-07-14 23:22:02 -07:00
Wez Furlong
181401a2ca add lua functions for importing color scheme files 2022-07-14 23:03:18 -07:00
Wez Furlong
e566885e7f colors: move wezterm.get_builtin_color_schemes to wezterm.colors.get_builtin_schemes 2022-07-14 21:52:49 -07:00
Wez Furlong
548adf484b add wezterm.color.get_default_colors 2022-07-14 21:41:39 -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
f9ab69950a color schemes: add version metadata
Record the version in which we first saw a color scheme.
For schemes from iterm2-color-schemes, we just assume that
we've had them forever as it isn't easy to reverse engineer
that metadata.

Everything else is tagged as 'nightly builds only' and I'll update
that to match the version number in the next release.

Newly discovered items will be added with 'nightly builds only'
from this point onwards.
2022-07-14 08:45:29 -07:00
Wez Furlong
810512c2c5 colors: refine importer
Adjust importer to read directly from the source .itermcolors
files in the upstream repo.  Extract some author information
from the comments in those files.

All data is now fetched (and cached!) via relatively minimal
http requests rather than requiring a git repo locally.

Also search for .yml files in base16 repos; found another
couple of schemes this way.

The toml files under assets/colors are no longer read by
anything in the repo. I plan to remove them, but since the
docs reference them as examples, I will first ensure that
there are docs and tooling that explains how to write and
share your own scheme files.
2022-07-14 00:14:16 -07:00
Wez Furlong
222853bdc5 color schemes: move other color scheme format code to color-funcs
I want to add lua funcs for importing schemes; this is a step towards
that.
2022-07-13 21:29:51 -07:00
Wez Furlong
aa697c72ba color: refactor docs, add a couple more methods
Moved the gradient function into the color module, but kept an alias
under the old name.

Gradients now return color objects.

Converting colors to string now uses rgba format when alpha is not 100%.
2022-07-12 07:45:08 -07:00
Wez Furlong
c8ca2054f6 lua: add wezterm.color.extract_colors_from_image
This function can be used to extra distinct colors from
an image to be fed into eg: color scheme generation.
2022-07-11 17:46:36 -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
cfd9c0b364 colors: add RYB based complement
Now you can complement_ryb yellow to arrive at a purple color,
just like you were taught in art class.
2022-07-11 00:18:39 -07:00
Wez Furlong
463ca2fa29 add wezterm.color module for working with colors
wezterm.color.parse() returns a color object that can be assigned in the
wezterm color config, and that can be used to adjust hue, saturation and
lightness, as well as calculate harmonizing colors (complements, triads,
squares) from the RGB/HSL color wheel.
2022-07-10 23:41:18 -07:00
Wez Furlong
4a4787ff41 add wezterm.json_parse and wezterm.json_encode 2022-07-10 09:30:54 -07:00
Wez Furlong
8bad7dee58 wezterm.format: accept "ResetAttributes" to reset attributes 2022-07-09 16:19:30 -07:00
Wez Furlong
c906179bb9 wayland: use zwlr_output_manager if available
This seems to have better names and also returns fractional
scaling information.
2022-07-08 13:40:28 -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
8f45cb8dfa lua: add MuxWindow::gui_window() method
This is the inverse of Window::mux_window().
2022-07-06 15:52:31 -07:00
Wez Furlong
f7848cf96d lua: reduce a bit of boilerplate around registering wezterm.submodule 2022-07-06 15:26:21 -07:00
Wez Furlong
6334e3bc44 rename wezterm.window to wezterm.gui
This better reflects what it operates on
2022-07-06 13:52:19 -07:00
Wez Furlong
5caa59577e lua: add screens.active 2022-07-06 13:17:31 -07:00
Wez Furlong
a6cf13e1e2 lua: add wezterm.window.screens()
Currently implemented on X11 only, this function returns information
about the geometry of the screen(s).

This is taken from the same source of information we use for the
`--position` CLI argument to `wezterm start`.

```
> wezterm.window.screens()
{
    "by_name": {
        "DisplayPort-1": {
            "height": 2160,
            "name": "DisplayPort-1",
            "width": 3840,
            "x": 0,
            "y": 0,
        },
    },
    "main": {
        "height": 2160,
        "name": "DisplayPort-1",
        "width": 3840,
        "x": 0,
        "y": 0,
    },
    "origin_x": 0,
    "origin_y": 0,
    "virtual_height": 2160,
    "virtual_width": 3840,
}
```
2022-07-06 08:35:05 -07:00