1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00
Commit Graph

981 Commits

Author SHA1 Message Date
Wez Furlong
17b2c49c68 rearrange more mouse event code 2020-01-05 14:37:17 -08:00
Wez Furlong
48d971c106 pull click counting code up from terminalstate 2020-01-05 14:37:17 -08:00
Wez Furlong
f1089e84bf Middle button always pastes if shift is held 2020-01-05 14:37:17 -08:00
Wez Furlong
fa9f699d46 rearrange mouse coordinate math
Move it up so that we can reference it in a later diff
2020-01-05 14:37:17 -08:00
Wez Furlong
a8bf11a825 add Selection types to the gui layer
These are still unused

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
4912e83f3e StableCursorPosition to track the cursor
This fixes up the cursor position when scrolling.

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
12b537d2c8 serde_derive -> serde with derive feature 2020-01-05 14:37:17 -08:00
Wez Furlong
1c716898e7 Remove viewport_offset from RenderableDimensions
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
ef072255dd Process shift+pageup/down at the gui layer
Refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
6183434bda Track viewport in the gui layer
Use StableRowIndex to implement tracking the viewport in the gui layer.
This resolves an issue where a busy terminal would continue to scroll
through the scrollback when you were paging backwards and look weird.

There's still some cleanup though:

- This breaks the selection ui
- the cursor position is wrong when scrolling back
- shift-pageup/pagedown need to be processed in the gui layer

Refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
39dc6516df simplify key_event logic a little
Early return and remove some explicit return statements
2020-01-05 14:37:17 -08:00
Wez Furlong
e8d46442ac move mouse wheel scroll handling to gui layer
It's not really moved, but rather duplicated there; we still have
fallback logic in terminalstate.rs that processes the equivalent
action, but adding the logic to the gui layer means that we can
process it in terms of the Tab and Renderable interfaces.

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
bafa36b8ca simplify middle mouse button paste logic
Now that we can tell whether the mouse is grabbed, we can safely
process the paste in the same way that we use for keyboard initiated
pasting.
2020-01-05 14:37:17 -08:00
Wez Furlong
5f5113ce50 Renderable: fold get_scrollbar_info into get_dimensions 2020-01-05 14:37:17 -08:00
Wez Furlong
5ba0c70cdb add Tab::is_mouse_grabbed concept
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
f1846ab0ae add Renderable::get_lines
This allows retrieving arbitrary lines from the scrollback

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
56c170240f Renderable: replace a 2-tuple with an expanded struct
This cleans up the API a little as part of
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
8d3e513ed8 Ensure that the scroll thumb is well defined when disabled
When the scrollbar is disabled we still create a quad for it, and that
quad stretches to the window height.  It is left with undefined texture
and could be either partially or totally transparent and lead to weird
effects like it appearing as though the titlebar was too wide for the
window, or by dimming the RHS of the window when toggling the scroll
bar on and off a few times.

This commit ensures that we set a well defined size and color when
the scroll bar is disabled, and seems to improve things for me.

Refs: https://github.com/wez/wezterm/issues/103
2020-01-02 11:20:42 -08:00
Wez Furlong
364fc147be Instant::elapsed() 2019-12-31 15:56:41 -08:00
Wez Furlong
253c36bf8c use duration_since per @jsgf 2019-12-31 15:38:57 -08:00
Wez Furlong
6b78d1ad27 Implement tab movement via key assignment
This commit adds the ability to change the relative or absolute
position of a tab within its containing window through the
use of a key assignment.

We include a default assignment of CTRL+SHIFT+PageUp for moving
left and CTRL+SHIFT+PageDown for moving right.

Closes: https://github.com/wez/wezterm/issues/84
2019-12-31 15:31:50 -08:00
Wez Furlong
cc27f3f902 Only highlight cells that use exactly the highlight URL
If the cells refer to the same object instance (rather than equivalent
instances), then we treat them as part of the same highlight.

Refs: https://github.com/wez/wezterm/issues/94
2019-12-31 14:35:36 -08:00
Wez Furlong
699d092a6b Ignore mouse clicks that coincide with window focusing
Now that we can track focus changes, we can eliminate an annoyance:
clicking in the window to focus it would cause a click event to
be passed to the terminal and clear the selection.

This commit will swallow button events that occur within 200ms
of the focus being gained by the window.
2019-12-31 14:11:09 -08:00
Wez Furlong
5540b2e66b Don't default to swapped backspace and delete on macos
With the changes in Refs: https://github.com/wez/wezterm/issues/88
we don't need to swap them by default on macos any more.
2019-12-30 10:33:52 -08:00
Jeremy Fitzhardinge
887991f464 Remove BlockOutline cursor style
Not really needed, since its something we can handle at rendering time.
2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
999ba79436 Use non-focused cursor shape for unfocused windows 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
a499eedb86 Make sure cursor gets refreshed properly on focus change 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
6d5fbf93ff Define outline cursor for unfocused use 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
0bc0972f75 Track focus state and disable cursor blinking when not focused
Issue https://github.com/wez/wezterm/issues/93
2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
962b74c458 Only blink cursor when it's not moving
The cursor should only start blinking when its been sitting in once place;
a moving cursor should always be visible. Rather than making the cursor blink
relative to the creation time of the window, track its position, and use the
last time it moved as the blinking timebase.

Fixes https://github.com/wez/wezterm/issues/83
2019-12-29 09:38:59 -08:00
Wez Furlong
5d55b8bc2e Ensure that the scrollbar defines more vertex fields
This is a bit of a speculative change to see if it helps with
refs: https://github.com/wez/wezterm/issues/82

I have sometimes seen my scrollbar have a color that I didn't
choose and ISTR having some issues in the past when updating
the quads if I didn't set all of the fields of the vertex
to a better defined value.
2019-12-28 12:15:48 -08:00
Wez Furlong
afc96688ae Use $WEZTERM_CONFIG_FILE for config path if set
This makes it easier for me to test other configurations when
troubleshooting issues!
2019-12-28 11:30:32 -08:00
Wez Furlong
fa7a007a9f Don't hang when using middle mouse button to paste
A while back I moved the clipboard related processing mostly out
of the term processing code, but since I mostly use the keyboard
for pasting, I'd overlooked the middle mouse button paste flow.

This is problematic because fetching the clipboard requires a
degree of inter process communication and needs the event loop
to be pumped.  Since the terminal callbacks are dispatched from
an event loop callback, attempting to block on the clipboard
future causes a deadlock.

This commit resolves that issue by anticipating that we'll need
the clipboard contents for the majority of middle mouse button
clicks and scheduling a fetch and cache ahead of passing that
event down to the terminal layer.

Why don't we simply use the same technique as the Paste key
assignment?  If the terminal is currently using SGR mouse
tracking mode then the application on the other end of the
pty will want the raw button press.   Our layering doesn't
allow for passing up the concept of whether a middle button
does paste or sends the raw event.

tricksy!

Refs: https://github.com/wez/wezterm/issues/87
2019-12-28 09:15:24 -08:00
Wez Furlong
c8cd600706 wayland: fix unintentional blend with other windows
@jsgf mentioned this to me, and since I've started running "proper"
wayland gnome-shell/mutter on my pixelbook go, I'm seeing it too.

The issue is that the alpha values are potentially <1.0 when they
are committed to the frame buffer and the mutter compositor is
faithfully blending wezterm with the window behind it, leading to
weird looking effects such as varying brightness of text, or for
cases where the window behind wezterm is bright white, a halo
effect that makes the text less sharp.

This commit addresses this issue by asking glium to ask opengl to
set the destination alpha to 1.0 in the final draw stage.
2019-12-27 19:12:19 -08:00
Wez Furlong
de3ffb3428 fix min underline height
I noticed this for small enough sizes of Fira Code the border width
for the cursor would round to zero, and then looking at eg: `man ls`,
the underlined portions had no underline.

Ensure that the underline size is at least 1 pixel.
2019-12-27 12:03:45 -08:00
Wez Furlong
0a6e3fda30 move scrollbar bits to their own module 2019-12-27 11:37:45 -08:00
Wez Furlong
ba2caa815d Allow omitting window_padding fields
Closes: https://github.com/wez/wezterm/issues/85
2019-12-27 09:58:51 -08:00
Wez Furlong
11b79827de Add script that can produce a full source tarball
Full means "including git submodules" and makes it easier for folks to
download and build a release without sucking down large repos from
various locations, especially for folks with bandwidth constraints.

Upload the source tarball to the associated release.

Refs: https://github.com/wez/wezterm/issues/81
Refs: https://github.com/wez/wezterm/pull/46
Refs: https://github.com/wez/wezterm/pull/48
2019-12-24 09:41:15 -08:00
Wez Furlong
fc6d80af0e opengl: make it easier to track quads
The offset math around the scroll thumb made me uncomfortable
so this commit introduces a struct to keep track of the vertex
indices and make it easier to recall them later.
2019-12-23 19:20:07 -08:00
Wez Furlong
66b0cf24d1 scrollbar: set a min height for the scroll thumb 2019-12-23 15:14:38 -08:00
Wez Furlong
aac93e7f0a Improve palette handling w/ live config reloading
@fanzeyi ran into part of this issue when using multiplexing;
tabs from a remote domain always used the default color scheme
rather than the local configuration file color scheme.

Another variation on this is that making changes to the `[colors]`
section of the config only impacts tabs created after the change
was loaded, rather than updating the running tabs.

The root of this was that each terminal was keeping its own
copy of the palette that was updated at creation time to reflect
the config file.  Relatively recently I introduced a new trait
to allow the terminal state to reach out and obtain configuration
from another source.

This commit connects the terminal configuration layer to the
configuration file directly.

The color schemes are now pulled directly from the configuration
file, except in the case where a dynamic color scheme has been
applied: using escape sequences to change the colors causes
the palette to be forked away from the configuration file.

There's still a low pri TODO around this space: if we're connected
to a remote domain and someone uses dynamic color scheme escapes,
should we reflect those locally?  If so then we'll need to build
some plumbing to transport the palette to/from the remote system.

Closes: https://github.com/wez/wezterm/pull/60
2019-12-23 14:19:48 -08:00
Wez Furlong
1ff76e1c3c fix scrollbar rendering on X11 + opengl
Needed to also set the foreground otherwise it appeared invisible
on that particular system!
2019-12-23 08:08:30 -08:00
Wez Furlong
f28d9e994f Enable mouse interaction with scroll bar
This commit:

* Removes the ability to drag the window by the tab bar.  I added
  that in anticipation of needing to do custom title bar dragging
  with Wayland, but it turned out both to be not required and not
  possible to drag windows around in that way.
* Replaces the drag logic with dragging the scrollbar thumb
* Clicking above the scrollbar thumb is equivalent to page up
* Clicking below the scrollbar thumb is equivalent to page down
2019-12-22 22:01:00 -08:00
Wez Furlong
ec609a2e41 Add optional scroll position UI
This commit adds a scrollbar that shows the scroll position but
that does not currently allow dragging to scroll.

The scrollbar occupies the right hand side window padding.

The width of the scrollbar can be set by explicitly configuring
`window_padding.right`.  If the right padding is set to 0 (which
is its default value), and the scroll bar is enabled then the cell
width will be used for the right padding value instead.

The scrollbar can be enabled/disabled via this config setting:

```
enable_scroll_bar = true
```

Its color by this:

```
[colors]
scrollbar_thumb = "#444444"
```

(Note that color palette config will be reloaded when the config
file is changed, but you'll need to spawn a new tab/window to
see the effects because we cannot assume that a config reload should
always replace a potentially dynamically adjusted color scheme in
a tab).
2019-12-22 20:12:56 -08:00
Wez Furlong
c961f934f2 renderer now renders different cursor styles
refs: https://github.com/wez/wezterm/issues/7
2019-12-22 13:08:57 -08:00
Wez Furlong
5471729b07 add some cursor util sprites
Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 11:34:08 -08:00
Wez Furlong
3be4c9c0d7 allow specifying the default cursor shape
Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 10:23:34 -08:00
Wez Furlong
8135ce46a5 Blink the cursor when it is set to blink
The blink rate is configurable via a new option.

Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 10:08:31 -08:00
Wez Furlong
5abc4e543e rendering now respects cursor visibility
This commit adds some plumbing for describing the cursor shape
(block, line, blinking etc) and visibility, and feeds that through
the mux and render layers.

The renderer now knows to omit the cursor when it is not visible.
2019-12-22 08:52:51 -08:00
Wez Furlong
ce45a0ee01 fixup IME/cursor positioning for padding changes 2019-12-22 08:21:36 -08:00