1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

docs: add window:current_event() and add scroll events to mouse docs

This commit is contained in:
Funami580 2022-07-29 19:30:54 +02:00 committed by Wez Furlong
parent cf423dc614
commit 9346a07d84
3 changed files with 58 additions and 0 deletions

View File

@ -18,6 +18,7 @@ As features stabilize some brief notes about them will accumulate here.
* [window:set_position](config/lua/window/set_position.md) method for controlling window position.
* [window:maximize](config/lua/window/maximize.md) and [window:restore](config/lua/window/restore.md) methods for controlling window maximization state.
* [window:get_selection_escapes_for_pane](config/lua/window/get_selection_escapes_for_pane.md) method for getting the current selection including escape sequences. [#2223](https://github.com/wez/wezterm/issues/2223)
* [window:current_event](config/lua/window/current_event.md) method for getting the current event. [#2296](https://github.com/wez/wezterm/pull/2296)
* [wezterm.color](config/lua/wezterm.color/index.md) module for working with colors and importing color schemes.
* [wezterm.gui](config/lua/wezterm.gui/index.md) module and [mux_window:gui_window](config/lua/mux-window/gui_window.md) method.
* [wezterm.gui.screens()](config/lua/wezterm.gui/screens.md) function for getting information about the available screens/monitors/displays
@ -32,6 +33,7 @@ As features stabilize some brief notes about them will accumulate here.
* [pane:is_alt_screen_active()](config/lua/pane/is_alt_screen_active.md) for testing whether the alt screen is active. Thanks to [@Funami580](https://github.com/Funami580)! [#2234](https://github.com/wez/wezterm/issues/2234)
* X11/Wayland: [XDG desktop portal](https://flatpak.github.io/xdg-desktop-portal/) is now used to determine whether dark mode is in use [#2258](https://github.com/wez/wezterm/issues/2258)
* [SetPaneZoomState](config/lua/keyassignment/SetPaneZoomState.md) key assignment and [MuxTab:set_zoomed()](config/lua/MuxTab/set_zoomed.md) for explicitly setting the zoom state of a pane. [#2284](https://github.com/wez/wezterm/discussions/2284)
* [mouse_bindings](config/mouse.md) can now handle scroll events. Thanks to [@Funami580](https://github.com/Funami580)! [#2173](https://github.com/wez/wezterm/issues/2173) [#2296](https://github.com/wez/wezterm/pull/2296)
#### Changed
* If `timeout_milliseconds` is specified in

View File

@ -0,0 +1,26 @@
# `window:current_event()`
*Since: nightly builds only*
Returns the current event.
For now only implemented for mouse events.
This example prints the delta scroll value
when you scroll up with your mouse wheel while holding `CTRL`:
```lua
local wezterm = require 'wezterm'
return {
mouse_bindings = {
{
event = 'WheelUp',
mods = 'CTRL',
action = wezterm.action_callback(function(window, pane)
local delta = window:current_event()['Down']['button']['WheelUp']
wezterm.log_info('delta is: ' .. delta)
end),
},
},
}
```

View File

@ -124,6 +124,36 @@ you wanted quadruple-click bindings you can specify `streak=4`.
| Double Left Up | `event={Up={streak=2, button="Left"}}` |
| Single Left Drag | `event={Drag={streak=1, button="Left"}}` |
*since: nightly builds only*
You can handle scroll events by using `'WheelUp'` or `'WheelDown'` as event.
Currently, this only works with at least one modifier being present.
```lua
local wezterm = require 'wezterm'
local act = wezterm.action
return {
mouse_bindings = {
-- Scrolling up while holding CTRL increases the font size
{
event = 'WheelUp',
mods = 'CTRL',
action = act.IncreaseFontSize,
},
-- Scrolling down while holding CTRL decreases the font size
{
event = 'WheelDown',
mods = 'CTRL',
action = act.DecreaseFontSize,
},
},
}
```
Take a look at [`window:current_event`](lua/window/current_event.md),
if you want to access the delta scroll value while handling the event.
# Gotcha on binding an 'Up' event only