1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-22 12:17:19 +03:00
Commit Graph

176 Commits

Author SHA1 Message Date
Wez Furlong
4ec48b1245 gifs: start at frame 0, not 1!
This fixes the panic that @mborejdo reported in
<https://matrix.to/#/!PirwUBcuIlTXwNveYz:matrix.org/$skjhC1EgMG5x0Wte0i6JquMHkQK2mST2zJoB_qrLMRc?via=matrix.org>
2021-03-12 08:39:53 -08:00
Wez Furlong
1097f329cf fixup x position for new tab button 2021-03-11 21:25:54 -08:00
Wez Furlong
eb4323ee59 add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';

-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)

-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)

return {
  tab_bar_style = {
    active_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#2b2042"}},
      {Text=SOLID_LEFT_ARROW},
    }),
    active_tab_right = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#2b2042"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
    inactive_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#1b1032"}},
      {Text=SOLID_LEFT_ARROW},
    }),
    inactive_tab_right = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#1b1032"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
  }
}
```
2021-03-11 21:22:10 -08:00
Wez Furlong
62d1d11eaf fall back to single frame gif parse if animated mode fails
At least we'll show something if we have a malformed gif.
2021-03-11 19:54:41 -08:00
Wez Furlong
9b3d35623f handle image decoding errors and return a placeholder
https://i.giphy.com/media/3owvKqP4VSydZE4pvq/200w.gif cannot
be decoded as an animated gif due to this error: `No end code in lzw stream`

Ensure that we don't completely fail to process the render phase
as a result.
2021-03-11 19:45:48 -08:00
Wez Furlong
b8390b3f7a animated images: now schedule repaint based on next frame time
Previously, invalidation for animation was driven by the cursor
blink rate, which meant that animated gifs/pngs could not play
faster than 5fps (default blink interval is 200ms).

This commit calculates the next invalidation time based on the
closes next frame time of all animated cells in the viewport.
2021-03-11 08:14:39 -08:00
Wez Furlong
c5cb0ef66d Added support for animated gifs and pngs
This is first draft; the animation rate is currently tied
to the cursor_blink_rate setting, so if the gif has frames that
are intended to display more frequently than that, they will
animate more slowly.

Animation is only carried out while the window has focus.
Animation increases the load on the GPU and thus uses more power.

It's kinda fun to stick one of these animated pixel gifs in the background:
https://imgur.com/gallery/F9DAH
2021-03-11 00:41:54 -08:00
Wez Furlong
182a4d068b ensure that we only use the default size when spawning new windows 2021-03-10 00:19:50 -08:00
Wez Furlong
83e9d672a4 spawning a new window should use the size from the config
rather than the size of the current window.
2021-03-10 00:15:26 -08:00
Wez Furlong
18cb179227 x11: query Xft.dpi from the root window
We should now be using the root window specified default dpi
if the dpi is left unspecified in the wezterm configuration.

refs: #515
2021-03-08 22:19:44 -08:00
Wez Furlong
5f1bb0a1bc "de-bounce" lua event callbacks
During a live resize, we could queue up a lot of `window-resized`
events, which is undesirable.

This commit introduces a simple but effective mechanism to manage this;
a given event can have at most one executing and one pending copy.

So if we get a burst of resize events (eg: during a live window resize)
that might have previously queued hundreds of discrete events, we now
get a more manageable situation with 1 executing and 1 queued.

With this change, a given event can only have 1 executing instance at a
time (with the exception that the open-uri event doesn't go through this
mechanism).

refs: https://github.com/wez/wezterm/issues/291
2021-03-07 18:11:27 -08:00
Wez Furlong
9c19fa1929 Add window-config-reloaded event
refs: #291
2021-03-07 15:06:04 -08:00
Benoit de Chezelles
683d8e96e8 windows: Add option to treat left ctrl-alt as altgr
The previous behavior was to always treat ctrl-alt as altgr on Windows,
this has been done to better support altgr through a VNC session,
but this is very unintuitive when you don't need this behavior.

ref: #472
2021-03-07 12:52:03 -08:00
Wez Furlong
ba5d50ba9e add window-resized event
This is to support <https://github.com/wez/wezterm/issues/291>.

The window resized event happens asynchronously wrt. processing
a window resize, triggering at the end of the normal window
resize handling.

This commit introduces the notion of whether we are in full screen
mode or not in the underlying event callback, which is useful to
gate the desired feature, which is: when in full screen mode,
increase the padding for the window to center its content.

While poking around at this, I noticed that we weren't passing
the per-window config down to the code that computes the quad
locations for the window.

This commit also changes the font size increase/decrease behavior
so that in full screen mode it doesn't try to resize the window.

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

wezterm.on("window-resized", function(window, pane)
  local window_dims = window:get_dimensions();
  local pane_dims = pane:get_dimensions();
  local overrides = window:get_config_overrides() or {}

  if not window_dims.is_full_screen then
    if not overrides.window_padding then
      -- not changing anything
      return;
    end
    overrides.window_padding = nil;
  else
    -- Use only the middle 33%
    local third = math.floor(window_dims.pixel_width / 3)
    local new_padding = {
      left = third,
      right = third,
      top = 0,
      bottom = 0
    };
    if overrides.window_padding and new_padding.left == overrides.window_padding.left then
      -- padding is same, avoid triggering further changes
      return
    end
    overrides.window_padding = new_padding

  end
  window:set_config_overrides(overrides)
end);

return {
}
```
2021-03-07 11:54:15 -08:00
Wez Furlong
336f209ede Revert and gate shaping changes
I'm calling it a temporary defeat on the shaping changes;
this commit effectively reverts the series of changes made
to support slicing up ligatures like `->` when the cursor
moves through them.

They've introduced so many issues and I've spent hours
that haven't resulted in a complete solution, so I've
disabled those changes by putting them behind a boolean
option.

I'll revisit them after I've cut the next release.

refs: https://github.com/wez/wezterm/issues/478
2021-03-06 23:49:37 -08:00
Wez Furlong
dcb6fec28f don't kill pane when closing copy or search mode overlays
I recently introduced this bug when tidying up reaping overlay panes.
2021-03-06 13:46:30 -08:00
Wez Furlong
30144ef964 more guesswork to compensate for shaping weirdness 2021-03-06 13:38:38 -08:00
Wez Furlong
ac3ac43c2b warn instead of panic if there's already something assigned
I saw this trigger and couldn't repro; I want to understand it
better when it next occurs.
2021-03-06 12:56:36 -08:00
Wez Furlong
9cfa93bf8b tidy up some of the texture atlas invalidation
There was a bit of redundancy with things that happen
inside some of these calls, so centralize and clarify it.
2021-03-06 10:25:39 -08:00
Wez Furlong
f0527f646c simplify shape preprocessing
Manual test scenario:

```
wezterm -n --config adjust_window_size_when_changing_font_size=false --config 'exit_behavior="Hold"' start -- sh -c "echo '(...)'"
```

then CTRL +/- to change font size; the first cell of the `...` was
previously random garbage, now is more consistent.

refs: https://github.com/wez/wezterm/issues/478
2021-03-06 10:19:59 -08:00
Wez Furlong
cfed798e79 window: allow window layer to hold per-window config
This is to allow for eg: hotkey to change window decorations
(https://wezfurlong.org/wezterm/config/lua/window/set_config_overrides.html)

So far only macos actually keeps a per-window config.
Hopefully this still compiles for windows and x11.
2021-03-04 23:05:44 -08:00
Wez Furlong
1178639a22 windows: implement decoration setting, change to bitfield
Can now set `window_decorations = "TITLE|RESIZE"` or variations
on those flags.  `NONE` is a shortcut for no flags.
2021-03-04 09:40:38 -08:00
Wez Furlong
3356a3a149 don't trigger status bar update after each paint or mouse move
mouse move events in the tab bar, and paint events, could cause
the title bar state to be recomputed.

Make sure that we don't trigger the status event to trigger for those.

refs: https://github.com/wez/wezterm/issues/500
2021-03-03 23:53:09 -08:00
Wez Furlong
7e1d16e671 Add SUPER+Drag to drag the window 2021-03-03 23:45:02 -08:00
Wez Furlong
5a5d08080c gui: allow dragging the window by non-tab areas in tab bar
I've only tested this on macos, but it should be cross platform,
with the caveat that Wayland doesn't let a window position itself,
so this won't work there.
2021-03-03 23:29:18 -08:00
Wez Furlong
4834a29791 macos: support disabling the titlebar
This isn't fully baked yet, so I'm not documenting it yet.
2021-03-03 22:47:31 -08:00
Wez Furlong
783f445c57 allow changing status_update_interval dynamically
We were using the value that was active when the window was created,
and never updating it.

This commit sweeps the interval check into the existing periodic
window maintenance routine.

refs: https://github.com/wez/wezterm/issues/500
2021-03-03 19:58:46 -08:00
Wez Furlong
c305abdcd7 trigger the status event when the title is updated, too
This makes it quicker to respond to things like eg: the cwd
in the pane changing.

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 22:36:39 -08:00
Wez Furlong
9ac230876c Add status_update_interval option for status updates
The status event is triggered at window creation, and
then every `status_update_interval` milliseconds.

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 20:44:08 -08:00
Wez Furlong
99a0b044a0 experimental: add right-status concept and event
The API isn't finalized; this is proof of concept for putting something
in the area to the right of the new tab button.

The info will be right aligned to the tab area.

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

wezterm.on("update-right-status", function(window, pane)
  -- demonstrates shelling out to get some external status.
  -- wezterm will parse escape sequences output by the
  -- child process and include them in the status area, too.
  local success, date, stderr = wezterm.run_child_process({"date"})

  -- Make it italic and underlined
  window:set_right_status(wezterm.format({
    {Attribute={Underline="Single"}},
    {Attribute={Italic=true}},
    {Text="Hello "..date},
  }));
end)

return {
}
```

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 09:52:54 -08:00
Wez Furlong
48f5fccb86 block glyphs: fix quad rendering
The line drawing routine takes inclusive start/end coordinates,
so if we're feeding the start/end from Range (which is exclusive),
then we need to reduce by 1.

refs: https://github.com/wez/wezterm/issues/433#issuecomment-787640338
2021-03-01 09:52:25 -08:00
Wez Furlong
d56c5178da shaping: add test for FiraCode
Adds a test and seemingly a fix for https://github.com/wez/wezterm/issues/478#issuecomment-787520977

Fira Code is OFL-1.1 licensed like the other fonts we include,
however, I'm not distributing Fira Code with wezterm.
2021-02-28 13:35:00 -08:00
Wez Furlong
b4b92a68f7 block glyphs: handle very small sizes better!
refs: #433
2021-02-28 10:06:00 -08:00
Wez Furlong
0597684ebd Render custom block glyphs
As explained in the docs included in this commit, ideally this
wouldn't be needed, but due to a long-standing hinting bug in
freetype <https://gitlab.freedesktop.org/freetype/freetype/-/issues/761>
it seems most expedient to just render our own block glyphs,
so that's what this does!

refs: #433
2021-02-28 09:43:26 -08:00
Wez Furlong
a3b25324b2 build fixes for macos, windows 2021-02-28 07:39:49 -08:00
Wez Furlong
27837b56b4 fix: triple click (line selection) to consider wrapped lines
closes: https://github.com/wez/wezterm/issues/466
2021-02-28 00:31:26 -08:00
Wez Furlong
c5b7fbaccf refactor: pull gui sources up one level
It hasn't been necessary to have them go under `gui` since
the mux server was moved out to its own binary.
2021-02-28 00:11:17 -08:00
Wez Furlong
ac376fb9c6 refactor: move frontend up a level -> own module 2021-02-28 00:04:10 -08:00
Wez Furlong
04ecd16493 remove --front-end CLI option
Can use `--config front_end="Software"` instead.
2021-02-27 23:59:04 -08:00
Wez Furlong
d837dc45a1 selection: reduce gap used for scrolling viewport
This doesn't fix https://github.com/wez/wezterm/issues/354
but perhaps makes it a bit less annoying.
2021-02-27 18:58:28 -08:00
Wez Furlong
6b0fef18f0 refactor: split more things out 2021-02-27 18:40:04 -08:00
Wez Furlong
452c76ea89 refactor: break more stuff out of termwindow 2021-02-27 18:21:36 -08:00
Wez Furlong
840173af61 refactor: split PrevCursorPos out of termwindow 2021-02-27 17:30:48 -08:00
Wez Furlong
dbf33984d7 refactor: move clipboard out of termwindow 2021-02-27 17:28:00 -08:00
Wez Furlong
63ca8e88b6 refactor: split out termwindow spawn functions 2021-02-27 17:22:11 -08:00
Wez Furlong
6ff349308b refactor: split termwindow.rs in two 2021-02-27 17:11:25 -08:00
Wez Furlong
db08b8c1dc add window:set_config_overrides lua method
This commit expands on the prior commits to introduce the concept
of per-window configuration overrides.

Each TermWindow maintains json compatible object value holding
a map of config key -> config value overrides.

When the window notices that the config has changed, the config
file is loaded, the CLI overrides (if any) are applied, and then
finally the per-window overrides, before attempting to coerce
the resultant lua value into a Config object.

This mechanism has some important constraints:

* Only data can be assigned to the overrides.  Closures or special
  lua userdata object handles are not permitted.  This is because
  the lifetime of those objects is tied to the lua context in which
  they were parsed, which doesn't really exist in the context of
  the window.
* Only simple keys are supported for the per-window overrides.
  That means that trying to override a very specific field of
  a deeply structured value (eg: something like `font_rules[1].italic = false`
  isn't able to be expressed in this scheme.  Instead, you would
  need to assign the entire `font_rules` key.  I don't anticipate
  this being a common desire at this time; if more advance manipulations
  are required, then I have some thoughts on an event where arbitrary
  lua modifications can be applied.

The implementation details are fairly straight-forward, but in testing
the two examplary use cases I noticed that some hangovers from
supporting overrides for a couple of font related options meant that the
window-specific config wasn't being honored.  I've removed the code that
handled those overrides in favor of the newer more general CLI option
override support, and threaded the config through to the font code.

closes: #469
closes: #329
2021-02-27 14:53:19 -08:00
Wez Furlong
60be1a98a0 lua: add window::effective_config() method
Expose the current window configuration to lua scripts.

refs: https://github.com/wez/wezterm/issues/469
2021-02-27 12:39:22 -08:00
Wez Furlong
4389e6dd13 gui: maintain a local copy of the ConfigHandle in TermWindow
This is a pre-req for having a window-specific config.

refs: #469
2021-02-27 12:04:55 -08:00
Wez Furlong
2d02df5f38 add --config name=value CLI options
`wezterm`, `wezterm-gui` and `wezterm-mux-server` now all support
a new `--config name=value` CLI option that can be specified
multiple times to supply config overrides.

Since there isn't a simple, direct way to update arbitrary fields
of a struct in Rust (there's no runtime reflection), we do this
work in lua.

The config file returns a config table. Before that is mapped
to the Rust Config type, we have a new phase that takes each
of the `--config` values and applies it to the config table.

For example, you can think of configuration as working like this
if wezterm is started as `wezterm --config foo="bar"`:

```lua
config = load_config_file();
config.foo = "bar";
return config;
```

The `--config name=value` option is split into `name` and `value`
parts.  The name part is literally concatenated with `config` in
the generated lua code, so the name MUST be valid in that context.
The `value` portion is literally inserted verbatim as the rvalue in the
assignment.  Not quoting or other processing is done, which means
that you can (and must!) use the same form that you would use in
the config file for the RHS.  Strings must be quoted.  This allows
you to use more complicated expressions on the right hand side,
such as:

```
wezterm --config 'font=wezterm.font("Fira Code")'
```

The overrides stick for the lifetime of the process; even if
you change the config file and reload, then the value specified
by the override will take precedence.

refs: https://github.com/wez/wezterm/issues/469
refs: https://github.com/wez/wezterm/issues/499
2021-02-27 10:53:45 -08:00