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

433 Commits

Author SHA1 Message Date
Wez Furlong
58157c47a9 config: can now subscribe to config change events
This removes a couple of periodic config polls

refs: https://github.com/wez/wezterm/issues/770
2021-05-08 11:06:07 -07:00
Wez Furlong
1cbaf55640 change mux empty poll to mux empty event
As part of reducing the amount of regularly scheduled stuff wezterm
does in the background, this commit restructures how an empty mux
is detected; now when the mux prunes dead windows it will emit
an Empty event.

The Activity type will now schedule a prune when it is dropped,
which will clean up and trigger the Empty event.

refs: https://github.com/wez/wezterm/issues/770
2021-05-08 10:25:49 -07:00
Wez Furlong
7cd9f32494 add some error context on notif dispatching
This was helpful when running down the situation in the previous
commit.
2021-05-08 10:21:44 -07:00
Wez Furlong
2e74663628 fixup log level for context loss 2021-05-08 09:36:19 -07:00
Wez Furlong
5d037eae52 adjust gui layer for window changes 2021-05-08 09:36:19 -07:00
Chris
2add312c5c
Allow VoidSymbol keycode to be seen by wezterm (#759)
* allow voidsymbol for key code

* update docs, cleanup

* cleanup and fmt of files

* remove unnecessary inputs
2021-05-07 07:54:24 -07:00
Wez Furlong
d64b785290 deps: update windows dep to 0.4 -> 0.9
dependabot keeps trying and failing because lots of things changed.
Let's try and get ahead of it...
2021-05-03 22:05:35 -07:00
Wez Furlong
a594298947 add window object to debug overlay
refs: https://github.com/wez/wezterm/issues/641
2021-05-03 18:36:26 -07:00
Wez Furlong
09f0421b48 add lua repl to the debug overlay
`wezterm` is pre-imported.
The repl prints the result of the expressions to the overlay.

refs: https://github.com/wez/wezterm/issues/641
2021-05-03 09:19:44 -07:00
Wez Furlong
8b71a57513 add debug overlay
Adds a `ShowDebugOverlay` key assignment that will create a tab
overlay that shows a limited number of recently logged events.

refs: https://github.com/wez/wezterm/issues/641
2021-05-03 09:19:38 -07:00
Wez Furlong
7a86f1b2b8 fixup word selection on long lines
This got a bit broken by the fix for https://github.com/wez/wezterm/issues/714

since we can be handed a range of logical line fragments, we should
test each of them to find our matching result.

Also, improve the logic for constraining the length when looking
backwards.
2021-05-02 12:40:16 -07:00
Wez Furlong
6919630810 refactor: new_window is now async
This doesn't really change anything, but it makes it a little
simpler to integrate wgpu in a later commit.
2021-05-02 12:05:28 -07:00
Wez Furlong
8880979586 Adjust font scaling math again
This commit introduces the knowledge about whether a font is
scalable or was using bitmap strikes (eg: color emoji bitmaps).

Then that information is used to help figure out whether and
how to scale a glyph.

refs: https://github.com/wez/wezterm/issues/685
2021-05-01 16:45:57 -07:00
Wez Furlong
d4da670294 docs for and minor tweak of curly underline improvement
refs: https://github.com/wez/wezterm/pull/733
2021-04-30 09:22:01 -07:00
Roland Fredenhagen
7b274d460e
Better function for undercurl (#733)
* Better function for undercurl

* Setting lower alpha

* underline alpha in line-frag

* make undercurl alpha background independent

* Improved Shader

* Old Rasterization

Co-authored-by: Roland Fredenhagen <git@modprog.de>
2021-04-30 09:19:43 -07:00
Wez Furlong
0316dfeb83 term can now notify application about potential title updates
When the title, icon, OSC 7 and SetUserVars sequences are processed,
notify the embedding application.

The gui layer uses this to trigger a titlebar update.

refs: #647
2021-04-30 07:28:02 -07:00
Wez Furlong
35eb7383b1 ci: simplify version number
Previously, we used `git describe --tags` to produce a version number
for non-released builds derived from the most recent tag + some info
such as the number of commits since that tag and then `g{HASH}`.

That always confuses people because the date portion at the front
looks old (it is typically the previous release) and the hash at
the end has that `g` in it.

This commit simplifies both the tag name used when making a release
and the computed version number take the date/time from the current
commit, and then append the hash.  That way the version number always
corresponds to a commit.

This scheme doesn't help detect situations where the commit is
dirty, but I don't think the old one would have helped with that
either.
2021-04-29 20:23:47 -07:00
Wez Furlong
94c98aa826 quickselect: fixup edge case with wrapped lines
the binary search would falsely extend the end of the match
to the start of the subsequent match for the wrapped line case.

The resolution is to emit a coordinate for the newline that we
add to the haystack between the wrapped lines.

closes: https://github.com/wez/wezterm/issues/732
2021-04-29 17:15:49 -07:00
Wez Furlong
d547f45714 avoid vanishing cursor when wrapped line is initially 0-width
refs #740
2021-04-29 16:06:43 -07:00
Wez Furlong
6d7f9879ac be more aggressive at pruning trailing blanks 2021-04-29 16:00:33 -07:00
Wez Furlong
7de7bf6b9e optimize render for blanks-after-clusters
In the situation where we have a full screen terminal (eg: 500 cells
wide), but very little output (eg: only 10's of columns on the left are
NOT blank), we would previously spend a non-trivial amount of time
calculating fg/bg colors for the blanks that trailed the actual
clusters; the calculation for each row was:

  O(trailing-blanks * full cell color compute cost)

which was around 30us per row.  For large numbers of rows this could
add up to >10ms per frame.

This commit changes the logic to run in two phases:

 * O(selection-width) with simple fg/bg color updates for the selection
   range

 * O(1) full cell color compute cost for the cursor if the cursor
   is somehow in the trailing blank region and not already handled
   by the earlier clustering logic.

With the sequence of recent commits, the frame time for the large
terminal case has been reduced from ~22ms to ~7ms, which is approx 3x
improvement.

refs: #740
2021-04-29 10:08:51 -07:00
Wez Furlong
20a599a372 fix test compilation 2021-04-28 18:07:07 -07:00
Wez Furlong
f91ca30008 micro-optimize clustering
This improves it by ~4x for long lines, taking it from 120us to ~30us.
2021-04-28 08:25:07 -07:00
Wez Furlong
8953bff276 fonts: pre-size some vecs
micro optimization really
2021-04-27 22:39:32 -07:00
Wez Furlong
d6c8eb1e3b benchmarking shaping
`cargo test --release -p wezterm-gui -- --nocapture bench_shaping`:

```
running 1 test
100: 139.82µs
1000: 385.333µs
10000: 3.144203ms
test shapecache::test::bench_shaping ... ok
```
2021-04-27 21:48:15 -07:00
Wez Furlong
e9fcc98d4a quickselect: allow pasting when typing the uppercase prefix
revise the colors to be a bit less glaring.

Updated the screenshot

refs: https://github.com/wez/wezterm/issues/732
2021-04-27 07:06:55 -07:00
Wez Furlong
d176af9c30 tidy up format-tab-title, add tab_max_width parameter
refs: https://github.com/wez/wezterm/issues/647
2021-04-26 21:43:30 -07:00
Wez Furlong
be9c60bfc8 removed tab_bar_style options in favor of format-tab-title
refs: https://github.com/wez/wezterm/issues/647
2021-04-26 20:16:47 -07:00
Wez Furlong
3ad2a46ecf quickselect: avoid a panic when used with mux
It looks like the mux search results include a trailing newline
in some cases, which means that a match can wrap onto a second
line.

If that line is shorter than the label length, we could panic.

This commit makes quickselect safer to use in this situation,
but the real fix is with the mux search code.
2021-04-26 09:58:16 -07:00
Wez Furlong
d907b86a91 fixup captures in default quickselect patterns
Change some of the grouping to non-capturing expressions,
and remove redundant whole-expressing captures

refs: #732
2021-04-26 08:38:45 -07:00
Wez Furlong
3028756ccb add tab_bar_at_bottom config option
closes: https://github.com/wez/wezterm/issues/278
2021-04-25 20:49:48 -07:00
Wez Furlong
f3679b024d fix mouse x position calc in tab bar
close: https://github.com/wez/wezterm/issues/677
2021-04-25 19:55:36 -07:00
Wez Furlong
f3706c706c de-hover tab when moving cursor down into the terminal
It's not perfect; this only handles the case where you move down
into the terminal.  I couldn't easily make the same thing happen
when moving the mouse up or left outside of the window.  It's
probably fixable but this is better than it was.

closes: https://github.com/wez/wezterm/issues/591
2021-04-25 17:01:21 -07:00
Wez Furlong
8ce376753f round out quick select mode
* Make alphabet and patterns configurable
* add docs
* Enhance scrollback search to support regex captures so that
  searching for eg: `fo(o)` will select the last `o` in `foo`.

refs: https://github.com/wez/wezterm/issues/732
2021-04-25 16:27:39 -07:00
Wez Furlong
87677a73bf Add support for iTerm2's SetUserVar escape
This doesn't propagate across wezterm's mux protocol
at this time.

refs: https://github.com/wez/wezterm/issues/647

https://iterm2.com/documentation-scripting-fundamentals.html#setting-user-defined-variables
2021-04-25 14:30:06 -07:00
Wez Furlong
1cb2856223 add hover parameter to format-tab-title
refs: https://github.com/wez/wezterm/issues/647
2021-04-25 13:53:06 -07:00
Wez Furlong
5b1631fe21 add quickselect overlay
This is the first pass implementation, drawing on the alphabet logic
and default patterns from tmux-thumbs (thanks @fcsonline!).

ctrl-shift-space pops up the quick select overlay.
Typing the highlighted prefix will select the matching text and
copy it as though the `Copy` key assignment was used.

TODOs are to make the alphabet and patterns configurable, as well
as write up some docs.

refs: #732
2021-04-25 11:52:14 -07:00
Wez Furlong
a69447fc2a nominally support toast notif timeouts
I've built this on linux, which doesn't respect the timeout.
I've made speculative changes that should build on mac and windows,
but that don't plumb the timeout functionality on those systems
as of yet.

refs: #619
2021-04-25 08:52:43 -07:00
Wez Furlong
2c89e47f9e add force_reverse_video_cursor option
refs: https://github.com/wez/wezterm/issues/706
2021-04-24 21:16:58 -07:00
Wez Furlong
09e101c268 add format-tab-title event
refs: https://github.com/wez/wezterm/issues/647
2021-04-24 17:59:39 -07:00
Wez Furlong
e3fcdc9f36 add format-window-title event
This provides a flexible way for users to customize what gets
shown in the window title bar.

closes: https://github.com/wez/wezterm/pull/603
2021-04-24 16:47:26 -07:00
Wez Furlong
1f8908cddb fonts: revise cap_height adjustment
back out the portion of the cap height scaling that applied when
we knew the cap height of the primary font but not a fallback font.

That logic allowed some overly wide powerline fonts to be sized
correctly (a bit smaller), but also meant that a number of emoji
and other symbol glyphs were now undersized.

refs: https://github.com/wez/wezterm/issues/727
2021-04-24 12:02:52 -07:00
Wez Furlong
87d49e45fc fix: multi-glyph tab titles
closes: https://github.com/wez/wezterm/issues/711
2021-04-23 22:51:53 -07:00
Wez Furlong
d705886b53 Add pane_focus_follows_mouse
closes: https://github.com/wez/wezterm/issues/600
2021-04-23 22:17:33 -07:00
Wez Furlong
657ed92d82 add swallow_mouse_click_on_pane_focus option
refs: https://github.com/wez/wezterm/issues/724
2021-04-23 22:17:06 -07:00
Wez Furlong
f97df9307a fix scaling for square glyphs
a copy-paste/transcription error had the y value divided by the cell
width rather than the x value.

refs: https://github.com/wez/wezterm/issues/707
2021-04-23 21:03:10 -07:00
Wez Furlong
91cd2e22e4 prefer local/specific config for a couple more cases
Avoid using `configuration()` when there may be a more specific
config with overrides that we can resolve.
2021-04-16 09:04:51 -07:00
Wez Furlong
76353a6240 fix: InputMap reading global config instead of window overrides
refs: #656
2021-04-16 08:59:49 -07:00
Wez Furlong
67d8848676 ls-fonts: refine output a bit
It now outputs something that you could conceivably put into
your config file, although the intent is to show the canonical
way to reference the individual fonts that were found, rather
than to specify a fully baked list to paste into a config.

eg:

```
; ./target/debug/wezterm ls-fonts
Primary font:
wezterm.font_with_fallback({
  -- /home/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
  {family="Operator Mono SSm Lig", weight="DemiLight"},

  -- /home/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontConfig
  {family="Operator Mono SSm Lig", weight="DemiLight"},

  -- /home/wez/.fonts/MaterialDesignIconsDesktop.ttf, FontDirs
  "Material Design Icons Desktop",

  -- /home/wez/.fonts/terminus-bold.otb, FontDirs
  {family="Terminus", weight="Bold"},

  -- /home/wez/.fonts/JetBrainsMono-Regular.ttf, FontDirs
  "JetBrains Mono",

  -- /home/wez/.fonts/NotoColorEmoji.ttf, FontDirs
  "Noto Color Emoji",

  -- /home/wez/.fonts/MaterialDesignIconsDesktop.ttf, FontConfig
  "Material Design Icons Desktop",

  -- /usr/share/fonts/terminus-fonts/ter-u32n.otb, FontConfig
  "Terminus",

  -- /home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig
  "JetBrains Mono",

  -- /home/wez/.fonts/NotoColorEmoji.ttf, FontConfig
  "Noto Color Emoji",

  -- <built-in>, BuiltIn
  "Last Resort High-Efficiency",

})
```
2021-04-14 09:06:02 -07:00
Wez Furlong
3fae59b01b fonts: use cap-height metric to scale fallback fonts
we now compute the ratio of the cap height (the height of a capital
letter) vs. the em-square (which relates to our chosen point size) to
understand what proportion of the font point-size that a given font
occupies when rendered.

When rendering glyphs from secondary fonts we can use the cap height
ratios of both to scale the secondary font such that its effective
cap height matches that of the primary font.

In plainer-english: if you mix say bold, italic and regular text
style in the same line, and you have different font families for
those fonts, then they will now appear to be the same height where
previously they may have varied more noticeably.

For emoji and symbol fonts there may not be a cap-height metric
encoded in the font.  We can however, improve our scaling: prior
to this commit we'd use the ratio of the cell metrics of the two
fonts to scale the icon/emoji glyph, but this could cause the glyph
to be slightly oversized as seen in https://github.com/wez/wezterm/issues/624

If we know the cap-height of the primary font then we can additionaly
apply that factor to scale the emoji to better fit the cell.

While looking at this, I noticed that the aspect ratio calculation
for when to apply to the allow_square_glyphs_to_overflow_width option
had width and height flipped :-(

See also: https://tonsky.me/blog/font-size/
refs: https://github.com/wez/wezterm/issues/624
2021-04-13 23:02:27 -07:00
Wez Furlong
776aedf97e fonts: allow specifying weight/stretch/italic for each fallback font 2021-04-12 22:30:55 -07:00
Wez Furlong
2e34f1a8dd Add wezterm ls-fonts subcommand
At this time it just shows you the fonts that your config matches
and where they came from:

```
; wezterm -n ls-fonts
Primary font:
  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Italic=true:
  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=true)
    (/home/wez/.fonts/JetBrainsMono-Italic.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Intensity=Bold:
  wezterm.font("JetBrains Mono", weight="Bold", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Bold.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

When Intensity=Bold Italic=true:
  wezterm.font("JetBrains Mono", weight="Bold", stretch="Normal", italic=true)
    (/home/wez/.fonts/JetBrainsMono-Bold-Italic.ttf, FontConfig)

  wezterm.font("JetBrains Mono", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/JetBrainsMono-Regular.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Noto Color Emoji", weight="Regular", stretch="Normal", italic=false)
    (/home/wez/.fonts/NotoColorEmoji.ttf, FontConfig)

  wezterm.font("Last Resort High-Efficiency", weight="Regular", stretch="Normal", italic=false)
    (<built-in>, BuiltIn)

```

refs: #347
2021-04-12 09:44:27 -07:00
Wez Furlong
e5665e80a1 add window:toast_notification method
refs: https://github.com/wez/wezterm/issues/619
2021-04-11 22:01:06 -07:00
Wez Furlong
16701f61b4 fix new-tab hover calculation
refs: https://github.com/wez/wezterm/issues/677
2021-04-11 16:10:14 -07:00
Wez Furlong
180f125830 fix gaps in multi-cell ligatured glyphs
refs: https://github.com/wez/wezterm/issues/614
2021-04-10 13:59:59 -07:00
Wez Furlong
c312983643 Ensure that we propagate OutOfTextureSpace errors
otherwise we won't be able to show many glyphs beyond those that
fit in the initial texture atlas!

refs: https://github.com/wez/wezterm/discussions/672
refs: https://github.com/wez/wezterm/issues/671
2021-04-10 07:26:19 -07:00
Wez Furlong
b825f86380 avoid incomplete paints if loading a glyph fails
This addresses the render artifacts aspect of https://github.com/wez/wezterm/issues/671

For whatever reason, some font(s) cannot be loaded on that system
and that results in the paint routine erroring out.

This commit avoids the error by substituting a blank glyph
instead of the glyph that failed to load.

refs: https://github.com/wez/wezterm/issues/671
2021-04-10 00:21:00 -07:00
Wez Furlong
16e7457049 x11: notice dynamic changes to Xft.dpi
This commit allows the x11 window implementation to detect changes
in the DPI that occur after a window is created.

These can occur when changing desktop resolution or when changing
the accessibility option for "Large Text" in gnome.

In order to avoid continually polling for the value on every resize,
we look for the `_GTK_EDGE_CONSTRAINTS` atom in our property change
notifications.  This seems to be sent at least as often as the
dpi/scaling changes.

It's also worth noting that some dpi changes don't generate resize
events, so we can't just read the dpi value on every resize, because
we'd miss some of those changes.

Part of this commit changes the font scaling logic: previously
we'd keep a notion of "dpi scale" to apply.  That dates from an
earlier time in wezterm where we didn't think that we knew an
actual dpi value.

The way that worked was that we'd compare our current guestimate
of the DPI against what we though the baseline OS dpi should be to
produce a scaling factor.

On X11 that dpi value is global and we'd effectively always produce
a revised scaling factor of 1 after we'd set up the initial window.

This commit changes that logic to just pass down the actual DPI value
to the font code.  That DPI value already accounts for HiDPI scaling
so this is hopefully a NOP change for the other systems.

refs: https://github.com/wez/wezterm/issues/667
2021-04-09 09:23:25 -07:00
Wez Furlong
ecc500af05 ssh: don't override the ssh config User value 2021-04-08 16:17:49 -07:00
Gus Wynn
dee10c2f21 Support unicode charaters in 2021-04-08 15:42:39 -07:00
Wez Furlong
6830d171cf fixup metrics when line_height==1.0
This was broken by b441be3ac9

For whatever reason, the breakage was only visible with the Iosveka
font on Windows.  I couldn't reproduce it on my other systems, even
though the code technically applies to any system.

The breakage was: the metrics resulted in a difference of about 0.4
pixels being used for the descender with that particular font, resulting
in weird vertical alignment problems.

The offset needs to be computed against the ceil of the cell height,
which removes the fractional offset.

refs: https://github.com/wez/wezterm/issues/661
refs: https://github.com/wez/wezterm/issues/582
2021-04-08 09:48:47 -07:00
Wez Furlong
81946d0144 fix under-invalidation of the selection
The repro scenario for this case was:

* open GNU nano
* hit enter twice
* type hello
* move the text cursor to the top line
* double click on hello
* hit enter

Prior to this commit, the selection would remain on the now-blank line
that previously held `hello`.

refs: #644
2021-04-07 08:43:45 -07:00
Wez Furlong
5cc29d1d8c wezterm-mux-server: keep running after all panes are gone
This has been a commonly requested feature in the past week,
and it's a reasonable one.  The mux server inherited the
close-when-done behavior from when it used to be an alternate
front-end in the same executable as the gui, but it doesn't
need to be that way any more.

We also need to accomodate that case in the client: if the
newly attached domain doesn't result in any panes being imported,
we need to spawn a new command there in order to keep the client
alive.  The pre-existing check for whether the mux was empty had
false positives because the local mux may still reference the
pane from the connection UI, which would finish closing out shortly
after we had decided not to spawn anything, and then the client
would close.

refs: https://github.com/wez/wezterm/issues/631
refs: https://github.com/wez/wezterm/issues/507
2021-04-03 15:00:08 -07:00
Wez Furlong
b441be3ac9 gui: vertically center cell within adjusted line height
When line_height is specified, rather than applying the offset
to just the top of the cell, apply it in equal parts to the top
and the bottom so that the cell is vertically centered.

closes: https://github.com/wez/wezterm/issues/582
2021-04-03 10:41:28 -07:00
Wez Furlong
4112b74f8a spawn local domain when starting gui in mux mode
This allows explicitly spawning commands locally, rather than
in the target mux.

this is similar to 12225a099a

refs: https://github.com/wez/wezterm/issues/468
2021-04-03 09:18:24 -07:00
Wez Furlong
298e0b8d76 hide mouse cursor each time we send key input to a pane
Mouse movement will show the cursor again.

macOS: fix hiding the cursor

refs: https://github.com/wez/wezterm/issues/618
2021-04-02 22:34:58 -07:00
Wez Furlong
4a3e0615f5 tweak ActivateLastTab and add a changelog entry for it
refs: https://github.com/wez/wezterm/pull/610
2021-04-02 09:29:52 -07:00
Alex Gartrell
ee4b4b598c Add ActivateLastTab command
This replicates `last-window` in tmux. To pull this off, I
deliberately store the last tab whenever I'm activating a new one or
spawning a new one. I had to do this explicitly rather than hooking
set_active, because we end up setting the active tab briefly for some
common operations like moving a tab.
2021-04-02 09:14:59 -07:00
Wez Furlong
d45bbed3fd ssh: fix handling wezterm ssh user@host:22 2021-03-29 21:21:31 -07:00
Wez Furlong
32fa186c99 wezterm-gui: add wezterm ssh -oIdentityFile=/some/thing
Allow overriding ssh config options from the command line.

I don't want to replicate the many options that `ssh(1)` has;
this just exposes the `-oNAME=VALUE` syntax.  The config names
are those from `man ssh_config`; `IdentityFile` rather than `-i`.

refs: #457
2021-03-28 08:24:35 -07:00
Wez Furlong
12225a099a fix spawning new tabs via launcher menu
I wonder how long this has been broken... rather than spawning
into domain "local" it would try to spawn into "`local`" and fail
silently because the error message wasn't logged.

So let's log it, and let's fix it.

refs: https://github.com/wez/wezterm/issues/468
2021-03-27 19:00:55 -07:00
Wez Furlong
53a13e60f5 start up "local" domain when spawning ssh
allows defining launch_menu items to spawn explicitly locally:

```lua
return {
  launch_menu = {
    {
      label = "Local zsh",
      args = {"zsh", "-l"},
      domain = {DomainName="local"},
    },
  }
}
```

refs: https://github.com/wez/wezterm/issues/468
2021-03-27 18:35:28 -07:00
Wez Furlong
e103653923 RemoteSshDomain now uses wezterm-ssh crate
There are a few notable changes as a result:

* A number of `.ssh/config` options are now respected; host matching
  and aliasing and identity file are the main things
* The authentication prompt is inline in the window, rather than
  popping up a separate authentication window

Refs: https://github.com/wez/wezterm/issues/457
2021-03-27 18:12:34 -07:00
Wez Furlong
c6308202cb hyperlinks, selection by word and line deal with wrapping better
These now operate in terms of logical lines so they deal with
lines that have wrapped outside the viewport better than in
previous releases.

closes: https://github.com/wez/wezterm/issues/408
2021-03-26 14:52:00 -07:00
Wez Furlong
0f23c140d1 partial revert of prior commit; it's not quite right
https://github.com/wez/wezterm/issues/408
2021-03-26 13:52:39 -07:00
Wez Furlong
d827be990d speculatively apply hyperlinks to logical lines
This might be all that is needed to make multiline implicit hyperlinks
function, but I need to transfer this commit to another machine to try
it.

refs: https://github.com/wez/wezterm/issues/527
refs: https://github.com/wez/wezterm/issues/408
2021-03-26 13:47:27 -07:00
Wez Furlong
0643e8b0ed add window:get_selection_text_for_pane
refs: https://github.com/wez/wezterm/issues/575
2021-03-25 22:10:29 -07:00
Aaron Abramov
786888ce0a update k9 to 0.11.0 to make it work with rustc@1.51.0
1.51.0 no longer takes non string literals in `panic()`. k9@0.11.0 fixes that
2021-03-25 10:39:00 -07:00
Wez Furlong
dbd7fc28a5 Raise minimum Rust version to 1.51, de-vendor openssl on unix
Rust 1.51 allows addressesing a long-standing TODO which was that we
shouldn't need to build a vendored copy of openssl on most sensible unix
systems.

We do require a vendored copy on macOS and Windows, but due to the way
that Cargo's feature resolver worked, it wasn't possible for this
requirement to be respected.

Rust 1.51 introduces `resolver="2"` which can deal with this feature
resolution!

https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2

The upshot of this is that building wezterm on real unix systems that
are not macos will now link against the system libssl, resulting in both
a shorter compile time and less headaches arising from having a slightly
different openssl used by wezterm than the rest of the system.

cc: @jsgf
2021-03-25 09:43:50 -07:00
Wez Furlong
b876fbabd6 remove the config bridge and have window -> config directly 2021-03-23 21:56:57 -07:00
Wez Furlong
f301fc6ecc avoid potential panic when processing double wide cells 2021-03-23 08:13:26 -07:00
Wez Furlong
5d96db3349 fix tests 2021-03-22 20:54:01 -07:00
Wez Furlong
8f856d0b81 font: make system fallback async wrt. rendering
If shaping can't resolve some glyphs, queue the font locator
fallback resolution to another thread; meanwhile, a last resort
glyph is used.

That thread can trigger an invalidation once the fallback resolve
is complete, the window is invalidated and the last resort glyph
is replaced by the resolve glyph.

refs: https://github.com/wez/wezterm/issues/559
refs: https://github.com/wez/wezterm/issues/508
2021-03-22 20:42:03 -07:00
dependabot[bot]
f032c5202a build(deps): bump windows from 0.4.0 to 0.5.0
Bumps [windows](https://github.com/microsoft/windows-rs) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/microsoft/windows-rs/releases)
- [Changelog](https://github.com/microsoft/windows-rs/blob/master/docs/changelog.md)
- [Commits](https://github.com/microsoft/windows-rs/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-22 13:55:43 -07:00
Wez Furlong
22522dc39e render more symbol/icon/emoji at double width by default
Default `allow_square_glyphs_to_overflow_width="WhenFollowedBySpace"`,
and expand its meaning from mostly square glyphs to glyphs that are
also wider than they are tall.

refs: https://github.com/wez/wezterm/issues/565
2021-03-22 11:36:45 -07:00
Wez Furlong
4fa85e7037 gui: avoid closing pty pane when double-activating search overlay
This is another variation on dcb6fec28f

refs: #572
2021-03-22 08:35:10 -07:00
Wez Furlong
a5f4803b0b fix panic when egl doesn't have OPENGL_API
refs: #566
2021-03-21 20:51:02 -07:00
Wez Furlong
a0d39989df simplify Color data type
There's something fishy with colorspaces and blending.
This commit removes the `window::Color` type and replaces
it and the confusing array of color types exposed by the
`palette` crate with a pair of much simpler types:

`LinearRgb` - a tuple of f32 linear color components
`SrgbaPixel` - the u32 sRGBA pixel representation

This doesn't change anything about rendering, it just
makes it a bit simpler and makes the SrgbaPixel -> LinearRgb
conversion happen slightly earlier which shaves off some
ad-hoc conversions.

Refs: https://github.com/wez/wezterm/issues/544
2021-03-21 16:54:22 -07:00
Wez Furlong
59ec969a26 gui: micro-optimize some aspects of rendering
hoist the underlyine glyph retrieval out of the loop.
Precompute some color conversions (less effective until
the gamma branch is merged).

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 13:40:24 -07:00
Wez Furlong
20e3d4d982 gui: use triple-buffering of vertexbuffers
The internet says that this is a recommended way to avoid stalling
when updating the vertex data.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 12:01:30 -07:00
Wez Furlong
1994a2ea2d gui: improve vertex buffer map/write/release performance
Switches from using a dynamic vertex buffer to an immutable
vertex buffer.  This feels counter-intuitive to me; the purpose
of dynamic is to sustain frequent updates, but mapping the buffer
needs to synchronize with the GPU, and if we are rapidly invalidating
the window that can stall painting by tens of milliseconds.

Switching to an immutable buffer avoids the stall and makes
quad mapping more consistently < 10ms, but its still not
ideal.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 10:28:17 -07:00
Wez Furlong
4767fcc28c windows: some minor performance improvements
* Make window invalidation more efficient by avoiding spawning a call
  that spawns a call to invalidate the window.  Just directly mark as
  invalidated.

* Suppress default background erase

* hoist the bg_color calc for quads that don't have Cells outside of
  its loop.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 10:06:43 -07:00
Wez Furlong
8015791dd0 fixup initial pty dimensions to account for font/dpi size
refs: https://github.com/wez/wezterm/issues/563
2021-03-20 13:17:32 -07:00
Wez Furlong
3d0f3eaeec gui: avoid doing work when WM sends spurious resize events
refs: #557
2021-03-19 08:11:39 -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
5681cd9b64 gui: update windows dep to 0.4 2021-03-14 15:25:33 -07:00
Wez Furlong
04b7cedd02 fix animated gif playback
A casualty of b8dcfba9a4 was that
the decoded gif would get reset each time the texture filled up.

Take care to move that cached into the newly minted glyphcache.
2021-03-14 10:29:02 -07:00
Wez Furlong
09081d2189 improve texture upload performance, part 2
Continuing along the same lines as the prior commit, the goal
of this commit is to remove the buffer transformation that was
part of uploading the texture to the GPU provided surface.

In order to do so:

* The sense of our local textures needs to change from bgra32 to rgba32.
  bgra32 was a hangover from earlier versions of our window crate that
  allowed direct-to-fb writes in software mode.  We had to pick bgra32
  for that for the broadest OS compatibility.  I believe that that
  constraint has been totally removed, although there is a chance that
  this will flip the colors on macos.
* There was an additional linear-to-srgb conversion inlined in that
  buffer transformation.  I have no idea where that is needed because
  the source data is carefully constructed as SRGB.  I don't yet know
  how to signal that, but for now I've moved that gamma correction
  into the shader when we sample the texture.

With this change, timg playback now has vtparse as the hottest
region of code.

refs: #537
2021-03-14 09:14:30 -07:00
Wez Furlong
b8dcfba9a4 improve texture upload performance
Two issues highlighted by profiling:

* Clearing the texture takes a non-trivial percentage of the profile.
  The docs suggest that it is better to create a new texture than
  to update large portions of a texture, so add some plumbing so
  that we can do that in the first texture-full case.

* Next on the list is the code that translates from linear BGRA to
  SRGBA.  This is present for reasons that I believe are now legacy,
  but for the moment: those two primitives now have faster and
  easier implementations, so simplify to those.

This improves the timg video playback performance by ~10% for me.

refs: #537
2021-03-13 23:18:15 -08: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
333f5f9750 fix a rounding issue when computing block glyphs
The leftmost pixel was being set to at least 1 by the scale
function.

Fix that up by computing the x coordinate without calling
the scale function.

refs: https://github.com/wez/wezterm/issues/536
2021-03-13 11:29:57 -08:00
Wez Furlong
3d642461f8 fixup pty pixel size calculation
Derive the pixels from the rows/cols rather than the available space.

refs: https://github.com/wez/wezterm/issues/535
2021-03-13 09:31:13 -08:00
Wez Furlong
f4105cb42f avoid excess capacity when dealing with iterm2 image protocol
Using a boxed slice means that we hold exactly the memory required
for the file data, rather than the next-power-of-two, which can
be wasteful when a large number of images are being sent to
the terminal.

This is a API breaking change for termwiz, so bump its version.

refs: #534
2021-03-13 08:10:48 -08:00
Wez Furlong
dd5db065dc remove stray debug print 2021-03-13 08:06:03 -08:00
Wez Furlong
9be7b8f6ec and fixup the test build
refs: #534
2021-03-13 01:03:04 -08:00
Wez Furlong
26f9d91e43 set an upper bound on the image/frame caches
While adding gif support I let this become unbounded.
This commit resolves that by categorizing images as either
single frame or animations.

Single frame images are decoded and held entirely in the texture
atlas, so occupy no additional space beyond the image file contents
and their sprite region in the texture atlas.

Animations are decoded into a set of frame bitmaps.  There can be
up to 16 animations (each with their full set of frames) cached.
The individual frames may also exist within the texture atlas
if space permits.

refs: #534
2021-03-13 00:47:38 -08:00
Wez Furlong
48a3674c9a wayland: fix a panic during initialization 2021-03-12 22:48:37 -08:00
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
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
8009863f9b fonts: shaper: also handle <wideglyph><spacer><spacer> ligatures
The Cascadia Code font has ligatures for `---` that consist of
a triple wide glyph followed by two zero-width glyphs.  Rewrite
that into a single glyph that spans three cells and remove the
zero-width glyphs from the shaped info.

refs: https://github.com/wez/wezterm/issues/478
2021-02-25 21:16:10 -08:00
Wez Furlong
9f89dde899 Avoid an unwrap
refs: https://github.com/wez/wezterm/issues/478
2021-02-23 22:06:02 -08:00
Wez Furlong
c964b69b1d Add ScrollByLine key assignment
refs: #497
2021-02-23 08:02:07 -08:00
Wez Furlong
3e44abcca8 Adopt new shaper logic in gui
Connect the gui to the new shaping logic; this means that we
can now correctly render fg/bg color when the cursor moves
through the cells that comprise a ligature.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
63555086b6 move shaper helper bits into shapecache
refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
5eb7634403 gui: factor image cell rendering into its own function 2021-02-22 19:17:24 -08:00
Wez Furlong
ee17e4e174 Add shaper post-processing function
This function is intended to deal with certain kinds of ligatures
and certain combining sequences that don't have corresponding glyphs.

It isn't hooked up to the gui yet, but does have unit tests that
are probably mostly correct.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
7a16e71e07 Add ResetFontAndWindowSize key assignment
closes: https://github.com/wez/wezterm/issues/480
2021-02-20 21:50:20 -08:00
Wez Furlong
a91c0a5d98 fixup render for macos
Apparently we need to enable srgb for all three stages in order
to output correct color.

refs: #491
2021-02-20 20:32:30 -08:00
Wez Furlong
82fc53d736 rasterize: refine blending math
Refine the colorization logic to make it more of a blending operation.
Previously, we were relying on opengl to carry out blending between
layers on our behalf, but that wasn't perfect.

This commit is inspired by this post:
https://www.puredevsoftware.com/blog/2019/01/22/sub-pixel-gamma-correct-font-rendering/
and factors in the background color when computing the colorized
glyph.

This appears to reduce the dark fringes/edges that we were seeing
before, without noticeably changing the brightness of the result.

refs: #491
2021-02-20 18:00:23 -08:00
Wez Furlong
4e2b2eddba split shaders, adjust srgb opengl render settings
https://learnopengl.com/Advanced-Lighting/Gamma-Correction suggests
some good practices:

* Only enable SRGB output on the final draw call, so that all prior
  stages can operate on linear values and avoid converting to/from
  linear multiple times.
* The SRGBA textures automatically linearize when sampled, but:
  * The RGB data must be SRGB (non-linear)
  * The A channel is assumed to be linear!

This commit nudges us closer to that by:

* Converting the freetype coverage map from its linear value to
  non-linear when rasterizing.
* Splitting the shader files into one per stage (background, lines,
  glyphs) and only setting outputs_srgb for the glyph stage

refs: #491
2021-02-20 17:12:36 -08:00
Wez Furlong
08b6043166 gui: introduce foreground_text_hsb transform
This allows explicitly manipulating the hue, saturation, brightness
of the text rendered in the terminal, allowing users to dial in
the accidental effect that was introduced by
d886de8300

For example, this will punch up the brightness:

```
  foreground_text_hsb = {
    hue = 1.0,
    saturation = 1.0,
    brightness = 1.5,
  },
```

refs: https://github.com/wez/wezterm/issues/491
2021-02-19 08:30:32 -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
3f91e30719 toast: windows: setup own AppUserModelID for our notifications
This is so that our notifications show as coming from wezterm
rather than powershell.
2021-02-17 23:45:52 -08:00
Wez Furlong
d886de8300 remove overzealous alpha manipulation
This isn't a complete fix, but it's best to get this out
of the way and then take another pass as the dark outline.

refs: #491
2021-02-17 21:46:03 -08:00
Wez Furlong
83da7216c3 toast: hook notifications up to OSC 9
refs: #489
2021-02-17 09:33:58 -08:00
Wez Furlong
145b7695c7 wezterm: more adventures in antialiasing
This commit:

* Fixes up the alpha blending draw parameters as discussed in
  https://github.com/glium/glium/issues/1844 and
  https://github.com/PistonDevelopers/conrod/issues/1347

* Introduces `colorize` and `colorize_hsv` functions to the shader.
  comments in the code explain those functions in detail.

As of this commit, `colorize_hsv` is what is used now.  To my
eye on this mac, it produces blended glyphs with less noticeable
dark antialiasing fringes.

refs: #470
2021-02-15 21:21:24 -08:00
Wez Furlong
0473e1de78 wezterm: more adventures with background alpha
Is it *right*? Hard to say, but it looks better than
the behavior I see with master at the moment.

This is a partial revert of #413, but respins it to
try to get a better alpha value for glyphs.

refs: #413
refs: #470
2021-02-13 13:16:37 -08:00
Wez Furlong
7b86a84bc3 window: avoid invalidating on mouse move
We weren't didn't treat the "No existing hyperlink, No new hyperlink"
case as no change in hyperlink, and were invalidating the window on
every mouse except for those over text with a hyperlink.
2021-02-13 08:49:09 -08:00
Greg V
58e2a181f2 wayland: do not create OpenGL context before the configure event
The existing code seems to use "configure" for just resizes,
so introduce a "start" flag in pending events to handle the
initial configure.
2021-02-12 16:56:24 -08:00
Wez Furlong
6410827581 wayland: remove window from mux if gui fails to create window
This avoids a weird "headless hang" if a window doesn't come up with
opengl support.
2021-02-12 08:21:00 -08:00
Wez Furlong
6371ec501a OSC 52: update it so that it we respect primary vs. clipboard selection 2021-02-08 08:56:06 -08:00
Wez Furlong
005b492a8b deps: update to ordered-float 2.1 2021-02-07 22:54:02 -08:00
Benoit de Chezelles
1eaa7ed47c Add Ctrl-u in search mode to clear the current search pattern 2021-02-07 18:57:06 -08:00
Benoit de Chezelles
c576b9d534
Add cli option --config-file (#459)
* Add cli option --config-file
* Update cli arg doc & make it conflict with skipping config
* When the config is given explicitly (either using --config-file or via WEZTERM_CONFIG_FILE), failing to load this file will use the default config.
* Otherwise the config file is searched one by one in a few directories.
2021-02-07 08:47:33 -08:00
Wez Furlong
d9275e110c deps: update metrics from 0.12 -> 0.14 2021-02-03 23:50:29 -08:00
Wez Furlong
70a364eb3f wezterm: use full alpha blending for glyphs
refs: https://github.com/wez/wezterm/issues/413
2021-02-03 08:55:49 -08:00
Wez Furlong
0c1ecc0fad wezterm: macos: show a toast notification when an update is available
This commit implements the deprecated NSUserNotification bits needed
to be able to handle clicking on a notification and open our choice
of URL.

Ideally we'd use the newer UserNotifications framework, but that
requires code signing.
2021-02-01 23:37:43 -08:00
Wez Furlong
17435d9589 wezterm: make it clearer which keys to use in confirmation dialogs
refs: https://github.com/wez/wezterm/issues/436
2021-02-01 18:48:54 -08:00
Wez Furlong
6bfadfac0a macos: handle dead keys without IME
Dead key processing respects the
`send_composed_key_when_left_alt_is_pressed` and
`send_composed_key_when_right_alt_is_pressed` options.

See doc changes included in this commit for more info.

refs: https://github.com/wez/wezterm/issues/410
2021-01-31 17:06:30 -08:00
Wez Furlong
df3387e12c wezterm: change default copy/paste behavior on X11
This commit changes mouse-based selection and middle click to use the
PrimarySelection.

CTRL-SHIFT-{C,V} use Clipboard.

{SHIFT,CTRL}-Insert use PrimarySelection.

`CompleteSelection` and `CompleteSelectionOrOpenLinkAtMouseCursor` now
require a parameter to specify the destination clipboard.

Removed the `default_clipboard_XXX` options added in
8dad34fa61 in favor of just explicitly
assigning the key/mouse bindings.

closes: #417
2021-01-31 09:28:42 -08:00
Zeyi (Rice) Fan
6b9401365c
Only disable drop shadow on macOS when window background opacity is transparent (#445)
* only set shadow when background is transparent

* set opaque correctly
2021-01-30 07:58:53 -08:00
Wez Furlong
8dad34fa61 more configuration options for Copy/Paste
* Adds `CopyTo` and `PasteFrom` assignments that specify the
  destination/source.
* Adds `default_clipboard_copy_destination` and `default_paste_source`
  config options that specify the default destination/source for
  existing `Copy` and `Paste` operations (for @bew)
* Deprecating `PastePrimarySelection` in favor of `PasteFrom`.
* Added `CTRL-Insert` -> `Copy` (for @Babar)

Aside from the new key assignment, these changes shouldn't change
the default behavior, but do make it easier to consider changing
that in a later commit.

They should allow for example:

* Set `default_clipboard_copy_destination = "PrimarySelection"` to
  prevent populating the clipboard by default when using the mouse.
* Overriding the CTRL-Insert, CTRL-SHIFT-C to explicitly populate
  the clipboard
* Set `default_paste_source = "PrimarySelection"` for middle click
  to paste the selection.
* Overriding SHIFT-Insert, CTRL-SHIFT-V to explicitly paste from
  the clipboard.

refs: #417
2021-01-27 10:20:17 -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
3256a949d8 wezterm: tidy up the "update available" banner
Change the underline color so it looks a bit less crowded on hover
2021-01-18 16:21:56 -08:00
Wez Furlong
89c1ac5b4c wezterm: add adjust_window_size_when_changing_font_size option
The default is true, which means that adjusting the font size will
cause the window to resize to preserve the number of rows/cols in
the terminal.

When set to false, the window size is preserved and the number of
terminal rows/cols is adjusted instead.

refs: https://github.com/wez/wezterm/issues/431
2021-01-18 13:23:02 -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
957ad6af90 windows: avoid panic on startup
In 30b262c1c0 I introduced an unwrap
here.  On Windows, this code can be called before we've set up opengl.
Allow for that!
2021-01-17 10:24:58 -08:00
Wez Furlong
fa4bbbd077 ugh, fix stupid formatting syntax error
refs: https://github.com/wez/wezterm/issues/428
2021-01-16 08:47:36 -08:00
Wez Furlong
4bbe67aac3 gui: refuse to scale to sizes where cell height would be < 2 pixels
refs: https://github.com/wez/wezterm/issues/428
2021-01-16 08:45:38 -08:00
Wez Furlong
db964a91a0 gui: handle a failure to compute font metrics at very small scales
https://github.com/wez/wezterm/issues/428
2021-01-16 08:27:32 -08:00