From 68a23a10e101cb05ea67816aec8b2802ed8ba5eb Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Thu, 12 Apr 2018 19:14:50 +0300 Subject: [PATCH] show command counts in the ruler Related #66 --- ui.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ui.go b/ui.go index a16a991..9169567 100644 --- a/ui.go +++ b/ui.go @@ -586,8 +586,9 @@ func (ui *ui) drawStatLine(nav *nav) { tot := len(currDir.fi) ind := min(currDir.ind+1, tot) + acc := string(ui.keyCount) + string(ui.keyAcc) - ruler := fmt.Sprintf("%d/%d", ind, tot) + ruler := fmt.Sprintf("%s %d/%d", acc, ind, tot) ui.msgWin.printRight(0, fg, bg, ruler) } @@ -765,6 +766,11 @@ func (ui *ui) readEvent(ch chan<- expr, ev termbox.Event) { ui.keyAcc = append(ui.keyAcc, val...) } + if len(ui.keyAcc) == 0 { + ch <- redraw + break + } + binds, ok := findBinds(gOpts.keys, string(ui.keyAcc)) switch len(binds) { @@ -792,12 +798,10 @@ func (ui *ui) readEvent(ch chan<- expr, ev termbox.Event) { ch <- expr ui.keyAcc = nil ui.keyCount = nil - } - if len(ui.keyAcc) > 0 { + ui.menuBuf = nil + } else { ui.menuBuf = listBinds(binds) ch <- redraw - } else if ui.menuBuf != nil { - ui.menuBuf = nil } default: if ok { @@ -818,12 +822,10 @@ func (ui *ui) readEvent(ch chan<- expr, ev termbox.Event) { ch <- expr ui.keyAcc = nil ui.keyCount = nil - } - if len(ui.keyAcc) > 0 { + ui.menuBuf = nil + } else { ui.menuBuf = listBinds(binds) ch <- redraw - } else { - ui.menuBuf = nil } } case termbox.EventResize: