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

812 Commits

Author SHA1 Message Date
Wez Furlong
d5726ba91a window: add RawKeyEvent concept
on macos only (for now), we generate a RawKeyEvent prior to
dead key or IME composition and route it to the window to give it
a chance to handle the event.

RawKeyEvent handling is scoped only to key assignments, not generating
input for the terminal.

A raw key event can be marked as handled to prevent moving on to
performing composition and generating cooked key input.

refs: https://github.com/wez/wezterm/issues/877
2022-01-02 15:04:27 -07:00
Wez Furlong
69e8d9144c gui: allow matching keys with a physical position
```lua
local wezterm = require 'wezterm'

return {
  debug_key_events = true,
  keys = {
    {key="phys:Q", action=wezterm.action{SendString="woot"}},
  },
}
```

The above will send "woot" to the pane whenever the key in same
physical position as Q on an ANSI standard US keyboard is pressed.

refs: https://github.com/wez/wezterm/issues/1483
2022-01-02 01:20:21 -07:00
Wez Furlong
b15907f61f input-types: introduce PhysKeyCode type
Based on the mac constants of the equivalent functionality;
may need some tweaking for other OS's.

refs: https://github.com/wez/wezterm/issues/1483
2022-01-01 21:35:37 -07:00
Wez Furlong
ea7030ae11 clarify the purpose of wezterm start in the --help output
This makes it a bit more understandable/discoverable.

refs: #1478
2022-01-01 12:44:38 -07:00
Wez Furlong
8251e04c63 gui: invalidate windows resources when icon changes
I noticed that by myself and another user who built from source
still had the old icon show up.
2022-01-01 12:15:03 -07:00
Wez Furlong
907b92b3ea gui: box: better job at avoiding overflowing bounds
This makes the x button overflow look better when the tab titles are
wide
2022-01-01 09:03:19 -07:00
Wez Furlong
7e8e215dc7 gui: remove adjust from vertex
This comes from a time where our quads were always locked to grid
positions.  We don't need it any more: we can simply add the adjustments
to the quad positions that we set.

Removing it makes the vertex a bit smaller and reduces the amount
of GPU accessible memory we need to use.
2022-01-01 08:11:10 -07:00
Wez Furlong
0184038c55 gui: invalidate window after window:perform_action
closes: #1475
2021-12-31 10:02:15 -07:00
Wez Furlong
7efc6a6cb8 gui: ensure that the tab bar occupies a full pixel height
Otherwise we get weird vertical misalignment effects in the
terminal cell area for eg: the top of a `z` glyph being drawn
at a half pixel height.
2021-12-30 20:06:05 -07:00
Wez Furlong
1e7d552844 fonts: replace font_ptr with a font id
I'm running down a weird thing where the main font renders weirdly
when the title font is 12 pt vs the main font 10 pt.

I thought there might have been a cache invalidation issue and
realized that we could have an A-B-A style issue with the font_ptr
stuff, so I replaced it with an incrementing id.

That didn't fix the thing I was looking at, but does feel a bit
nicer overall.
2021-12-30 19:09:30 -07:00
Wez Furlong
00a393b3d1 gui: bundle and use Roboto for title font on Linux + Windows
The default we use on macOS looks decent.  Roboto is a similar
looking font that we can use for the other platforms.
I may make it the same on all three once I've had a chance
to compare it on a mac.
2021-12-30 17:51:22 -07:00
Wez Furlong
97c8cda974 gui: ls-fonts: include title font in ls-fonts output 2021-12-30 16:51:30 -07:00
Wez Furlong
561efcb8d1 gui: invalidate fancy tab bar on config reload
Otherwise we won't pick up font changes as quickly
2021-12-30 16:50:44 -07:00
Wez Furlong
07af7e0c4b gui: constrain fancy tab size to fit the width
closes: https://github.com/wez/wezterm/issues/1470
2021-12-30 09:20:51 -07:00
Wez Furlong
e5dd859ecc gui: tidy up metrics/line widths for X and + tab bar buttons 2021-12-29 09:00:50 -07:00
Wez Furlong
5608e9477b termwiz: make seqno a required param for Line
Previously, we would implicitly set it to the special SEQ_ZERO
value, but since that value always flags the row as changed,
it causes some over-invalidation issues downstream in wezterm.

This commit makes that parameter required, so that the code that
is creating a new Line always passes down the seqno from that event.

refs: #1472
2021-12-29 08:34:59 -07:00
Wez Furlong
93a9b5a7fe gui: add Poly content drawing to box model; use it for x and + buttons
This should make those buttons look a bit more consistent
2021-12-28 23:24:18 -07:00
Wez Furlong
74caa9c173 gui: fixup bottom alignment of tab bar buttons 2021-12-28 21:53:08 -07:00
Wez Furlong
add3863871 gui: add x close button in fancy tabs
closes: #1351
2021-12-28 19:15:45 -07:00
Wez Furlong
494a0983ee gui: cache shaping and layout of fancy tab bar, allow placing at bottom
We only need to recompute when the tab content changes, or when
the window is resized, plus invalidations of the shape cache
of texture atlas filling up.

Hover events don't need to re-shape.

We can now also place the tab bar at the bottom of the screen again.
2021-12-28 12:29:54 -07:00
Wez Furlong
cc2bbced82 gui: respect tab background color
The main tab area now takes the background color from the first
cell in a formatted tab bar item as the full background color
for the whole tab area, which looks a lot nicer than just the
using that color for the minimal bounding box of the tab text.
2021-12-28 10:10:13 -07:00
Wez Furlong
f92d8112ae gui: avoid seeing right-status underneath left tabs when window is small
Introduce an opaque container to hold the left items and have that
sit over the top of the floated right status area to make things
look cleaner.
2021-12-28 09:22:16 -07:00
Wez Furlong
4ca7514029 gui: tighten up fancy tab bar to 1.75 line height
Add bottom alignment for tabs and make them slightly shorter
than the right status area; this avoids some pixel gaps.
2021-12-28 08:51:09 -07:00
Wez Furlong
13ac944e7f cargo fmt
refs: #1468
2021-12-28 08:50:43 -07:00
Wez Furlong
6ac6ac45b6 lua: add pane:get_logical_lines_as_text
refs: #1468
2021-12-28 08:04:41 -07:00
Wez Furlong
f4fab10e69 gui: box model style layout/render for fancy tab bar
This commit adds a CSS box model inspired element / layout
facility, and replaces the hand implemented fancy tab bar
element render.

This makes the code for fancy tab bar much easier to read
and update.

The right status area now expands to the full height of the
tab bar area, and uses a line height of 2.0, which makes
it line up nicely in the tab bar.
2021-12-28 00:14:54 -07:00
Wez Furlong
8c7072c5ef gui: flesh out test case for wsl -l -v
closes: https://github.com/wez/wezterm/issues/1462
2021-12-27 10:39:26 -07:00
Wez Furlong
780756bea8 gui: don't warn about wsl helper function on unix
Technically is only used on windows, but I'm fine with having
it built and tested on all platforms.
2021-12-27 10:35:11 -07:00
Wez Furlong
7e90a7008c deps: update pulldown_cmark, cargo update 2021-12-27 09:49:22 -07:00
Wez Furlong
4cf90bf7a1 gui: avoid invalidating window when only a modifier key is held down 2021-12-26 12:58:14 -07:00
Wez Furlong
2464e8fb3a gui: use wsl -l -v output for launcher items
Switch to the slightly more structured verbose output of `wsl -l -v`
in the hope that we are less prone to localization issues and
are more robust in the face of future changes.

refs: #1462
2021-12-26 09:19:38 -07:00
Wez Furlong
d51ce704d9 gui: don't use win32 gui subsystem in test configuration
We won't see test output in that case, because the tests won't
be able to write to the console!
2021-12-26 09:16:22 -07:00
Wez Furlong
2e24b0fc22 gui: improve new tab button appearance for fancy tab bar 2021-12-26 08:21:09 -07:00
Wez Furlong
790b515c21 gui: allow mouse wheel to route to hovered pane
refs: https://github.com/wez/wezterm/issues/798
2021-12-25 15:37:14 -07:00
Wez Furlong
c937f0c77c cargo fmt 2021-12-25 14:01:36 -07:00
Wez Furlong
a1ff2d6415 gui: make another pass over focus/mouse event routing
refs: #1437
2021-12-25 13:59:23 -07:00
Wez Furlong
56420205e9 gui: fix over-opacity with split panes and transparent windows
closes: #1459
2021-12-25 12:20:40 -07:00
Wez Furlong
a78ff883a9 windows: query the system caption font
Use this for the tab bar font by default
2021-12-25 09:54:31 -07:00
Wez Furlong
714e74e7af fonts: move computation of title font to wezterm-fonts
Rather than hardcode a fixed default value in the config crate, define
the default as optional and leave it to the font crate to compute
the value.

This is a step towards allow introducing system dependent GUI related
code to resolve/understand the title font: we can't put that directly
in the config crate.
2021-12-25 07:49:46 -07:00
Wez Furlong
3a628527b7 gui: fix right width of right status area in fancy tab bar
refs: #1180
2021-12-24 18:07:24 -07:00
Wez Furlong
ebaf49ad6b gui: use first cell bg/fg color for fancy tab bg/fg
refs: #1180
2021-12-24 17:42:01 -07:00
Wez Furlong
240382bcf1 gui: fix fancy tab height
Always match the height of the background strip, which is
2*metrics.height.

refs: #1180
2021-12-24 16:34:45 -07:00
Wez Furlong
8eb7c3cff4 gui: fancy tab bars are now the default
Adjust the rendering and coloring a bit to make the defaults
look pretty reasonable.

refs: #1180
2021-12-24 16:23:01 -07:00
Wez Furlong
6c1710f87d mux: remove ProgDomain; just pass down default prog/cwd as appropriate
This allows making these values configurable per-domain in the
future.

refs: #1456
2021-12-24 07:52:02 -07:00
Wez Furlong
bd6072b320 avoid default_prog, default_cwd when spawning panes via ssh
refs: https://github.com/wez/wezterm/issues/1456
2021-12-23 23:24:42 -07:00
Wez Furlong
1d064e0913 Add get_foreground_process_name, expose it and cwd in PaneInformation
Add `get_foreground_process_name` to both Pane and the lua wrapper.

Add `foreground_process_name` and `current_working_dir` fields to
`PaneInformation`.  In order for those to be dynamically fetched,
switch the lua conversion for `PaneInformation` to be a UserData
with field access methods.  It's a little more verbose but allows
us to lazily compute these two new fields.

refs: https://github.com/wez/wezterm/discussions/1421
refs: https://github.com/wez/wezterm/issues/915
refs: https://github.com/wez/wezterm/issues/876
2021-12-23 18:49:17 -07:00
Wez Furlong
38087755e1 quickselect: allow changing label for custom actions 2021-12-23 16:32:20 -07:00
Wez Furlong
3a5f6f94a6 quickselect: refine out of bounds case
I now understand that it is simply because the number of matches is too
large to be represented by a two character string in the selected
alphabet.
2021-12-23 13:58:10 -07:00
Wez Furlong
4bd29ae5cc gui: fix ringing bell shape
Don't want it to be the block outline

refs: #1432
2021-12-23 11:56:40 -07:00
Wez Furlong
668d41ad5d quickselect: add QuickSelectArgs and helpers for opening urls
This commit expands quick select mode so that you can trigger it
with distinct sets of patterns (eg: urls on one key assignment,
hashes on a different key assignment), different alphabets,
and lastly, the option to perform a different action from
the default copy action.

You can pair this with `action_callback` to run lua code to
do something with the selected text.

This commit also adds `wezterm.open_with`, a helper function
for opening documents/URLs.

refs: #846
refs: #1362
2021-12-23 10:55:44 -07:00
Wez Furlong
6a265d9f72 new ActivateTabRelativeNoWrap key assignment
refs: #1414
2021-12-23 09:32:49 -07:00
Wez Furlong
3856a61527 bleh, cargo fmt 2021-12-23 08:57:24 -07:00
Wez Furlong
becd107600 gui: quickselect: instrument and avoid potential panic
The label dedup code has panicked on me a couple of times.
I managed to capture the line number, so this commit aims to
capture some state to try to understand what's going on,
and importantly, to avoid the actual panic part.

refs: #1271
2021-12-23 08:55:36 -07:00
Autumn Lamonte
0a93a58605 New optional argument 'doNotMoveCursor' for iTerm2 images. This
permits iTerm2 images to be drawn anywhere on screen without
scrolling the cursor, including the bottom row.

Also included is a check in fcwrap.rs to_range_set(), without which
was causing a panic at runtime due to subtraction from unsigned
leading to overflow.
2021-12-23 07:07:08 -08:00
Wez Furlong
162d5a79ee gui: fix switched parameters when updating initial geometry
refs: #1387
refs: #1270
2021-12-23 07:58:24 -07:00
Wez Furlong
294579fd31 term: introduce right&bottom padding to ImageCell
This helps us correctly set the size of the image cell
for the case where we have a partial cell at the right/bottom
edge of an image being mapped across cells.

refs: #1270
2021-12-23 07:26:49 -07:00
Wez Furlong
9ed80fb22b fix typo is commented out portion of shader 2021-12-22 21:03:19 -07:00
Wez Furlong
89d4c61dae gui: fixup shader linear->srgb math
Move away from the imprecise simple pow version and over to a
version that properly respects the linear and non-linear portions
of the curve.

refs: #1025
2021-12-22 20:57:17 -07:00
Wez Furlong
9e146beb02 gui: more fun with gamma correction
On Windows, both EGL and MESA render modes were too dark.
After a bit of hunting around what I found made EGL and MESA
consistent with my default nVidia GPL rendering was:

* Tell glium that our shader outputs srgb
* Add explicit gamma conversion from linear to srgb in the shader

AFAICT, that shouldn't be required, but it seems as though something
deep in glium really wants to apply some kind of gamma conversion,
and it seems to select the wrong kind unless we set things explicitly
to SRGB.

There are some people complaining about this in
https://github.com/glium/glium/issues/1615.

I actually tried to move entirely aware from the glium srgbtexture2d
type in the hope of having explicit control over the gamma, but the
issue is in what happens to the outputs rather than the inputs.

It appears to me as though the text now looks slightly less
intense, so I think this may be what we need for the gamma issue
in https://github.com/wez/wezterm/issues/544 and potentially
also https://github.com/wez/wezterm/issues/1025

refs: https://github.com/wez/wezterm/issues/1373
2021-12-22 18:14:52 -07:00
Wez Furlong
5c222cfcdc term: allow iterm2 file transfer protocol
Adds some plumbing to allow the GUI to implement a download handler
and connect that up for iterm2 image/file transfers that have their
inline property set to false.

Previously we'd just log an error.

Now we will by default download the file to the user's download
directory.

This behavior can be turned off via the new `allow_download_protocols`
configuration setting.

File transfers can be initiated on a remote host via the
https://iterm2.com/utilities/it2dl script.

When the download completes, a toast notification is shown that will
open the file when clicked.

refs: https://github.com/wez/wezterm/discussions/1450
2021-12-22 09:21:39 -07:00
Wez Furlong
1c9b9f69e0 gui: simplify some text cursor rendering
Remove special case for blocks where we switched it out for a blank
sprite and instead varied the cell background.

We now always render a matching cursor sprite as a separate layer
over the top of the text background color, but below the text
foreground layer.

This is preparing for https://github.com/wez/wezterm/issues/1432

Make bar/line cursors use the text foreground color when reverse
video cursors are enabled, per @VKondakoff:
https://github.com/wez/wezterm/issues/1076#issuecomment-978214136
2021-12-21 22:49:52 -07:00
Wez Furlong
525739acb3 gui: revise unfocused mouse event handling
This adjusts the logic to suppress moves and clicks, but to
pass through wheel events.

refs: https://github.com/wez/wezterm/issues/1437
2021-12-21 21:48:20 -07:00
Wez Furlong
b40f65c25e termwiz: s/Fuschia/Fuchsia/g
closes: #1407
2021-12-21 20:38:59 -07:00
Wez Furlong
d2e73e10cf gui: make unfocused bar cursor more distinct from focused bar
This isn't perfect and I'm not 100% sure about it.

refs #1445
2021-12-21 08:56:21 -07:00
Wez Furlong
37c83b8308 deps: update 2021-12-20 08:15:56 -07:00
Wez Furlong
e9f1297b45 mux: improve Window closing behavior
Finally getting around to fixing this usability wart: this commit
changes the behavior of Window closing so that you can close a window
containing multiplexer panes without prompting and without killing
off those panes.

This is achieved through some plumbing:

* The mux can now advise Domains about an impending window closure,
  giving them the opportunity to "do things" in readiness.
* The mux client domain informs the container ClientPane instances
  to ignore the next Pane::kill call, which would otherwise inform
  the mux server to kill the remote pane
* Pane:can_close_without_prompting now requires a CloseReason.
* ClientPane's can_close_without_prompting impl allows Window closing
  without prompting on the assumption that the ignore-next-kill hack
  above is working

refs: #848
refs: #917
refs: #1224
2021-12-19 09:07:11 -07:00
Wez Furlong
9e9e76bf0a mux: Pane::reader now returns Result<Option<Read>>
The mux client just returns a dummy reader, and some overlays
have panicking stubs: just allow for them to return None
instead of potentially spawning a useless thread.
2021-12-19 06:30:39 -07:00
Wez Furlong
2412e663f8 gui: add missing dep for windows
refs: #1402
2021-12-17 21:28:41 -07:00
Wez Furlong
120a3dfe12 gui: improve how we handle online changes to update checking config
Previously, we would only look at the `check_for_updates` config
on startup.

This commit adjusts the update checker logic so that we always
start it, and that we respect config reloads.
2021-12-17 21:23:57 -07:00
Wez Furlong
1d4a0a9592 gui: improve update notifications
Only show the update window and/or generate a toast notification
is the current wezterm-gui process is the eldest of the set of
running wezterm-guis.

This avoids spamming the user with update information.

refs: https://github.com/wez/wezterm/issues/1402
2021-12-17 21:13:07 -07:00
Wez Furlong
c33f548db3 gui: explicitly track click-to-focus state
we need to skip processing mouse events while in that state,
until we see the mouse release.

refs: #1310
2021-12-12 22:45:46 -07:00
Wez Furlong
ada35ff3db gui: improve handling of dpi changes especially during window creation
This fixes up the Windows issue, but I wonder if it also helps with the
mac issue?

refs: https://github.com/wez/wezterm/issues/1039
refs: https://github.com/wez/wezterm/issues/1381
2021-12-12 09:27:37 -07:00
Wez Furlong
20e424f54b add default_gui_startup_args config
closes: https://github.com/wez/wezterm/issues/1030
2021-12-11 23:18:22 -07:00
Wez Furlong
66908eabb4 add ScrollToTop and ScrollToBottom key assignments
refs: https://github.com/wez/wezterm/issues/1360
2021-12-11 22:02:31 -07:00
Wez Furlong
bf34be3ab8 gui: ResetFontAndWindowSize should use known dpi
This code was partially replicating the initial window setup
where we didn't necessarily know the dpi, but in the context
where this is run, we do know the dpi for the window, so
let's consistently use that number throughout.

refs: #1039
2021-12-11 09:43:32 -07:00
Wez Furlong
04cb8d1d3b gui: skip mouse event handling if window is not focused
The intent is to workaround what appears to be an i3 bug.
Not totally sure this is a good change, but let's try it!

Might also help with an issue on macos.

refs: #1140
refs: #1310
2021-12-10 10:33:00 -07:00
Wez Furlong
7b402678e4 gui: fix initial pixel geometry on hidpi displays
refs: #1387
2021-12-10 09:20:41 -07:00
Wez Furlong
f905ec8100 fix some unused/unread field warnings 2021-12-10 08:18:36 -07:00
Wez Furlong
348ddcb122 quickselect: de-dup labels
refs: #1271
2021-12-09 09:50:32 -07:00
Wez Furlong
b9aec2fcad tabbar: fix double wide characters in tab titles
refs: #1371
2021-12-09 08:34:19 -07:00
Wez Furlong
bde2c728bf ci: use consistent git core.abbrev setting for TAGNAME
refs: https://github.com/wez/wezterm/issues/1365
2021-12-05 19:21:06 -07:00
Wez Furlong
9ceb6357b8 Apply newly defined domains to the mux on config reload
refs: https://github.com/wez/wezterm/issues/1279
2021-12-03 22:56:03 -07:00
Wez Furlong
78d4329ca7 gui: improve how per-pane palette backgrounds are rendered
We now try to avoid black background bounaries by filling out to where
the edges of the splits are.

refs: #1256
2021-12-03 10:14:00 -07:00
Wez Furlong
0a16c90283 gui: fix double padding for pane background color position
When splitting, the bottom the pane background was offset by an
additional padding increment -> fix it!

refs #1256
2021-12-03 09:36:02 -07:00
Wez Furlong
545b70b0d5 gui: adjust how the split lines are drawn
This moves away from using special block glyphs for the lines and
just draws lines directly.

In addition, since these lines are no longer constrained to available
glyphs or glyph boundaries, we can now render lines that cross when
there are a mix of horizontal and vertical splits, which looks a
bit nicer.

refs: #1256
2021-12-03 09:29:50 -07:00
Wez Furlong
9a25a6deed fix initial window size when using fancy tab bar
closes: #1340
2021-12-02 09:13:49 -07:00
Wez Furlong
232b220d08 Avoid looping if window:set_config_overrides doesn't change the config
Assuming that the window config reloaded hook doesn't actually change
anything, this will avoid a cycle where we keep triggering the hook
over and over.
2021-12-01 08:45:12 -07:00
Wez Furlong
225e7a1243 introduce unicode_version config
This is a fairly far-reaching commit. The idea is:

* Introduce a unicode_version config that specifies the default level
  of unicode conformance for each newly created Terminal (each Pane)
* The unicode_version is passed down to the `grapheme_column_width`
  function which interprets the width based on the version
* `Cell` records the width so that later calculations don't need to
  know the unicode version

In a subsequent diff, I will introduce an escape sequence that allows
setting/pushing/popping the unicode version so that it can be overridden
via eg: a shell alias prior to launching an application that uses a
different version of unicode from the default.

This approach allows output from multiple applications with differing
understanding of unicode to coexist on the same screen a little more
sanely.

Note that the default `unicode_version` is set to 9, which means that
emoji presentation selectors are now by-default ignored.  This was
selected to better match the level of support in widely deployed
applications.

I expect to raise that default version in the future.

Also worth noting: there are a number of callers of
`unicode_column_width` in things like overlays and lua helper functions
that pass `None` for the unicode version: these will assume the latest
known-to-wezterm/termwiz version of unicode to be desired. If those
overlays do things with emoji presentation selectors, then there may be
some alignment artifacts. That can be tackled in a follow up commit.

refs: #1231
refs: #997
2021-11-25 09:00:45 -07:00
Wez Furlong
3b30230d58 windows: gui: only attach parent console when spawned by wezterm
speculative attempt to do something about https://github.com/wez/wezterm/issues/1278
2021-11-21 09:21:44 -07:00
Cédric Schieli
311eb30d7f Remove unneeded offsets in powerline outline semicircle custom glyphs 2021-11-12 18:38:11 -08:00
Cédric Schieli
7d9615b4ba Better alignment for powerline outline semicircle custom glyphs 2021-11-12 18:38:11 -08:00
Cédric Schieli
dd832dcccf Improve powerline outline semicircle custom glyphs 2021-11-12 18:38:11 -08:00
Benoit de Chezelles
fa76a64504 Improve powerline filled semicircle custom glyphs 2021-11-12 18:38:11 -08:00
Wez Furlong
4225610c09 add config option to enable resize increments, disable by default
refs: #1254
refs: #1289
2021-11-09 08:30:58 -07:00
Wez Furlong
1ec7e10c19 fonts: ls-fonts now handles system fallback lists, adds Menlo on macos
It appears as though Menlo is the only font on macos to contain the
heavy ballot cross symbol, which is commonly used on macos (eg: in
`brew` output).

Our fallback list, despite starting with Menlo, didn't include menlo
itself in the candidates.

Furthermore, `ls-fonts` wouldn never see the result of the system
fallback resolution because it didn't know to try again, and was
using the list of handles from before the fallback.

This commit resolves all of these concerns.

refs: #849
2021-11-08 22:49:52 -07:00
Wez Furlong
b8ff61da5b ssh: allow wezterm ssh -v to log verbose diagnostics to stderr
Feels generally useful
2021-10-25 15:56:36 -07:00
Wez Furlong
c1a766404c config: add ssh_backend config, and default to libssh
refs: #1014
2021-10-21 07:16:42 -07:00
Wez Furlong
d461c1c0b6 deps: lru 0.6 -> 0.7 2021-10-10 19:29:42 -07:00
Wez Furlong
64271288ac gui: avoid false cache sharing in glyph cache, fix custom block advance
Since we may have two different sizes/namespaces of fonts between
the title font and the main terminal font, we need to be a bit more
careful to pass down distinguishing font information when caching
glyphs.

In addition, I noticed that the advance for custom block glyphs
(eg: powerline!) weren't right in the tab bar.  To resolve this,
when shaping, we skip using the glyph from the font and synthesize
a placeholder with the appropriate advance.
2021-10-09 13:38:15 -07:00
Wez Furlong
5a6317ebe4 gui: draw a hint of a dividing line on fancy tab edges 2021-10-09 08:34:47 -07:00
Wez Furlong
23a0d67589 make fancy tab bar corners more rounded 2021-10-09 08:12:11 -07:00
Wez Furlong
d54762bf4b gui: fixup status bar boundary math for new padding
We were truncating the right-status text because we were passing
the padded number of cols for the tab bar, but since the tab bar
now exists outside the padding, that value was too small.
2021-10-09 07:32:56 -07:00
Wez Furlong
b576b31f0a gui: more refinements to fancy tab bar presentation 2021-10-08 08:29:17 -07:00
Wez Furlong
a20fe39e50 gui: tidy up fancy tab bar layout logic
Use more euclid types to clarify what goes where and make it easier
to change this code.
2021-10-08 07:32:46 -07:00
Wez Furlong
8c3477006f Allow using unit like "1cell" or "5%" for window_padding
This commit introduces the `Dimension` type which allows specifying
a value in a variety of units; pixels, points, cells, percent.

`Dimension` needs contextual information to be evaluated as pixel
values, which makes resolving the value from the config slightly
more of a chore.

However, this type allows more flexible configurations that scale
with the font size and display dpi.

refs: #1124, #291, #195
2021-10-07 19:26:22 -07:00
Wez Furlong
9b4f7e78d6 fonts: properly fixup emoji baseline
The previous commit was partially OK, but the main cause of
emoji being wonky was this bit of macos specific code that I
added ages ago.

Remove that hack and the portion of the code from the previous
commit that was working to undo it.

This should make the baselines consistent across all platforms.

refs: #1203
2021-10-06 19:40:30 -07:00
Wez Furlong
e25deaaed1 fonts: align emoji fonts with the primary font baseline
refs: #1203
2021-10-05 22:01:21 -07:00
Wez Furlong
4eef20320d search: auto-update when the pane content changes
refs: https://github.com/wez/wezterm/issues/1205
2021-10-05 20:17:45 -07:00
Wez Furlong
87ea33f2f8 partially revert ligature cursor fix
refs: #478
2021-10-05 19:46:36 -07:00
Wez Furlong
f3159b6689 gui: add rounded corners to fancy tab buttons 2021-10-05 09:12:13 -07:00
Wez Furlong
49d77138ae gui: refine text positioning math around fancy tab bar
Avoid accidentally scaling the tab bar when using IncreaseFontSize.

Use a "better" default title font based on the platform.

Avoid a gap between bottom of tab button and dividing line at
certain font sizes.
2021-10-04 23:13:21 -07:00
Wez Furlong
97ef6b71bd gui: add filled_rectangle helper function
This is used to allocate a quad that makes a simple rectangular
block of solid color.
2021-10-04 22:30:37 -07:00
Wez Furlong
f511f9f52e gui: fixup some alignment/layout math for tab bar
bottom placement had mismatched render and hit test locations.
Tweak how we generate per-tab info for fancy tab mode.
2021-10-04 17:35:54 -07:00
Wez Furlong
839fe2d8cc resolve false style/cache/shaper sharing in fancy tab bar 2021-10-04 17:35:54 -07:00
Wez Furlong
43bc96b521 re-use core render_line function in fancy renderer
There's some false cache sharing that needs to be resolved though.
2021-10-04 17:35:54 -07:00
Wez Furlong
b1509fa0d1 re-use main shaper helper for fancy tab text rendering 2021-10-04 17:35:54 -07:00
Wez Furlong
a5319d66bd fix an issue where a selection could bleed out of a pane
When split horizontally, selecting multiple lines at the top of the left
pane could paint a horizontal selection line all the way across the rest
of the terminal to the right hand edge.
2021-10-04 17:35:54 -07:00
Wez Furlong
3da775d0e5 gui: add use_pixel_positioning mode to render_screen_line_opengl
I've tested this with the regular tab bar to prove that it essentially
works; the intent is to use it with the fancy tab bar rendering.
2021-10-04 17:35:54 -07:00
Wez Furlong
d6149382a3 gui: refactor Line shaping 2021-10-04 17:35:54 -07:00
Wez Furlong
a4956c1c05 gui: more refactoring of positioning math for cell/glyph rendering
Removes the dependency on knowing where the pane top/left position
is so that the line render routine could be used in more places.

Adjusts the tab bar and scroll bar positioning so that the tab bar
ignores window padding and is always flush with the top/bottom window
edge (full width as well), and that the scroll bar top/bottom respects
the tab bar position and height.
2021-10-04 17:35:54 -07:00
Wez Furlong
efa437b16d gui: factor y pixel coordinate out of render_screen_line_opengl
Instead, pass in the y pixel value that it should use to calculate
the position.
2021-10-04 17:35:54 -07:00
Wez Furlong
fae5435824 fix incorrect fg color when cursoring over ligatured glyph
More of a "fix"; we use some heuristics based on the bearing
and glyph width to figure out if a sequence looks like a funky
ligature that moves left to render the glyph.

This may be prone to false positives, but the consequences are low:
when we think a glyph is part of a ligature, then rather than using
the cursor_fg color (which is typically black, or close to invisible),
we retain the normal text fg color.

This way the portion of the glyph outside of the cursor retains its
foreground color, and just the cell containing the cursor may have
a slightly funky fg color in the case where the heuristic was bad.

closes: #478
2021-10-04 17:35:54 -07:00
Wez Furlong
904d2a948d tidy up milli uptime for blinking text 2021-10-04 17:35:54 -07:00
Wez Furlong
b4255c3b86 Refactor shaping helper 2021-10-04 17:35:54 -07:00
Wez Furlong
962e44bbfb WIP: fancier tab bar
`use_fancy_tab_bar` switches to an alternate rendering of the tab
bar that uses the window_frame config to get a proportional
title font to use to render tabs, as well as rendering a few
additional elements to space out and make the tabs feel more
like tabs.

Computing the number of tabs doesn't respect the alternate font
at this time.

Formatted tab item foreground and background colors are also
not respected at this time.

refs: #1180
2021-10-04 17:35:54 -07:00
Wez Furlong
8652f2e7d3 gui: factor tab bar drawing into own method 2021-10-04 17:35:54 -07:00
Wez Furlong
da30ecd5b3 tab bar: use UIItem for hit testing 2021-10-04 17:35:54 -07:00
Wez Furlong
401719fb01 fonts: improve cap-height and use_cap_height_to_scale_fallback_fonts
We now compute the cap-height from the rasterized glyph data.

Moved the scaling action of use_cap_height_to_scale_fallback_fonts from
glyphcache into the font resolver: when enabled, and we have data
about the baseline font and the font being resolved, then the resolving
font will be scaled such that the cap-height of both fonts has the same
pixel size.

The effect of this is that `I` glyphs from both fonts should appear to
have the same height.

Added a row of `I`'s in differing styles at the bottom of styles.txt
to make this easier to visualize.

refs: #1189
2021-10-02 18:23:51 -07:00
Wez Furlong
d3c748e18f fonts: enable matching against bitmap strike sizes
This is to handle situations such as some versions of the Terminus
bitmap font, where the individual bitmap strike sizes are broken
out across multiple individual files.

Font matching now passes down the nominal pixel height based on
the current DPI and font scale factor, and will use that to select
the font file that has the closest pixel size.

Previously, it would be potentially undefined which of the Terminus
font files would be selected.

refs: https://github.com/wez/wezterm/issues/1189
2021-10-02 09:33:55 -07:00
Wez Furlong
959da7f0bd also change cursor border color when visual bell target is cursor 2021-09-30 17:21:31 -07:00
Wez Furlong
ca89181098 bell: allow changing the cursor color when the bell is rung
I find this less distracting than both the audible and the default
background color flashing.
2021-09-29 08:02:34 -07:00
Wez Furlong
3566b82458 add wezterm connect --class option 2021-09-29 07:15:25 -07:00
Wez Furlong
72cb110b65 add audible_bell config option
This allows using the system beep sound, currently only on macos.

refs: #3
2021-09-26 12:55:19 -07:00
Wez Furlong
3b2f7b87ec gui: tweak visual bell for transparent and non-black backgrounds
refs: #3
2021-09-25 15:32:22 -07:00
Wez Furlong
0c1ad718d0 add visual bell
refs: #3
2021-09-25 12:40:22 -07:00
Wez Furlong
2337c06c0f gui: new bell event for running lua when the bell is rung
This commit adjusts the the window event routing/queuing so that
a queued event can capture a pane_id other than the focused pane.

Since we only allow one queued instance of a given named event in a
window, a consequence of this is that multiple bell events coming
from different panes at the same time may race and the loser's
event will be dropped. We log a warning in that case.

refs: #3
2021-09-23 08:22:01 -07:00
Wez Furlong
a2110fed6f gui: add mouse event logging
refs: #1140
2021-09-14 08:43:55 -07:00
Wez Furlong
8282faf31f window: allow specifying window resize increments on macos and x11
This commit introduces a mechanism for specifying resize increments
for a window, and then arranges for the termwindow to set those
to match the current font cell metrics.

This should help to avoid cases where there is excess padding pixels
resulting from the window being slightly larger than computed number
of cells and the font metrics.
2021-09-08 22:57:42 -07:00
Greg V
94ede1e8f1 window: implement window movement by dragging on Wayland 2021-09-08 17:45:48 -07:00
Greg V
ce5615082c gui: cancel mouse click streak when the cursor has moved to a different cell (fixes #910)
Fast-clicking users generally expect to be able to rapidly do regular selections
or otherwise cancel double/triple/quad clicks, so significant mouse movement should end the streak.

Allowing tiny pixel movements to account for touchpads is necessary.
Fortunately, the position here is already in character grid cells, which provides enough margin for this.
Other code editors like gedit also seem to do this based on the character grid.
2021-09-08 17:38:59 -07:00
Spyros Roum
bfaf46a196 Also accept shift + y/n when asking for confirmation to close panes 2021-09-08 09:33:08 -07:00
Wez Furlong
aa61a6b065 gui: force cursor to be visible in copy mode
It appears as though kakoune hides the terminal cursor and renders
its own version of the cursor.

The hidden state was being picked up by the copymode overlay,
making it awkward to use.

This commit forces the cursor to be visible (and a block) when
copy mode is active.

closes: #1113
2021-09-06 19:51:20 -07:00
Wez Furlong
41866a0b5b gui: capture new terminal size even if we haven't setup opengl
I think this is a hangover from the older logic to figure out
the initial sizing, and I suspect that it is what is causing
refs: 1074

So this is a speculative change to see if it helps!
2021-09-06 10:19:06 -07:00
Wez Furlong
93e18b2a01 deps: colorgrad -> 0.5 2021-09-05 23:27:01 -07:00
Wez Furlong
545a8fc8a7 deps: ordered-float -> 2.8 2021-09-05 23:25:37 -07:00
Wez Furlong
fea3a527dd Fixed invisible I-beam/underline cursor w/force_reverse_video_cursor
closes: https://github.com/wez/wezterm/issues/1076
2021-09-04 14:24:58 -07:00
Wez Furlong
4c8ccf8efc Add Multiple key assignment
refs: https://github.com/wez/wezterm/pull/1091
2021-09-04 13:01:34 -07:00
Wez Furlong
bc4ed3735d Add SendKey key assignment
refs: https://github.com/wez/wezterm/pull/1091
2021-09-03 12:07:17 -07:00
Wez Furlong
97831848cb gui: also log current size during a resize event
refs: #947
2021-09-02 09:18:32 -07:00
Wez Furlong
d38ba13211 render: 3 layers with dual source blending only for the glyph layer
This splits rendering into 3 passes:

* background pass for z-index < 0.  This is for solid background colors,
  background images, and image attachments with z-index < 0.
  Rendered with regular alpha blending.
* glyph pass: for glyphs at z-index==0. This is rendered with dual
  source blending enabled to facilitate subpixel aa appearance.
* top layer pass for z-index >= 0 graphics.  This is rendered with
  regular alpha blending.

This avoids weird effects, like images with alpha shining through
the back of the window when the window itself isn't transparent.

refs: #544
2021-08-24 08:53:33 -07:00
Wez Furlong
5629e0c1ca deps: tiny-skia -> 0.6 2021-08-23 07:48:13 -07:00
Wez Furlong
98206f0bf8 gui: take another pass at alpha/gamma stuff
The prior commit wasn't right, this looks better!

refs: #1049
2021-08-19 19:11:59 -07:00
Wez Furlong
66ff7740c4 gui: tweak alpha/color mask to avoid incorrect transparency
transparent images weren't always blending correctly, and were
instead shining through.

This might also have affected cursors.

It may also be a factor in a couple of recent reports of excessive
boldness which looked like funky over-alpha multiplication.

Let's see what people say about this.
2021-08-19 10:07:06 -07:00
Wez Furlong
c6e1889b04 remove unused alt alpha blending config
This doesn't make sense in a dual source blending world
2021-08-19 09:41:48 -07:00
Wez Furlong
571c137955 gui: gamma fixup
This makes the comparison in https://github.com/wez/wezterm/issues/544
work for me on mac, linux (x11, wayland) and also on Windows but
only using WGL.

It looks like we can use the proper colorspace on all targets
except for ANGLE EGL.  For whatever reason, the combination of
glium and ANGLE EGL on windows over-gamma corrects.

AFAICT, the framebuffer and perhaps the surfaces it creates
don't indicate srgb support, and whatever combination of status
they return tickles glium's srgb stuff the wrong way.

I think the "solution" is just to directly use WGL by default.

EGL was on by default because it tended to be more survivable
when graphics card drivers were updated, but the last couple
of times I updated mine it still killed wezterm anyway.

refs: #544
2021-08-19 09:17:09 -07:00
Wez Furlong
2013718336 gui: avoid divide by zero for glyphs that report num_cells=0
refs: https://github.com/wez/wezterm/issues/1042
2021-08-18 08:33:53 -07:00
Wez Furlong
769f632a26 gui: avoid making a transparent hole under the cursor 2021-08-16 08:32:49 -07:00
Wez Furlong
3e80854bc7 gui: apply hsv transform to background colors
refs: #1025
2021-08-16 08:07:22 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
e1ee1ddd97 gui: disable zone fetch in the renderer
We need a more scalable alternative to this before we can use
it in the renderer.
2021-08-15 15:58:51 -07:00
Wez Furlong
67e4516c03 gui: fix seqno for semantic zone cache 2021-08-15 13:42:09 -07:00
Wez Furlong
a7b20443ba gui: add more generic dragging concept, fixup scrollbar math
Add a more general dragging thingy and use that to know when we
are dragging splits or the scroll thumb.

Fixup scrollbar math, which didn't account for whether the tabbar
was shown and which might cause the scroll thumb to jump around
on first drag (resolves #568)
2021-08-15 13:41:38 -07:00
Wez Furlong
befdc7ac3a Fixed: text_background_opacity was not respected 2021-08-15 08:33:09 -07:00
Wez Furlong
ab8c8dc6c9 gui: add UIItem concept
The idea here is to make it a bit easier to do hit detection for UI
elements; today we've been duplicating position math between the render
and the mouse movement handlers, with both pieces of code knowing the
location of the UI element.

UIItem allows the render phase to record the position, which allows
the mouse phase to be a more independent lookup against the registered
elements.

This makes it easier to add more UI elements in the future.
2021-08-15 07:46:06 -07:00
Wez Furlong
0bbb8cc37c gui: add semantic zone cache 2021-08-14 21:43:53 -07:00
Wez Furlong
eabb84b974 gui: fix: respect dynamic color scheme backgrounds
Ensure that we respect the dynamic color scheme that is configured
in a given pane.
2021-08-14 12:12:27 -07:00
Wez Furlong
0a5a4cb642 cleanup: remove bg color from vertex
Now that we have dual-source blending, this is unused
2021-08-14 11:02:56 -07:00
Wez Furlong
615b5b3966 gui: support radial gradients 2021-08-13 17:38:33 -07:00
Wez Furlong
d9e0340a94 gui: add some randomness to gradients to avoid banding 2021-08-13 13:35:55 -07:00
Wez Furlong
746951416b gui: tidy up gradient calculation 2021-08-13 12:14:14 -07:00
Wez Furlong
d59898987a gui: fix lost sync with the cell position in the renderer
If a cell contained a ligature, the math used to track where the
next quad was going to be placed could lose consistency with
the cluster/shaping information and result in offset glyphs.

This was most noticeable to me in tab titles in the tab bar;
my shell dotfiles append `-- something` to the title when a
command is launched, and the `--` is a ligature in my font.

I think I've also seen this mess up positioning in the notcurses
demo as well.

The solution is to take the cluster initial cell index rather
than trying to reverse engineer it from incomplete info.
2021-08-13 09:34:36 -07:00
Wez Furlong
cbfb6d59c5 added new window_background_gradient config option 2021-08-12 23:08:38 -07:00
Wez Furlong
6f78ee4f14 deps: update unicode-segmentation to 1.8 2021-08-11 23:06:17 -07:00
Wez Furlong
0866e5d213 fonts/shaping: respect the Presentation selection for a cluster
This commit annotates fonts with a boolean that indicates whether
we think it contains glyphs with emoji presentation, and then
passes the cluster.presentation field down to the shaper.

If the presentation doesn't match the current font in the fallback,
then it will be skipped until we exhaust its options.

`wezterm ls-fonts` also shows whether we think a font has emoji
presentation.

refs: #997
2021-08-11 09:11:59 -07:00
Wez Furlong
ee71d478c4 window+gui: enable dual source blending
This replaces the slightly gnarly subpixel enabled blending in the
shader with Dual Source Blending, which is a technique where the
fragment shader can specify both the primary color (RGBA) as well
as an additional per-channel mask that can be used to alpha blend
with the destination.

This enables artifact-free alpha blending when used together
with a transparent window background.

refs: https://github.com/wez/wezterm/issues/932
2021-08-10 18:23:18 -07:00
Wez Furlong
89f9512cc1 gui: use solid color block for background color quads
like 2facc465ef but for
cells with a background color
2021-08-09 08:48:20 -07:00
Wez Furlong
2facc465ef gui: avoid sampling solid background color
eg: white could have a greyish border from where the texture sampling
was picking up the transparent padding in the texture atlas.
2021-08-09 08:19:27 -07:00
Wez Furlong
827adf3a95 gui: try to gracefully handle both resize and scaling changes
refs: #695
2021-08-08 14:43:41 -07:00
Wez Furlong
eae327efcc model: replace LineBits::DIRTY with a sequence number
Terminal now maintains a sequence number that increments
for each Action that is applied to it.

Changes to lines are tagged with the current sequence number.

This makes it a bit easier to reason about when an individual
line has changed relative to some point in "time"; the consumer
of the terminal can sample the current sequence number and then
can later determine which lines have changed since that point
in time.

refs: https://github.com/wez/wezterm/issues/867
2021-08-08 12:45:08 -07:00
Wez Furlong
9617c742cf gui: try harder to deal with tiling wm resizing + dpi changes
refs: #695
2021-08-07 22:32:52 -07:00
Wez Furlong
5a9bd14d89 gui: fix newlines in copied text
Use the newer logical line method in pane rather than going
via the hyperlink function, so that we can better reason
about physical vs. logical line breaks, and get the results
very slightly faster too.

refs: #874
2021-08-07 19:16:29 -07:00
Wez Furlong
6d9957e6e3 term, gui: allow tracking multiple buttons
We were previously only remembering the most recently pressed
button, but that's a lossy thing to do.

This commit remembers the button presses so that we can correctly
report all press/release events.

refs: #973
2021-08-07 18:37:38 -07:00
Wez Furlong
1344b243d8 gui: allow dispatching resize events during creation
I think this is the heart of the initial size issues:
during creation, if the dpi or size is different, we generate
a resize event, but because it is dispatched before we've
assigned self.window, we weren't able to resize the window
to fit.

This commit passes the Window object down to the resize
handler so that it can do that; the diff is conceptually
small but there is corresponding fanout around ensuring
that the Window is passed down through all the resize
related codepaths that need it.

refs: #1002
refs: #695
2021-08-07 10:07:32 -07:00
Wez Furlong
e143db2b7f gui: tidy up initial resize/scale adjustment
It seems like this is making things worse on X11/Wayland.
Let's try simply skipping it--that seems fine on X11/Wayland,
but needs to be verified on macOS and Windows.

refs: #1002
refs: #695
2021-08-07 09:45:33 -07:00
Wez Furlong
308f3a8d74 window: avoid resizing on startup if the size doesn't appear different
The intent is to avoid weirdness with Wayland where we need to wait for
a configure event before we try to set the window size programmatically.

refs: #1002
2021-08-06 19:37:08 -07:00
Wez Furlong
79165617b1 window: add WindowState concept
WindowState is a bitfield that can represent maximized, full screen
and hidden window states.

WindowState is passed along with resize events, improving on the
prior basic is_full_screen boolean by representing the other states.

Notably, WindowState::MAXIMIZED is used to represent a state where
the window's size is constrained by some window environment function;
it could be due to the window being maximized in either or both the
vertical or horizontal directions, or by the window being in a tiled
state on any edge.

When the window is MAXIMIZED, wezterm will behave as though
`adjust_window_size_when_changing_font_size = false` because it knows
that it cannot adjust the window size in that state.

This potentially helps with #695, depending on whether the window
manager propagates this state information to wezterm.  Gnome/mutter
does a good job at this with both X11 and Wayland, but I couldn't get
sway to report these states and I don't know of any other tiling wm
that I can easily install and use on fedora, so there's a question
mark around that.
2021-08-06 18:56:37 -07:00
Wez Furlong
0158e8e49a gui: fixup window transparency 2021-08-06 13:07:50 -07:00
Wez Furlong
40bb5ddb97 gui: maybe fix weird bg color issue on Intel macs
This commit changes the full surface fill to be fully transparent,
and adds a separate quad to fill with the configured window background
color.

The thesis is that this should avoid the apparent weird rgb/srgb
mismatch that seems to occur with the window background on Intel macs
(those have a different OpenGL implementation than M1 based macs which
don't appear to have this issue).

refs: https://github.com/wez/wezterm/issues/1000
refs: https://github.com/wez/wezterm/issues/653
2021-08-06 09:51:57 -07:00
Wez Furlong
b883627ba1 gui: work harder to preserve initial terminal size
I noticed that on macos, the initial terminal size didn't
match the 80x24 default; it was a few columns short.

I think I broke this with recent changes in window
event dispatching.

This commit passes the terminal size down to apply_dimensions
just after we've set up the GL context to preserve the
terminal size.

Possibly related to https://github.com/wez/wezterm/issues/1002
2021-08-06 09:26:29 -07:00
Wez Furlong
aac4d36d6e gui: make a separate quad allocation pass for image cells
This should help to avoid artifacts in the case where glyphs
render outside their nominal terminal cell (happens when the
shaper tweaks positioning, and/or when ligatures are involved).

Previously we'd render the layers in z-index order for cell N
before the layers in z-index order for cell N+1.

If N had an image that overlayed the text (nominally z-index 0.5!)
and the glyph in N+1 (z-index 0) was slightly to the left of its
border, then it could layer incorrectly over the cell to the left.
2021-08-06 08:57:19 -07:00
Wez Furlong
3ea13fb530 kitty img: tidy up blit and bounds check, skip 0 duration root frame 2021-08-05 23:59:35 -07:00
Wez Furlong
c10288bd25 improve rgbcolor_alpha_to_window_color fidelity
The underlying types in termwiz support 10-bit color, but in our
conversion to the data we pass to the vertex, we were forcing it
into 8-bit and then converting to float.

Simplify this by skipping the intermediate 8-bit representation
and just go directly to float.
2021-08-05 20:37:33 -07:00
Wez Furlong
64fc58583e Tidy up outputs_srgb option
It's always on; simplify the code and just set it in the constructor
directly without passing it down from the caller.
2021-08-05 20:33:56 -07:00
Wez Furlong
17fc41fc52 add option to select alternative alpha blending
I'm not sure if this is needed now that we have a single draw call, but
based on the history and the nuance of different gl/driver/os quirks it
feels like a good idea to keep this option in the back pocket.
2021-08-04 15:26:48 -07:00
Wez Furlong
b6c6cef876 refactor: move cursor sprite generation to be dynamic
This allocates cursor sprites as needed, and uses the Poly drawing
code from the customglyph module to do it.
2021-08-04 10:01:21 -07:00
Wez Furlong
4e1f933e00 add some more eighth custom glyphs 2021-08-04 00:20:56 -07:00
Wez Furlong
524f9ddd40 render double-wide cursor for double-wide cells 2021-08-03 12:27:24 -07:00
Wez Furlong
07bea8c269 gui: change image frame caching scheme to use frame hash
Since we can now mutate individual frames, we need to avoid
falsely caching across a change; switch from using (image_id, frame_idx)
to frame_hash.

refs: #986
2021-08-03 08:42:39 -07:00
Wez Furlong
29a64e10b8 allow locking ImageData's ImageDataType for mutation
refs: #986
2021-08-02 21:35:57 -07:00
Wez Furlong
90b16b9518 move image decoding into termwiz
Adds a use_image feature to termwiz that enables an optional
dep on the image crate.  This in turn allows decoding of animation
formats (gif, apng) from file data, but more crucially, allows
modeling animation frames at the termwiz layer, which is a pre-req
for enabling kitty img protocol animation support.

refs: #986
2021-08-02 21:35:50 -07:00
Wez Furlong
76681c9879 refactor: split custom glyph code into its own file 2021-08-01 22:06:04 -07:00
Wez Furlong
86bf251f3f add some more metrics around get_lines_with_hyperlinks_applied + others 2021-08-01 14:50:50 -07:00
Wez Furlong
887152a13d Improve UX when we run out of texture space
Rather than leaving the frame un-rendered, this commit arranges
to make one last pass but with all image quad assignments skipped.

This should at least make a reasonable effort at displaying text
on the screen.

refs: https://github.com/wez/wezterm/issues/879
2021-08-01 11:29:50 -07:00
Wez Furlong
94d409d340 prefer to hold rgba8 rather than png data for kitty, sixel
I noticed when running the notcurses demo that we're spending a
decent amount of time decoding png data whenever we need to
re-do the texture atlas.

Let's avoid that by allowing for ImageData at the termwiz layer
to represent both the image file format and decoded rgba8 data.

This commit is a bit muddy and also includes some stuff to try
to delete placements from the model.  It's not perfect by any
means--more expensive than I want, and there's something funky
that causes a large number of images to build up during some
phases of the demo.

refs: #986
2021-08-01 11:29:50 -07:00
Wez Furlong
503d3df368 Constrain texture size to that supported by gpu
OpenGL will silently let us allocate a texture larger than the GPU can
bind to a sampler, reporting the error status out of band and leaving
the display in a perma-broken state.

This commit deliberately checks against the max texture size and raises
an error in that case.

The recovery story isn't perfect, but at least the texture remains
usable, so the user can clear the screen and still be able to see glyphs
afterwards.

refs: https://github.com/wez/wezterm/issues/879
2021-08-01 10:42:57 -07:00
Wez Furlong
09220adb07 simplify rendering pane splits
Just use a single quad for a given split

refs: #986
2021-07-31 20:34:36 -07:00
Wez Furlong
bbe019db96 implement kitty image source and offset options for placement
Allows selecting a source "sprite" from the image data, and offsetting
its position within the cell.

refs: #986
2021-07-31 14:03:27 -07:00
Wez Furlong
54f435b904 Restore bg_color to the vertex
Until we have dual source blending, we need the background color
in order to have a more visually pleasing alpha blend.

refs: #986
refs: #932
2021-07-31 10:44:27 -07:00
Wez Furlong
e165cdf210 Consolidate shader logic
Now that we have a single pass, we don't need to "include" snippets,
and that makes the shaders a lot easier to follow.

refs: #986
2021-07-31 07:34:14 -07:00
Wez Furlong
725572de9c reduce to a single draw call
Taking further advantage of dynamic quad allocation, we can now
remove the multiple render passes in favor of allocating the quads
and painting them from back to front.

In turn, this means that we can reduce the amount of data that we
store in the vertex, which simplifies the shaders a bit, at the
expense of making the render code in rust a bit more complex.

However, we can take advantage of stretching runs of cells with
background colors in to a single quad.

refs: #986
2021-07-31 00:23:16 -07:00
Wez Furlong
9a8b2e1e81 fix log level when loading background image 2021-07-30 20:06:41 -07:00
Wez Furlong
175ca9f722 remove draw pass 4
This was added in 365a68dfb8 to free the
orca from its cage.  With the recent dynamic quad allocation changes, we
don't need a distinct 4th pass any more and can simply layer a separate
quad on top of the glyph quad.

refs: #986
2021-07-30 19:23:02 -07:00
Wez Furlong
89586d658e dynamically allocate quads as needed
This removes the pre-allocated (at resize) number of quads
and replaces it with a dynamic mechanism that tracks how many
quads are needed for a frame and then will re-allocate and
re-render when there weren't enough.

We start with 1024 quads and try to allocate in multiples
of 1024 quads.

refs: #986
2021-07-30 16:59:47 -07:00
Wez Furlong
6a84f051b6 Make quad allocation more dynamic
This commit removes the `Quads` struct which maintained pre-defined quad
indices for each of the cells, the background image and scrollbar thumb.

In its place, we now "dynamically" hand out quads to meet the needs of
what is being rendered.  There are some efficiency gains here with
things like the selection (which can now be a single stretched quad,
rather than `n` quads in width).

This isn't a fully dynamic allocation scheme, as we still allocate the
current worst case number of quads when resizing.

A following commit will adjust that so that we allocate a ballpark and
then employ a mechanism similar to OutOfTextureSpace to grow and retry a
render pass when we need more quads.

Futhermore, this dynamic approach may allow reducing the amount of stuff
we have in the Vertex and "simply" render some quads before others so
that we don't have to have so many draw() passes to build up the
complete scene.

refs: #986
2021-07-30 12:59:15 -07:00
Wez Furlong
72d368440f move some of the vertex buffer state into TripleVertexBuffer
This is a stepping stone towards dynamically allocating
vertices.

refs: #986
2021-07-29 22:21:46 -07:00
Wez Furlong
71e88a4fea conceptually allow for multiple image attachments in a cell
refs: #986
2021-07-29 19:41:52 -07:00
Wez Furlong
7b0b042683 termwiz: parse and encode kitty image protocol
This teaches termwiz to recognize and encode the APC
sequences used by the kitty image protocol.

This doesn't include support for animations, just the
transmit, placement and delete requests.

refs: #986
2021-07-28 09:04:37 -07:00
Wez Furlong
a1f55049c5 deps: upgrade open 1.4 -> 2.0
The main difference is that it can now use `wslview` to open things
across wsl boundaries.

closes: #982
2021-07-26 08:15:02 -07:00
Wez Furlong
7192fe7696 respect reverse video attributes for inferred cells
In the case where the cells vec is shorter than the line width,
we need to ensure that we render the inverse video background
color if that mode is in effect.

refs: #133
2021-07-25 08:11:49 -07:00
Wez Furlong
51cc72e299 Schedule blink invalidations
Also fixes an issue where only the first frame schedule would
take effect!  Surprised this didn't bubble up as a bug with
animated gifs already.

refs: #133
2021-07-25 08:11:00 -07:00
Autumn Lamonte
e3f1d15f5d #133 unit tests 2021-07-24 23:43:30 -07:00
Autumn Lamonte
70544b7b26 #133 cleanup, rapid blinking text 2021-07-24 23:35:06 -07:00
Autumn Lamonte
d8cacee28a #133 blinking text 50% 2021-07-24 23:29:31 -07:00
Autumn Lamonte
d3b0881ded #133 Tab stops, reverse video. 2021-07-24 23:07:20 -07:00
Wez Furlong
6ddc8afc64 termwiz: recognize the XTGETTCAP DCS sequence
Parse and respond to this sequence docs can be found
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Device-Control-functions:DCS-plus-q-Pt-ST.F95

refs: https://github.com/wez/wezterm/issues/954
2021-07-24 21:06:48 -07:00
Wez Furlong
dcbbda7702 allow images to overlay text
This commit introduces a 4th draw pass for rendering sixel and
iterm images that are attached to cells.

Previously, a cell could container either text or an image from
the perspective of the renderer.  If it had an image then the glyph
bitmap would be ignored in favor of the image.

However, that causes sixel behavior to diverge from other terminals
(https://github.com/wez/wezterm/issues/942) so we need to be render
both of these.

The simplest way to achieve this is to add a distinct set of texture
coordinates for the attached image and then add a draw pass to alpha
blend it over the glyph content.

The sixel/iterm image processing stage is also adjusted to preserve
the prior cell information and "simply" attach the image info to
the cell.  Previously, the cell would be replaced with a blank cell
with the image attached.

The result of this is that the notcurses-demo intro section can
now render the orca "enveloped in the soft glow of glyphs" rather
than caged in a black box.

Note that there are some cases where the render turns blocky but
I suspect that that is due to some other misunderstanding between
wezterm and notcurses and that we'll root cause it as a follow up.
2021-07-22 09:46:08 -07:00
Wez Furlong
5434a2a581 wezterm-gui: fix over-invalidation when hovering hyperlinks
refs: #964
2021-07-21 08:58:35 -07:00
Cédric Schieli
77261ac374 Allow styling of the whole new tab button 2021-07-18 19:11:12 -07:00
Wez Furlong
a2e882a7cb deps: cargo update, and a couple of dependabot suggestions 2021-07-18 19:10:46 -07:00
Wez Furlong
7cd3dcaee4 tidy up cwd vs. home dir on Windows
Looking at #900; the unconditional directory change on startup
is "bad" because it only happens on Windows.

This commit removes it and instead puts the logic into the pty
layer to match the unix behavior.

The behavior is:

* If the command specifies the cwd, use that.
* Otherwise, use the home directory
2021-07-18 14:57:33 -07:00
Wez Furlong
a697b30223 window: add xsettings support on X11 systems
This allows reading xsettings which contain information about
both the active theme as well as the DPI.

refs: #947
2021-07-18 12:54:52 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00
Wez Furlong
75eaaab6a1 Allow window config overrides to apply per-pane
This allows window-level config overrides to apply
to panes contained within the window.

For instance, this allows setting a window-level
color scheme.
2021-07-17 23:02:41 -07:00
Wez Furlong
37888657bf fix rendering issue in close confirmation dialog
Mentioned in #898, the hover effect didn't match mouse movement.
This was just a rendering issue in the confirmation overlay.
2021-07-17 09:13:48 -07:00
Wez Furlong
020c0991e4 cleanup: remove term::Clipboard::get_contents method
This dates back to long ago, and is never called.
Remove it, and cleanup some state associated with it.
2021-07-17 07:38:48 -07:00
Wez Furlong
fcd5512709 fix misclassification of mouse events
While looking at https://github.com/wez/wezterm/issues/945 I noticed
that mouse moves were being considered to be drag events even though
no mouse buttons were held down.
2021-07-15 22:25:35 -07:00
Wez Furlong
ac5199c216 config: add bypass_mouse_reporting_modifiers option
This allows changing eg: SHIFT to ALT for bypassing mouse reporting.

refs: https://github.com/wez/wezterm/issues/911
2021-07-11 22:02:23 -07:00
Wez Furlong
be680955d7 scroll to bottom on paste
closes: https://github.com/wez/wezterm/issues/931
2021-07-10 22:04:43 -07:00
Wez Furlong
6aa575d838 fixup build on macos 2021-07-10 17:42:05 -07:00
Wez Furlong
db6da81272 window: move away from async event queue
I added this originally thinking that it would make it easier to resolve
https://github.com/wez/wezterm/issues/695 and to integrate wgpu support,
but it's the cause of https://github.com/wez/wezterm/issues/922 so let's
take it out and more directly connect the window events to those in the
terminal.

This commit likely breaks mac and windows; pushing it so that I can
check it out and verify on those systems.
2021-07-10 17:30:19 -07:00
Wez Furlong
47839adf95 CellAttribute: move fg/bg color accesses to accesors
This facilitates hiding the raw fields in the next diff
2021-07-10 15:15:36 -07:00
Wez Furlong
9c77d56026 RgbColor: hide internal red, green, blue fields
I'd like to adjust this to support 10bpc color, so the first step
is hiding the individual 8bpc fields.
2021-07-10 14:22:31 -07:00
Wez Furlong
313d130deb remove cluster from GlyphPosition
This simplifies the code and avoids a call to reverse the
cluster to the cell index.
2021-07-09 22:46:16 -07:00
Wez Furlong
2ed3cbe313 add per-line render latency histogram 2021-07-08 09:58:48 -07:00
Wez Furlong
7287447f33 refactor: hoist some params to higher render level
and pass down via params struct
2021-07-08 09:51:11 -07:00
Benoit de Chezelles
71ff0441c4 Rename cell_* to dot_area_* for clarity 2021-07-08 09:30:27 -07:00
Benoit de Chezelles
313365771d micro-opti: Pre-calculate bit masks for braille dots pattern 2021-07-08 09:30:27 -07:00
Benoit de Chezelles
249f9dfe29 Use squares instead of circles for braille dots (for simplicity & perf) 2021-07-08 09:30:27 -07:00
Benoit de Chezelles
d48cf4e5ee Few micro-optimizations for performance 2021-07-08 09:30:27 -07:00
Benoit de Chezelles
831f3a8b51 Make the braille dots smaller (and the code clearer!) 2021-07-08 09:30:27 -07:00