1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-30 06:03:39 +03:00
Commit Graph

244 Commits

Author SHA1 Message Date
Wez Furlong
3cf7c9c3c2 refine skip_close_confirmation_for_processes_named to look at proc tree
That means that we won't be fooled by a shell with a backgrounded
editor.

refs: https://github.com/wez/wezterm/issues/562
2021-03-22 21:34:10 -07:00
Wez Furlong
e69485d3ca avoid hang if several glyphs fail to resolve in quick succession
The channel to the connui was bounded to 16 and could easily be
saturated from the main thread.  The saturated queue would block
the main thread.
2021-03-22 15:53:56 -07:00
Wez Furlong
4d4fa35557 skip_close_confirmation_for_processes_named now also works on macos
refs: https://github.com/wez/wezterm/issues/562
2021-03-22 12:57:36 -07:00
Wez Furlong
ad4b3b4648 add skip_close_confirmation_for_processes_named option
Currently only respected on linux.

refs: https://github.com/wez/wezterm/issues/562
2021-03-22 12:42:46 -07:00
Wez Furlong
d62d2a5133 avoid blocking forever in LocalPane::drop
I don't understand how fish ends up blocking forever in the related
issue, but it shouldn't block us too!  The price of this situation
is likely a lingering zombie child process but that seems fine.

refs: https://github.com/wez/wezterm/issues/558
2021-03-20 12:16:56 -07:00
Wez Furlong
9e6abce963 mux: adjust pty output buffering/reading
I've had a few people comment that the screen repaints stutter
more since the most recent release.

One of the main changes in that area was to increase throughput
for timg case, where a lot of data was being pumped through.

I think that, ironically, the decreased latency results in more
frequent repaints where not all of the updated screen is visible
in a full screen redraw, so it appears more janky.

This commit introduces a small 1ms delay to see if additional
output is forthcoming when parsing the data.  It will keep
delaying and accumulating until there's at least one parsed
output action to process, so there is a small constant latency
overhead added to a single character output (thread context
switch + 1ms delay).

This small delay is counter-balanced with raising the priority
of dispatching the render actions; previously we'd spawn them
at lower-than-input priority.  With the batching potential,
I think spawning them at the same priority is OK; the main
reason for the lower priority was to ensure timely ctrl-c
processing when a lot of output is being dumped to the terminal.

It's hard for me to gauge whether this fixes the reported issue,
as I've been unable to reproduce it for myself.

refs: https://github.com/wez/wezterm/issues/559
refs: https://github.com/wez/wezterm/issues/546
2021-03-19 22:12:29 -07:00
Wez Furlong
ba7add140e Attach gui window invalidation to pty output event
I'm not convinced that this is 100% good, but @fanzeyi reported
some latency when using tmux to mirror two sessions.  The session
that was accepting interactive input responded quickly, but the
mirroring session was laggy.

This change connects the mux pane output event to window invalidation,
which should cause repaints to happen more often.

I couldn't reproduce the scenario above on my M1 mac, but that may
just be because M1 has dark magicks.
2021-03-17 20:20:08 -07:00
Wez Furlong
2ea093170c mux: avoid panic if prune_dead_windows is called indirectly
refs: #542
2021-03-15 06:38:17 -07:00
Wez Furlong
693a717db2 improve output parsing performance and throughput
I've been meaning to do this for a while; this commit moves
the escape sequence parsing into the thread that reads the
pty output which achieves two goals:

* Large escape sequences (eg: image protocols) that span multiple
  4k buffers can be processed without ping-ponging between the
  reader thread and the main gui thread
* That parsing can happen in the reader thread, keeping the gui
  thread more responsive.

These changes free up the CPU during intensive operations such
as timg video playback.

This is a slight layering violation, in that this processing
really belongs to local pane (or any pane that embeds Terminal),
rather than generically at the Mux layer, but it's not any
worse a violation than `advance_bytes` already was.

refs: https://github.com/wez/wezterm/issues/537
2021-03-13 19:19:05 -08:00
Wez Furlong
5fa5aef7f3 Disable newline splitting in output processing
In a couple of quick tests, this doesn't seem to break cat'ing
the emoji test data so it seems like it isn't needed anymore.

In addition, it removes a bottleneck from processing image
streams produced by timg, which tend to be very large with
new newlines.

With this change, I'm able to view a 25fps source video at
about 60fps.

refs: https://github.com/wez/wezterm/issues/537
2021-03-13 14:23:36 -08:00
Wez Furlong
823213703c mux: introduce can_close_without_prompting concept to model
This is defined as a trait method on Pane (default: false), and has the
obvious transitive equivalent methods in Tab and Window (eg: if all
contained items are `can_close_without_prompting`, then that container
is also `can_close_without_prompting`).

The intent is to avoid bothering the user to confirm closing a window
when the content is not stateful and doesn't warrant it.

For example: the window that is displayed in the event of a
configuration error really shouldn't prompt to the user to confirm
closing it.

All termwiztermtab panes are `can_close_without_prompting==true`
to effect this policy.

In the future, we could teach LocalPane to lookup the session leader
process against a list of "uninteresting" or "stateless" processes
and return an appropriate result (as suggested in
https://github.com/wez/wezterm/issues/280).  That functionality
is NOT part of this commit.
2021-02-27 09:03:13 -08:00
Wez Furlong
697a6abd04 add exit_behavior config option
`exit_behavior = "Hold"` will keep the pane alive until explicitly
closed.  More details in the docs that are part of this commit.

refs: https://github.com/wez/wezterm/issues/499
2021-02-27 00:15:51 -08:00
Wez Furlong
651e536d87 term: plumb Bell through toast notification channel
Per my comment: https://github.com/wez/wezterm/issues/3#issuecomment-780750798

this routes the bell through to the GUI layer, where it currently
does nothing about it.
2021-02-18 22:34:05 -08:00
Wez Furlong
83da7216c3 toast: hook notifications up to OSC 9
refs: #489
2021-02-17 09:33:58 -08:00
Dylan Frankland
88f44f5b5f
Add erase mode to ClearScrollback action (#439)
* Add ClearBuffer action

Clears all lines, both visible and those scrolled off the top of the viewport, making the prompt line the new first line and resetting the scrollbar thumb to the full height of the window.

This is the behavior that Hyper / xterm has for clearing the terminal.

* Combine ClearBuffer into ClearScrollback as enum with associated erase mode

Makes it easier to manage the different options of clearing the terminal.
2021-01-25 21:26:23 -08:00
Wez Furlong
28e527b649 fix tests
refs: #429
2021-01-17 22:01:21 -08:00
Wez Furlong
da3a41e018 wezterm: fix mapping scroll wheel to cursor up/down in alt screen
This appears to have been broken since the introduction of mouse
assignments :-/

This commit adds Pane::is_alt_screen_active so that the gui layer
can tell whether the alt screen is active, and allow passing down
the event.

refs: #429
2021-01-17 21:44:02 -08:00
Wez Furlong
5d360ae365 termwiz: Remove anyhow::Result from public API
It's been replaced with an opaque termwiz error type instead.

This is a bit of a more conservative approach than that in (refs: #407)
and has less of an impact on the surrounding code, which appeals to
me from a maintenance perspective.

refs: #406
refs: #407
2021-01-08 00:32:30 -08:00
Wez Furlong
7cf68365a5 deps: misc updates 2020-12-29 09:24:34 -08:00
Wez Furlong
80411d7db9 simplify passing the TerminalSize to the terminal
Following on from 8649056ac0,
this commit should make it harder to make a similar mistake
in the future, by introducing a new TerminalSize struct for
that purpose.
2020-12-29 09:06:26 -08:00
Wez Furlong
6b414bebc9 tweak updating checking
* Allow injecting some initial output to new panes
* Have the update checker set this new-pane-banner to a short
  upsell to let the user know there is an update.
* Refactor toast notifications into their own crate
* Have the update checker call a new stub function that triggers
  a toast notification with an URL... but it does nothing because
  the rust ecosystem doesn't support this on macos yet and I'm
  writing this code there
2020-12-26 18:22:44 -08:00
Wez Furlong
b3ac77aa92 wezterm: allow adding images to termwiztermtab apps
Tidies up the plumbing around pixel dimensions so that ImageData
can be rendered via the termwiztermtab bits.

I put this together to play with sticking the wezterm logo in
the close confirmation dialogs.  I didn't end up using that though,
but have preserved the commented code for use in future hacking.
2020-12-26 14:01:48 -08:00
Wez Furlong
80214319ae adjust log levels
Revise logging so that we use info level for things that we want
to always log, and adjust the logger config to always log info
level messages.

That means shifting some warning level logs down lower to debug level so
that they aren't noisy.

closes: https://github.com/wez/wezterm/issues/388
2020-12-20 22:01:06 -08:00
Wez Furlong
2603f9d4b4 fixup mux output processing
in ab342d9c46 I started to rearrange how
the output processing thread works.  It wasn't quite right, so this
commit tidies things up.

The main change here is that there is now back-pressure from the output
parser on the reader; if it is taking a while to parse the output then
we don't buffer up so much input.

This makes operations like `find /` followed immediately by `CTRL-C`
more responsive.

With this change, I don't feel that the
`ratelimit_output_bytes_per_second` option is needed any more, so it
has been removed.
2020-12-12 08:53:45 -08:00
Wez Furlong
ab342d9c46 mux: re-jigger pty output processing
This removes the ratelimiter from the mux pty output reader.
Instead, we now have two reader threads:

* One to perform blocking reads from the pty output and send them
  to the other thread
* The other thread waits for data from the first, then tries to find
  a newline character so that it can send 1+ lines of data to the
  terminal parser.  If it doesn't find any lines, it waits ~50ms for
  additional data from the first thread to bundle together eg:
  really long lines, or image protocol data.  It will keep doing this
  until no more data arrives within 50ms or until it finds a newline.
  Once no more data arrives within 50ms, it sends whatever it has
  accumulated and then blocks waiting for the next chunk

I tried a quick ctrl-c test with this; running `find /` and seeing
how easily interruptible it is, and it seems OK on my M1 mac.
I don't think we need the output rate limiter any more, but I'll
try this out on my bigger linux machine as well to see if that
feels as good.

With this change, `cat test-data/emoji-test.txt` no longer has wonky
spacing when it gets to the England flag at the bottom.

refs: https://github.com/wez/wezterm/issues/339
2020-12-10 23:47:11 -08:00
Wez Furlong
526df72544 textwrap -> 0.13 2020-12-09 14:07:35 -08:00
Wez Furlong
a063d20cf0 wezterm: improve shaping of emoji
This is one of those massive time sinks that I almost regret...
As part of recent changes to dust-off the allsorts shaper, I noticed
that the harfbuzz shaper wasn't shaping as well as the allsorts one.

This commit:

* Adds emoji-test.txt, a text file you can `cat` to see how well
  the emoji are shaped and rendered.

* Fixes (or at least, improves) the column width calculation for
  combining sequences such as "deaf man" which was previously calculated
  at 3 cells in width when it should have just been 2 cells wide, which
  resulted in a weird "prismatic" effect during rendering where the
  glyph would be rendered with an extra RHS portion of the glyph across
  3 cells.

* Improved/simplified the clustering logic used to compute fallbacks.
  Previously we could end up with some wonky/disjoint sequence of
  undefined glyphs which wouldn't be successfully resolved from a
  fallback font.  We now make a better effort to consolidate runs of
  undefined glyphs for fallback.

* For sequences such as "woman with veil: dark skin tone" that occupy a
  single cell, the shaper may return 3 clusters with 3 glyphs in the
  case that the font doesn't fully support this grapheme.  At render
  time we'd just take the last glyph from that sequence and render it,
  resulting in eg: a female symbol in this particular case.  It is
  generally a bit more useful to show the first glyph in the sequence
  (eg: person with veil) rather than the gender or skin tone, so the
  renderer now checks for this kind of overlapping sequence and renders
  only the first glyph from the sequence.
2020-11-23 13:45:38 -08:00
Wez Furlong
c6c87eaf7c tmux: plumbing for querying panes when control mode is started up
refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:25:01 -08:00
Wez Furlong
9442726f23 tmux: press q to detach control mode pane
refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:24:58 -08:00
Wez Furlong
91f1cc21fc mux/wezterm: move Renderable into Pane
This makes it easier to overrride/overlay inside the mux when
indicating that we are in tmux mode.

refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:24:56 -08:00
Wez Furlong
fffb9b3fa0 tmux: some plumbing for detaching and indicating tmux is active
the renderable interface is getting in the way though...

refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:24:53 -08:00
Wez Furlong
aaf63285d2 tmux: attach control mode parser to terminal
This causes `tmux -CC attach` to enter control mode and patch
into the terminal, printing out parsed event messages.

refs: https://github.com/wez/wezterm/issues/336
2020-11-20 09:24:50 -08:00
Wez Furlong
37a3f7db5f wezterm: add ScrollToPrompt key assignment
Adds some supporting methods for computing the `SemanticZone`s
in the display and a key assignment that allows scrolling the
viewport to jump to the next/prev Prompt zone.
2020-11-08 09:58:02 -08:00
Wez Furlong
cfef4fd0ca wezterm: adjust pixel width and height when dragging splits
The drag would update the cell dimensions but not the pixel dimensions,
which results in weird image scaling.

refs: #312
2020-11-02 19:56:46 -08:00
Wez Furlong
7e8c5a06bb split gui into wezterm-gui executable
This commit moves a bunch of stuff around such that `wezterm` is now a
lighter-weight executable that knows how to spawn the gui, talk to
the mux or emit some escape sequences for imgcat.

The gui portion has been moved into `wezterm-gui`, a separate executable
that doesn't know about the CLI or imgcat functionality.

Importantly, `wezterm.exe` is no longer a window subsystem executable
on windows, which makes interactions such as `wezterm -h` feel more
natural when spawned from `cmd`, and should allow
`type foo.png | wezterm imgcat` to work as expected.

That said, I've only tested this on linux so far, and there's a good
chance that something mac or windows specific is broken by this
change and will need fixing up.

refs: #301
2020-10-24 16:40:15 -07:00
Wez Furlong
b0fdd15d35 wezterm: add [Z] prefix to titlebar for zoomed panes
refs: #297
2020-10-20 23:20:22 -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
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
24b290a5da localtab.rs -> localpane.rs 2020-10-06 13:42:51 -07:00
Wez Furlong
a0b3932e6d fixup build for macos 2020-10-05 09:11:17 -07:00
Wez Furlong
5eb4d32004 upgrade misc deps, notably, async-task 2020-10-05 00:06:01 -07:00
Wez Furlong
b93cf5066d move Activity into mux crate 2020-10-03 11:15:57 -07:00
Wez Furlong
025732d00f Add MuxNotification::WindowCreated, use it to spawn gui window
Rather than having each call site add a window to the mux and then
call the front end to spawn a window, make the mux emit a signal
advising of a window spawn, and have the front end subscribe to
that signal.
2020-10-03 11:15:57 -07:00
Wez Furlong
a511abb1c2 move mux to its own crate 2020-10-03 11:15:57 -07:00