Skip to content

Commit 3deffac

Browse files
authored
Chore: Update Yazi types
Reference: sxyazi/yazi#2802
1 parent 529a4a8 commit 3deffac

File tree

1 file changed

+69
-88
lines changed

1 file changed

+69
-88
lines changed

yazi_types.lua

Lines changed: 69 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,59 @@
8888
--- style: ui.Style,
8989
---): ui.Span
9090

91-
-- The types for the alignments of the ui.Line object
92-
---@alias ui.Line.LEFT integer Align the line to the left.
93-
---@alias ui.Line.CENTER integer Align the line to the center.
94-
---@alias ui.Line.RIGHT integer Align the line to the right
95-
96-
-- The possible alignments of the ui.Line object
97-
---@alias ui.Line.Alignment
98-
--- |ui.Line.LEFT
99-
--- |ui.Line.CENTER
100-
--- |ui.Line.RIGHT
91+
-- The types for the alignments of the UI objects
92+
---@alias ui.Align.LEFT integer Align the UI object to the left.
93+
---@alias ui.Align.CENTER integer Align the UI object to the center.
94+
---@alias ui.Align.RIGHT integer Align the UI object to the right.
95+
96+
-- The type of the ui.Align object
97+
---@class (exact) ui.Align
98+
---@field LEFT ui.Align.LEFT Align the UI object to the left.
99+
---@field CENTER ui.Align.CENTER Align the UI object to the center.
100+
---@field RIGHT ui.Align.RIGHT Align the UI object to the right.
101+
102+
-- The type for all possible alignments
103+
---@alias ui.Alignment ui.Align.LEFT|ui.Align.CENTER|ui.Align.RIGHT
104+
105+
-- The types for the wrapping on UI objects
106+
---@alias ui.Wrap.NO integer No wrapping.
107+
---@alias ui.Wrap.YES integer Wrap at the end of the line.
108+
---@alias ui.Wrap.TRIM integer ui.Wrap.YES + trim leading whitespace.
109+
110+
-- The type of the ui.Wrap object
111+
---@class (exact) ui.Wrap
112+
---@field NO ui.Wrap.NO No wrapping.
113+
---@field YES ui.Wrap.YES Wrap at the end of the line.
114+
---@field TRIM ui.Wrap.TRIM ui.Wrap.YES + trim leading whitespace.
115+
116+
-- The type for all possible wrap types
117+
---@alias ui.Wrapping ui.Wrap.NO|ui.Wrap.YES|ui.Wrap.TRIM
118+
119+
-- The edges of the UI objects
120+
---@alias ui.Edge.NONE integer No edge.
121+
---@alias ui.Edge.TOP integer Edge on the top.
122+
---@alias ui.Edge.RIGHT integer Edge on the right of the object.
123+
---@alias ui.Edge.BOTTOM integer Edge on the bottom of the object.
124+
---@alias ui.Edge.LEFT integer Edge on the left of the object.
125+
---@alias ui.Edge.ALL integer Edges all around the object.
126+
127+
-- The type of the ui.Edge object
128+
---@class (exact) ui.Edge
129+
---@field NONE ui.Edge.NONE No edge.
130+
---@field TOP ui.Edge.TOP Edge on the top.
131+
---@field RIGHT ui.Edge.RIGHT Edge on the right of the object.
132+
---@field BOTTOM ui.Edge.BOTTOM Edge on the bottom of the object.
133+
---@field LEFT ui.Edge.LEFT Edge on the left of the object.
134+
---@field ALL ui.Edge.ALL Edges all around the object.
135+
136+
-- The type for all possible edges of UI objects
137+
---@alias ui.Edges
138+
--- |ui.Edge.NONE
139+
--- |ui.Edge.TOP
140+
--- |ui.Edge.RIGHT
141+
--- |ui.Edge.BOTTOM
142+
--- |ui.Edge.LEFT
143+
--- |ui.Edge.ALL
101144

102145
-- The type of the ui.Line object
103146
---@class (exact) ui.Line: ui.Style
@@ -112,38 +155,13 @@
112155
--- Set the alignment of the line.
113156
--- Arguments:
114157
--- - alignment: The alignment to set.
115-
---@field align fun(self: ui.Line, alignment: ui.Line.Alignment): ui.Line
158+
---@field align fun(self: ui.Line, alignment: ui.Alignment): ui.Line
116159
---@field visible fun(self: ui.Line): boolean Whether the line is visible.
117160
---
118161
--- Set the style of the line.
119162
--- Arguments:
120163
--- - style: The style to set.
121164
---@field style fun(self: ui.Line, style: ui.Style): ui.Line
122-
---@field LEFT ui.Line.LEFT A constant for the align() method
123-
---@field CENTER ui.Line.CENTER A constant for the align() method
124-
---@field RIGHT ui.Line.RIGHT A constant for the align() method
125-
126-
-- The types for the alignments of the ui.Text object
127-
---@alias ui.Text.LEFT integer Align the text to the left.
128-
---@alias ui.Text.CENTER integer Align the text to the center.
129-
---@alias ui.Text.RIGHT integer Align the text to the right
130-
131-
-- The possible alignments of the ui.Text object
132-
---@alias ui.Text.Alignment
133-
--- |ui.Text.LEFT
134-
--- |ui.Text.CENTER
135-
--- |ui.Text.RIGHT
136-
137-
-- The types for the wrap of the ui.Text object
138-
---@alias ui.Text.WRAP_NO integer No wrapping.
139-
---@alias ui.Text.WRAP integer Wrap at the end of the line.
140-
---@alias ui.Text.WRAP_TRIM integer ui.Text.WRAP + trim leading whitespace.
141-
142-
-- The possible wrappings of the ui.Text object
143-
---@alias ui.Text.Wrapping
144-
--- |ui.Text.WRAP_NO
145-
--- |ui.Text.WRAP
146-
--- |ui.Text.WRAP_TRIM
147165

148166
-- The type of the ui.Text object
149167
---@class (exact) ui.Text: ui.Style
@@ -163,12 +181,12 @@
163181
--- Set the alignment of the text.
164182
--- Arguments:
165183
--- - alignment: The alignment to set.
166-
---@field align fun(self: ui.Text, alignment: ui.Text.Alignment): ui.Text
184+
---@field align fun(self: ui.Text, alignment: ui.Alignment): ui.Text
167185
---
168186
--- Set the wrapping of the text.
169187
--- Arguments:
170188
--- - wrapping: The wrapping to set.
171-
---@field wrap fun(self: ui.Text, wrapping: ui.Text.Wrapping): ui.Text
189+
---@field wrap fun(self: ui.Text, wrapping: ui.Wrapping): ui.Text
172190
---
173191
--- Get the maximum width of the text.
174192
---@field max_width fun(self: ui.Text): integer
@@ -183,12 +201,6 @@
183201
--- - x: Horizontal position to scroll to.
184202
--- - y: Vertical position to scroll to.
185203
---@field scroll fun(self: ui.Text, x: integer, y: integer): ui.Text
186-
---@field LEFT ui.Text.LEFT A constant for the align() method
187-
---@field CENTER ui.Text.CENTER A constant for the align() method
188-
---@field RIGHT ui.Text.RIGHT A constant for the align() method
189-
---@field WRAP_NO ui.Text.WRAP_NO A constant for the wrap() method
190-
---@field WRAP ui.Text.WRAP A constant for the wrap() method
191-
---@field WRAP_TRIM ui.Text.WRAP_TRIM A constant for the wrap() method
192204

193205
-- The types for the direction of the ui.Layout object
194206
---@alias ui.Layout.HORIZONTAL integer Layout horizontally.
@@ -289,23 +301,6 @@
289301
--- - style: The style to set.
290302
---@field style fun(self: ui.List, style: ui.Style): ui.List
291303

292-
-- The direction of the ui.Bar object
293-
---@alias ui.Bar.NONE integer No direction.
294-
---@alias ui.Bar.TOP integer Top direction.
295-
---@alias ui.Bar.RIGHT integer Right direction
296-
---@alias ui.Bar.BOTTOM integer Bottom direction.
297-
---@alias ui.Bar.LEFT integer Left direction.
298-
---@alias ui.Bar.ALL integer All directions.
299-
300-
-- The possible directions of the ui.Bar object
301-
---@alias ui.Bar.Direction
302-
--- |ui.Bar.NONE
303-
--- |ui.Bar.TOP
304-
--- |ui.Bar.RIGHT
305-
--- |ui.Bar.BOTTOM
306-
--- |ui.Bar.LEFT
307-
--- |ui.Bar.ALL
308-
309304
-- The type of the ui.Bar object
310305
---@class (exact) ui.Bar
311306
---
@@ -325,29 +320,6 @@
325320
--- Arguments:
326321
--- - style: The style to set.
327322
---@field style fun(self: ui.Bar, style: ui.Style): ui.Bar
328-
---@field NONE string A constant for the ui.Bar() method
329-
---@field TOP string A constant for the ui.Bar() method
330-
---@field RIGHT string A constant for the ui.Bar() method
331-
---@field BOTTOM string A constant for the ui.Bar() method
332-
---@field LEFT string A constant for the ui.Bar() method
333-
---@field ALL string A constant for the ui.Bar() method
334-
335-
-- The position of the ui.Border object
336-
---@alias ui.Border.NONE integer No direction.
337-
---@alias ui.Border.TOP integer Top direction.
338-
---@alias ui.Border.RIGHT integer Right direction
339-
---@alias ui.Border.BOTTOM integer Bottom direction.
340-
---@alias ui.Border.LEFT integer Left direction.
341-
---@alias ui.Border.ALL integer All directions.
342-
343-
-- The possible positions of the ui.Border object
344-
---@alias ui.Border.Position
345-
--- |ui.Border.NONE
346-
--- |ui.Border.TOP
347-
--- |ui.Border.RIGHT
348-
--- |ui.Border.BOTTOM
349-
--- |ui.Border.LEFT
350-
--- |ui.Border.ALL
351323

352324
-- The different types of the ui.Border object
353325
---@alias ui.Border.PLAIN integer Plain border.
@@ -385,6 +357,12 @@
385357
--- Arguments:
386358
--- - style: The style to set.
387359
---@field style fun(self: ui.Border, style: ui.Style): ui.Border
360+
---@field PLAIN ui.Border.PLAIN Plain border.
361+
---@field ROUNDED ui.Border.ROUNDED Rounded border.
362+
---@field DOUBLE ui.Border.DOUBLE Double border.
363+
---@field THICK ui.Border.THICK Thick border.
364+
---@field QUADRANT_INSIDE ui.Border.QUADRANT_INSIDE Border with the quadrant inside.
365+
---@field QUADRANT_OUTSIDE ui.Border.QUADRANT_OUTSIDE Border with the quadrant outside.
388366

389367
-- The type of the ui.Gauge object
390368
---@class (exact) ui.Gauge
@@ -432,6 +410,9 @@
432410

433411
-- The type of the ui global object
434412
---@class (exact) Ui
413+
---@field Align ui.Align The possible alignments for the UI objects.
414+
---@field Wrap ui.Wrap The possible wrap types for the UI objects.
415+
---@field Edge ui.Edge The possible edges for the UI objects.
435416
---@field Rect fun(params: ui.RectParams): ui.Rect Create a rectangular area.
436417
---
437418
--- Create a padding object.
@@ -476,13 +457,13 @@
476457
---
477458
--- Create a bar object.
478459
--- Arguments:
479-
--- - direction: The direction to create the bar.
480-
---@field Bar (fun(direction: ui.Bar.Direction): ui.Bar)|ui.Bar
460+
--- - edge: The edge of the bar.
461+
---@field Bar (fun(edge: ui.Edges): ui.Bar)|ui.Bar
481462
---
482463
--- Create a border object.
483464
--- Arguments:
484-
--- - position: The position to create the border.
485-
---@field Border (fun(position: ui.Border.Position): ui.Border)|ui.Border
465+
--- - edge: The edge of the border.
466+
---@field Border (fun(edge: ui.Edges): ui.Border)|ui.Border
486467
---@field Gauge fun(): ui.Gauge Create a gauge object.
487468
---
488469
--- Clear the content of a specified rectangular area.

0 commit comments

Comments
 (0)