Skip to content

Commit 6b5d4d0

Browse files
committed
refactor!: Moved window event descriptions for each wezterm.on def.
Signed-off-by: Guennadi Maximov C <g.maxc.fox@protonmail.com>
1 parent cf0f6fa commit 6b5d4d0

2 files changed

Lines changed: 115 additions & 128 deletions

File tree

Lines changed: 12 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,15 @@
11
---@meta
22

3-
---The `"augment-command-palette"` event is emitted when
4-
---the `Command Palette` is shown.
5-
---
6-
---Its purpose is to enable you to add additional entries
7-
---to the list of commands shown in the palette.
8-
---
9-
---This hook is synchronous; calling asynchronous functions will not succeed.
10-
---
11-
---The return value is a `AugmentCommandPaletteReturn` table.
12-
---
13-
---@alias AugmentCommandPalette "augment-command-palette"
14-
15-
---The `"bell"` event is emitted when the `ASCII BEL` sequence
16-
---is emitted to a pane in the window.
17-
---
18-
---Defining an event handler doesn't alter wezterm's handling of the bell;
19-
---the event supplements it and allows you
20-
---to take additional action over the configured behavior.
21-
---
22-
---@alias Bell "bell"
23-
24-
---The `"format-tab-title"` event is emitted when the text for a tab title
25-
---needs to be recomputed.
26-
---
27-
---This event is a bit special in that it is synchronous and must return
28-
---as quickly as possible in order to avoid blocking the GUI thread.
29-
---
30-
---The most notable consequence of this is that some functions that are asynchronous
31-
---(e.g. `wezterm.run_child_process()`) are not possible to call
32-
---from inside the event handler and will generate a
33-
---`format-tab-title: runtime error: attempt to yield from outside a coroutine` error.
34-
---
35-
---@alias FormatTabTitle "format-tab-title"
36-
37-
---The `"format-window-title"` event is emitted when the text for the window title
38-
---needs to be recomputed.
39-
---
40-
---This event is a bit special in that it is synchronous and must return
41-
---as quickly as possible in order to avoid blocking the GUI thread.
42-
---
43-
---The most notable consequence of this is that some functions that are asynchronous
44-
---(e.g. `wezterm.run_child_process()`) are not possible to call
45-
---from inside the event handler and will generate a
46-
---`format-window-title: runtime error: attempt to yield from outside a coroutine` error.
47-
---
48-
---@alias FormatWindowTitle "format-window-title"
49-
50-
---The `"new-tab-button-click"` event is emitted when the user clicks on the
51-
---`"new tab"` button in the tab bar.
52-
---
53-
---This is the `+` button that is drawn to the right of the last tab.
54-
---
55-
---@alias NewTabButtonClick "new-tab-button-click"
56-
57-
---The `"open-uri"` event is emitted when
58-
---the `CompleteSelectionOrOpenLinkAtMouseCursor` key/mouse assignment is triggered.
59-
---
60-
---The default action is to open the active URI in your browser,
61-
---but if you register for this event you can co-opt the default behavior.
62-
---
63-
---@alias OpenUri "open-uri"
64-
65-
---The `"update-right-status"` event is emitted periodically
66-
---(based on the interval specified by `config.status_update_interval`).
67-
---
68-
---@alias UpdateRightStatus "update-right-status"
69-
70-
---The `"update-status"` event is emitted periodically
71-
---(based on the interval specified by the status_update_interval configuration value).
72-
---
73-
---@alias UpdateStatus "update-status"
74-
75-
---The `"user-var-changed"` event is emitted when a _user var escape sequence_
76-
---is used to set a user var.
77-
---
78-
---@alias UserVarChanged "user-var-changed"
79-
80-
---The `"window-config-reloaded"` event is emitted when the configuration for
81-
---a window has been reloaded.
82-
---
83-
---This can occur when the configuration file is detected as changed
84-
---(when `Config.automatically_reload_config` is enabled),
85-
---when the configuration is explicitly reloaded via the `ReloadConfiguration` key action,
86-
---and when `Window:set_config_overrides()` is called for the window.
87-
---
88-
---@alias WindowConfigReloaded "window-config-reloaded"
89-
90-
---The `"window-focus-changed"` event is emitted when the focus state
91-
---for a window is changed.
92-
---
93-
---@alias WindowFocusChanged "window-focus-changed"
94-
95-
---The `"window-resized"` event is emitted when the window is resized
96-
---and when transitioning between full-screen and regular windowed mode.
97-
---
98-
---The event is triggered asynchronously with respect to the potentially-ongoing
99-
---live resize operation. `wezterm` will coalesce the stream of multiple events
100-
---generated by a live resize such that there can be
101-
---a maximum of 1 event executing and 1 event buffered.
102-
---
103-
---@alias WindowResized "window-resized"
104-
1053
---@alias WindowEvent
106-
---|AugmentCommandPalette
107-
---|Bell
108-
---|FormatTabTitle
109-
---|FormatWindowTitle
110-
---|NewTabButtonClick
111-
---|OpenUri
112-
---|UpdateRightStatus -- DEPRECATED
113-
---|UpdateStatus
114-
---|UserVarChanged
115-
---|WindowConfigReloaded
116-
---|WindowFocusChanged
117-
---|WindowResized
4+
---|"augment-command-palette"
5+
---|"bell"
6+
---|"format-tab-title"
7+
---|"format-window-title"
8+
---|"new-tab-button-click"
9+
---|"open-uri"
10+
---|"update-right-status" -- DEPRECATED
11+
---|"update-status"
12+
---|"user-var-changed"
13+
---|"window-config-reloaded"
14+
---|"window-focus-changed"
15+
---|"window-resized"

lua/wezterm/types/wezterm.lua

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,18 @@ local Wezterm = {}
11491149
---Its purpose is to enable you to add additional entries to the list of commands shown in the palette.
11501150
---
11511151
---This hook is synchronous; calling asynchronous functions will not succeed.
1152+
------
1153+
---The `"augment-command-palette"` event is emitted when
1154+
---the `Command Palette` is shown.
1155+
---
1156+
---Its purpose is to enable you to add additional entries
1157+
---to the list of commands shown in the palette.
1158+
---
1159+
---This hook is synchronous; calling asynchronous functions will not succeed.
1160+
---
1161+
---The return value is an [`AugmentCommandPaletteReturn`](lua://AugmentCommandPaletteReturn) table.
11521162
---
1153-
---@param event AugmentCommandPalette
1163+
---@param event "augment-command-palette"
11541164
---@param callback AugmentCallbackWindowPane
11551165
---@return AugmentCommandPaletteReturn
11561166
function Wezterm.on(event, callback) end
@@ -1160,7 +1170,15 @@ function Wezterm.on(event, callback) end
11601170
--- the pane in which the bell was rung, which may not be active pane;
11611171
--- it could be in an unfocused pane or tab
11621172
---
1163-
---@param event Bell
1173+
------
1174+
---The `"bell"` event is emitted when the `ASCII BEL` sequence
1175+
---is emitted to a pane in the window.
1176+
---
1177+
---Defining an event handler doesn't alter wezterm's handling of the bell;
1178+
---the event supplements it and allows you
1179+
---to take additional action over the configured behavior.
1180+
---
1181+
---@param event "bell"
11641182
---@param callback CallbackWindowPane
11651183
function Wezterm.on(event, callback) end
11661184

@@ -1196,7 +1214,19 @@ function Wezterm.on(event, callback) end
11961214
---it doesn't make sense to define multiple instances of the event
11971215
---with `multiple wezterm.on("format-tab-title", ...)` calls.
11981216
---
1199-
---@param event FormatTabTitle
1217+
------
1218+
---The `"format-tab-title"` event is emitted when the text for a tab title
1219+
---needs to be recomputed.
1220+
---
1221+
---This event is a bit special in that it is synchronous and must return
1222+
---as quickly as possible in order to avoid blocking the GUI thread.
1223+
---
1224+
---The most notable consequence of this is that some functions that are asynchronous
1225+
---(e.g. `wezterm.run_child_process()`) are not possible to call
1226+
---from inside the event handler and will generate a
1227+
---`format-tab-title: runtime error: attempt to yield from outside a coroutine` error.
1228+
---
1229+
---@param event "format-tab-title"
12001230
---@param callback fun(tab: MuxTab, tabs: MuxTab[], panes: Pane[], config: Config, hover: boolean, max_width: number): string|FormatItem
12011231
function Wezterm.on(event, callback) end
12021232

@@ -1227,29 +1257,55 @@ function Wezterm.on(event, callback) end
12271257
---it doesn't make sense to define multiple instances of the event
12281258
---with multiple `wezterm.on("format-window-title", ...)` calls.
12291259
---
1230-
---@param event FormatWindowTitle
1260+
------
1261+
---The `"format-window-title"` event is emitted when the text for the window title
1262+
---needs to be recomputed.
1263+
---
1264+
---This event is a bit special in that it is synchronous and must return
1265+
---as quickly as possible in order to avoid blocking the GUI thread.
1266+
---
1267+
---The most notable consequence of this is that some functions that are asynchronous
1268+
---(e.g. `wezterm.run_child_process()`) are not possible to call
1269+
---from inside the event handler and will generate a
1270+
---`format-window-title: runtime error: attempt to yield from outside a coroutine` error.
1271+
---
1272+
---@param event "format-window-title"
12311273
---@param callback fun(window: Window, pane: Pane, tabs: MuxTab[], panes: Pane[], config: Config): string
12321274
function Wezterm.on(event, callback) end
12331275

1234-
---@param event GuiAttached
1276+
---@param event "gui-attached"
12351277
---@param callback fun(domain: ExecDomain)
12361278
function Wezterm.on(event, callback) end
12371279

1238-
---@param event GuiStartup
1280+
---@param event "gui-startup"
12391281
---@param callback fun(cmd?: SpawnCommand)
12401282
function Wezterm.on(event, callback) end
12411283

12421284
--- - The first event parameter is a [`Window`](lua://Window) object that represents the GUI window
12431285
--- - The second event parameter is a [`Pane`](lua://Pane) object that represents the active pane in the window
12441286
---
1245-
---@param event NewTabButtonClick
1287+
------
1288+
---The `"new-tab-button-click"` event is emitted when the user clicks on the
1289+
---`"new tab"` button in the tab bar.
1290+
---
1291+
---This is the `+` button that is drawn to the right of the last tab.
1292+
---
1293+
---@param event "new-tab-button-click"
12461294
---@param callback fun(window: Window, pane: Pane, button: "Left"|"Middle"|"Right", default_action: KeyAssignment)
12471295
function Wezterm.on(event, callback) end
12481296

12491297
--- - The first event parameter is a [`Window`](lua://Window) object that represents the GUI window
12501298
--- - The second event parameter is a [`Pane`](lua://Pane) object that represents the pane
12511299
--- - The third event parameter is the URI string
1252-
---@param event OpenUri
1300+
---
1301+
------
1302+
---The `"open-uri"` event is emitted when
1303+
---the `CompleteSelectionOrOpenLinkAtMouseCursor` key/mouse assignment is triggered.
1304+
---
1305+
---The default action is to open the active URI in your browser,
1306+
---but if you register for this event you can co-opt the default behavior.
1307+
---
1308+
---@param event "open-uri"
12531309
---@param callback fun(window: Window, pane: Pane, uri: string)
12541310
function Wezterm.on(event, callback) end
12551311

@@ -1268,7 +1324,11 @@ function Wezterm.on(event, callback) end
12681324
---`wezterm` won't schedule another call until `status_update_interval_milliseconds`
12691325
---have elapsed since the last call completed.
12701326
---
1271-
---@param event UpdateRightStatus
1327+
------
1328+
---The `"update-right-status"` event is emitted periodically
1329+
---(based on the interval specified by `config.status_update_interval`).
1330+
---
1331+
---@param event "update-right-status"
12721332
---@param callback CallbackWindowPane
12731333
---@deprecated
12741334
function Wezterm.on(event, callback) end
@@ -1285,7 +1345,11 @@ function Wezterm.on(event, callback) end
12851345
---`wezterm` won't schedule another call until `status_update_interval` milliseconds
12861346
---have elapsed since the last call completed.
12871347
---
1288-
---@param event UpdateStatus
1348+
------
1349+
---The `"update-status"` event is emitted periodically
1350+
---(based on the interval specified by the status_update_interval configuration value).
1351+
---
1352+
---@param event "update-status"
12891353
---@param callback CallbackWindowPane
12901354
function Wezterm.on(event, callback) end
12911355

@@ -1312,7 +1376,11 @@ function Wezterm.on(event, callback) end
13121376
---
13131377
---See `Pane:get_user_vars()`.
13141378
---
1315-
---@param event UserVarChanged
1379+
------
1380+
---The `"user-var-changed"` event is emitted when a _user var escape sequence_
1381+
---is used to set a user var.
1382+
---
1383+
---@param event "user-var-changed"
13161384
---@param callback fun(window: Window, pane: Pane, name: string, value: string)
13171385
function Wezterm.on(event, callback) end
13181386

@@ -1328,7 +1396,16 @@ function Wezterm.on(event, callback) end
13281396
--- - The first event parameter is a [`Window`](lua://Window) object that represents the GUI window
13291397
--- - The second event parameter is a [`Pane`](lua://Pane) object that represents the active pane in that window
13301398
---
1331-
---@param event WindowConfigReloaded
1399+
------
1400+
---The `"window-config-reloaded"` event is emitted when the configuration for
1401+
---a window has been reloaded.
1402+
---
1403+
---This can occur when the configuration file is detected as changed
1404+
---(when `Config.automatically_reload_config` is enabled),
1405+
---when the configuration is explicitly reloaded via the `ReloadConfiguration` key action,
1406+
---and when `Window:set_config_overrides()` is called for the window.
1407+
---
1408+
---@param event "window-config-reloaded"
13321409
---@param callback CallbackWindowPane
13331410
function Wezterm.on(event, callback) end
13341411

@@ -1338,13 +1415,25 @@ function Wezterm.on(event, callback) end
13381415
--- - The first event parameter is a `Window` object that represents the GUI window
13391416
--- - The second event parameter is a `Pane` object that represents the active pane in that window
13401417
---
1341-
---@param event WindowFocusChanged
1418+
------
1419+
---The `"window-focus-changed"` event is emitted when the focus state
1420+
---for a window is changed.
1421+
---
1422+
---@param event "window-focus-changed"
13421423
---@param callback CallbackWindowPane
13431424
function Wezterm.on(event, callback) end
13441425

13451426
--- - The first event parameter is a `Window` object that represents the GUI window
13461427
--- - The second event parameter is a `Pane` object that represents the active pane in that window
13471428
---
1348-
---@param event WindowResized
1429+
---The `"window-resized"` event is emitted when the window is resized
1430+
---and when transitioning between full-screen and regular windowed mode.
1431+
---
1432+
---The event is triggered asynchronously with respect to the potentially-ongoing
1433+
---live resize operation. `wezterm` will coalesce the stream of multiple events
1434+
---generated by a live resize such that there can be
1435+
---a maximum of 1 event executing and 1 event buffered.
1436+
---
1437+
---@param event "window-resized"
13491438
---@param callback CallbackWindowPane
13501439
function Wezterm.on(event, callback) end

0 commit comments

Comments
 (0)