feat(ui): seleksi baris pakai highlight (token Selection) gantikan panah — sesuai masukan
CI / test (push) Failing after 14s
CI / test (push) Failing after 14s
This commit is contained in:
1 parent
a28b83513d
commit
db891398fb
4 files changed
+138
-32
No files matched your search
+36
-9
@@ -616,11 +616,10 @@ func (m Model) sidebarView() string {
|
||||
}
|
||||
|
||||
func (m Model) sectionLine(i, innerW int) string {
|
||||
mark := " "
|
||||
if i == m.cur() {
|
||||
mark = styled(theme.Current().Accent, "▶ ")
|
||||
}
|
||||
sel := i == m.cur()
|
||||
th := theme.Current()
|
||||
|
||||
var line string
|
||||
switch m.section {
|
||||
case sectionImages:
|
||||
im := m.images[i]
|
||||
@@ -628,19 +627,47 @@ func (m Model) sectionLine(i, innerW int) string {
|
||||
if m.imageInUse(im.ID) {
|
||||
glyph, color = "●", th.Success
|
||||
}
|
||||
return mark + styled(color, glyph) + " " +
|
||||
text(truncate(imageDisplayName(im), innerW-10)) + dim(" "+humanBytes(im.Size))
|
||||
line = paintRow(sel, color, glyph) +
|
||||
paintRow(sel, th.Text, " "+truncate(imageDisplayName(im), innerW-10)) +
|
||||
paintRow(sel, th.Subtext, " "+humanBytes(im.Size))
|
||||
case sectionVolumes:
|
||||
v := m.volumes[i]
|
||||
return mark + text(truncate(v.Name, innerW-6)) + dim(" "+v.Driver)
|
||||
line = paintRow(sel, th.Text, truncate(v.Name, innerW-6)) +
|
||||
paintRow(sel, th.Subtext, " "+v.Driver)
|
||||
case sectionNetworks:
|
||||
n := m.networks[i]
|
||||
return mark + text(truncate(n.Name, innerW-6)) + dim(" "+n.Driver)
|
||||
line = paintRow(sel, th.Text, truncate(n.Name, innerW-6)) +
|
||||
paintRow(sel, th.Subtext, " "+n.Driver)
|
||||
default:
|
||||
c := m.containers[i]
|
||||
glyph, color := stateStyle(c.State)
|
||||
return mark + styled(color, glyph) + " " + text(truncate(c.Name, innerW-4))
|
||||
line = paintRow(sel, color, glyph) +
|
||||
paintRow(sel, th.Text, " "+truncate(c.Name, innerW-4))
|
||||
}
|
||||
if sel {
|
||||
line = selPad(line, innerW)
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
// paintRow — satu segmen baris daftar; baris terpilih memakai latar
|
||||
// token Selection sehingga posisi aktif jelas tanpa perlu panah.
|
||||
func paintRow(sel bool, fg theme.Color, s string) string {
|
||||
st := theme.Style(fg)
|
||||
if sel {
|
||||
st = st.Background(lipgloss.Color(string(theme.Current().Selection)))
|
||||
}
|
||||
return st.Render(s)
|
||||
}
|
||||
|
||||
// selPad — isi sisa lebar baris terpilih dengan latar Selection penuh.
|
||||
func selPad(s string, w int) string {
|
||||
gap := w - lipgloss.Width(s)
|
||||
if gap <= 0 {
|
||||
return s
|
||||
}
|
||||
bg := lipgloss.NewStyle().Background(lipgloss.Color(string(theme.Current().Selection)))
|
||||
return s + bg.Render(strings.Repeat(" ", gap))
|
||||
}
|
||||
|
||||
func (m Model) contentView() string {
|
||||
|
||||
Reference in new issue
Block a user