Skip to content

Commit dd60042

Browse files
sxyazixeysz
authored andcommitted
feat: new ui.Align, ui.Wrap, and ui.Edge (sxyazi#2802)
1 parent d6b2c3b commit dd60042

File tree

28 files changed

+217
-104
lines changed

28 files changed

+217
-104
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

yazi-plugin/preset/components/current.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Current:empty()
2020
end
2121

2222
return {
23-
ui.Line(s):area(self._area):align(ui.Line.CENTER),
23+
ui.Line(s):area(self._area):align(ui.Align.CENTER),
2424
}
2525
end
2626

@@ -43,7 +43,7 @@ function Current:redraw()
4343

4444
return {
4545
ui.List(left):area(self._area),
46-
ui.Text(right):area(self._area):align(ui.Text.RIGHT),
46+
ui.Text(right):area(self._area):align(ui.Align.RIGHT),
4747
}
4848
end
4949

yazi-plugin/preset/components/header.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Header = {
2+
-- TODO: remove these two constants
23
LEFT = 0,
34
RIGHT = 1,
45

@@ -83,7 +84,7 @@ function Header:redraw()
8384

8485
return {
8586
ui.Line(left):area(self._area),
86-
ui.Line(right):area(self._area):align(ui.Line.RIGHT),
87+
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
8788
}
8889
end
8990

yazi-plugin/preset/components/marker.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Marker:redraw()
2929
w = 1,
3030
h = math.min(1 + last[2] - last[1], self._area.y + self._area.h - y),
3131
}
32-
elements[#elements + 1] = ui.Bar(ui.Bar.LEFT):area(rect):style(last[3])
32+
elements[#elements + 1] = ui.Bar(ui.Edge.LEFT):area(rect):style(last[3])
3333
end
3434

3535
local last = { 0, 0, nil } -- start, end, style

yazi-plugin/preset/components/rail.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ end
1010

1111
function Rail:build()
1212
self._base = {
13-
ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):symbol(th.mgr.border_symbol):style(th.mgr.border_style),
14-
ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):symbol(th.mgr.border_symbol):style(th.mgr.border_style),
13+
ui.Bar(ui.Edge.RIGHT):area(self._chunks[1]):symbol(th.mgr.border_symbol):style(th.mgr.border_style),
14+
ui.Bar(ui.Edge.LEFT):area(self._chunks[3]):symbol(th.mgr.border_symbol):style(th.mgr.border_style),
1515
}
1616
self._children = {
1717
Marker:new(self._chunks[1], self._tab.parent),

yazi-plugin/preset/components/status.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Status = {
2+
-- TODO: remove these two constants
23
LEFT = 0,
34
RIGHT = 1,
45

@@ -141,7 +142,7 @@ function Status:redraw()
141142
return {
142143
ui.Text(""):area(self._area):style(th.status.overall),
143144
ui.Line(left):area(self._area),
144-
ui.Line(right):area(self._area):align(ui.Line.RIGHT),
145+
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
145146
table.unpack(ui.redraw(Progress:new(self._area, right_width))),
146147
}
147148
end

yazi-plugin/preset/plugins/archive.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function M:peek(job)
4545
else
4646
ya.preview_widget(job, {
4747
ui.Text(left):area(job.area),
48-
ui.Text(right):area(job.area):align(ui.Text.RIGHT),
48+
ui.Text(right):area(job.area):align(ui.Align.RIGHT),
4949
})
5050
end
5151
end

yazi-plugin/preset/plugins/empty.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
22

3-
function M.msg(job, s) ya.preview_widget(job, ui.Text(ui.Line(s):reverse()):area(job.area):wrap(ui.Text.WRAP)) end
3+
function M.msg(job, s) ya.preview_widget(job, ui.Text(ui.Line(s):reverse()):area(job.area):wrap(ui.Wrap.YES)) end
44

55
function M:peek(job)
66
local path = tostring(job.file.url)

yazi-plugin/preset/plugins/file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function M:peek(job)
1111
text = ui.Text(string.format("Failed to start `%s`, error: %s", cmd, err))
1212
end
1313

14-
ya.preview_widget(job, text:area(job.area):wrap(ui.Text.WRAP))
14+
ya.preview_widget(job, text:area(job.area):wrap(ui.Wrap.YES))
1515
end
1616

1717
function M:seek() end

yazi-plugin/preset/plugins/folder.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function M:peek(job)
1616
if #folder.files == 0 then
1717
local done, err = folder.stage()
1818
local s = not done and "Loading..." or not err and "No items" or string.format("Error: %s", err)
19-
return ya.preview_widget(job, ui.Line(s):area(job.area):align(ui.Line.CENTER))
19+
return ya.preview_widget(job, ui.Line(s):area(job.area):align(ui.Align.CENTER))
2020
end
2121

2222
local items = {}

0 commit comments

Comments
 (0)