Skip to content

Commit

Permalink
show number of selected/saved files in status line
Browse files Browse the repository at this point in the history
cc #143
  • Loading branch information
gokcehan committed Feb 13, 2021
1 parent 9ec336f commit 1b93f22
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ func (win *win) printf(screen tcell.Screen, x, y int, st tcell.Style, format str
}

func (win *win) printLine(screen tcell.Screen, x, y int, st tcell.Style, s string) {
win.printf(screen, x, y, st, "%s%*s", s, win.w-len(s), "")
win.printf(screen, x, y, st, "%s%*s", s, win.w-printLength(s), "")
}

func (win *win) printRight(screen tcell.Screen, y int, st tcell.Style, s string) {
win.print(screen, win.w-len(s), y, st, s)
win.print(screen, win.w-printLength(s), y, st, s)
}

func (win *win) printReg(screen tcell.Screen, reg *reg) {
Expand Down Expand Up @@ -729,6 +729,30 @@ func (ui *ui) drawStatLine(nav *nav) {
ind := min(dir.ind+1, tot)
acc := string(ui.keyCount) + string(ui.keyAcc)

var selection string

if len(nav.saves) > 0 {
copy := 0
move := 0
for _, cp := range nav.saves {
if cp {
copy++
} else {
move++
}
}
if copy > 0 {
selection += fmt.Sprintf(" \033[33;7m %d \033[0m", copy)
}
if move > 0 {
selection += fmt.Sprintf(" \033[31;7m %d \033[0m", move)
}
}

if len(nav.selections) > 0 {
selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(nav.selections))
}

var progress string

if nav.copyTotal > 0 {
Expand All @@ -744,7 +768,7 @@ func (ui *ui) drawStatLine(nav *nav) {
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
}

ruler := fmt.Sprintf("%s%s %d/%d", acc, progress, ind, tot)
ruler := fmt.Sprintf("%s%s%s %d/%d", acc, progress, selection, ind, tot)

ui.msgWin.printRight(ui.screen, 0, st, ruler)
}
Expand Down

0 comments on commit 1b93f22

Please sign in to comment.