make model.header() less gross
model.showHelp() too
This commit is contained in:
parent
cf82990925
commit
e57afe835d
|
@ -326,19 +326,14 @@ func (m model) showHelp() string {
|
||||||
|
|
||||||
if !m.readonly {
|
if !m.readonly {
|
||||||
if m.mode != modes.Interactive {
|
if m.mode != modes.Interactive {
|
||||||
keys = append([]string{
|
keys = append([]string{styleKey(m.keys.doit)}, keys...)
|
||||||
styleKey(m.keys.doit),
|
|
||||||
}, keys...)
|
|
||||||
}
|
}
|
||||||
keys = append([]string{
|
keys = append([]string{styleKey(m.keys.mark)}, keys...)
|
||||||
styleKey(m.keys.mark),
|
|
||||||
}, keys...)
|
|
||||||
}
|
}
|
||||||
return strings.Join(keys, darkesttext.Render(" • "))
|
return strings.Join(keys, darkesttext.Render(" • "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) header() string {
|
func (m model) header() string {
|
||||||
// TODO: clean this ugly thing up
|
|
||||||
var (
|
var (
|
||||||
right, left string
|
right, left string
|
||||||
spacerWidth int
|
spacerWidth int
|
||||||
|
@ -357,33 +352,30 @@ func (m model) header() string {
|
||||||
}
|
}
|
||||||
dot = darkesttext.Render("•")
|
dot = darkesttext.Render("•")
|
||||||
wideDot = darkesttext.Render(" • ")
|
wideDot = darkesttext.Render(" • ")
|
||||||
|
keysFmt = strings.Join(keys, wideDot)
|
||||||
|
selectFmt = strings.Join(selectKeys, wideDot)
|
||||||
|
filterFmt = strings.Join(filterKeys, wideDot)
|
||||||
)
|
)
|
||||||
|
|
||||||
right = " " // to offset from the table border
|
switch {
|
||||||
switch m.mode {
|
case m.filtering:
|
||||||
case modes.Interactive:
|
right = fmt.Sprintf(" Filtering %s %s", dot, filterFmt)
|
||||||
right += strings.Join(keys, wideDot)
|
case m.mode == modes.Interactive:
|
||||||
default:
|
right = fmt.Sprintf(" %s %s %s", keysFmt, dot, selectFmt)
|
||||||
right += m.mode.String()
|
|
||||||
if m.workdir != "" {
|
|
||||||
right += fmt.Sprintf(" in %s", dirs.UnExpand(m.workdir, ""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
right += fmt.Sprintf(" %s %s", dot, strings.Join(selectKeys, wideDot))
|
|
||||||
|
|
||||||
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
||||||
|
case m.mode == modes.Listing:
|
||||||
if m.mode == modes.Listing {
|
var filtered string
|
||||||
title := "Showing"
|
|
||||||
if m.filter != "" || m.filtering {
|
if m.filter != "" || m.filtering {
|
||||||
title += " (filtered)"
|
filtered = " (filtered)"
|
||||||
}
|
}
|
||||||
right = fmt.Sprintf(" %s %d files in trash", title, len(m.fltrfiles))
|
right = fmt.Sprintf(" Showing%s %d files in trash", filtered, len(m.fltrfiles))
|
||||||
left = ""
|
default:
|
||||||
|
var wd string
|
||||||
|
if m.workdir != "" {
|
||||||
|
wd = " in " + dirs.UnExpand(m.workdir, "")
|
||||||
}
|
}
|
||||||
|
right = fmt.Sprintf(" %s%s %s %s", m.mode.String(), wd, dot, selectFmt)
|
||||||
if m.filtering {
|
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
||||||
right = fmt.Sprintf(" Filtering %s %s", dot, strings.Join(filterKeys, wideDot))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// offset of 2 again because of table border
|
// offset of 2 again because of table border
|
||||||
|
|
Loading…
Reference in a new issue