Add --header-lines option

This commit is contained in:
Junegunn Choi
2015-07-22 03:21:20 +09:00
parent 18469b6954
commit f469c25730
8 changed files with 143 additions and 77 deletions

View File

@@ -79,6 +79,7 @@ var _runeWidths = make(map[rune]int)
const (
reqPrompt util.EventType = iota
reqInfo
reqHeader
reqList
reqRefresh
reqRedraw
@@ -231,6 +232,22 @@ func (t *Terminal) UpdateCount(cnt int, final bool) {
}
}
// UpdateHeader updates the header
func (t *Terminal) UpdateHeader(header []string, lines int) {
t.mutex.Lock()
t.header = make([]string, lines)
copy(t.header, header)
if !t.reverse {
reversed := make([]string, lines)
for idx, str := range t.header {
reversed[lines-idx-1] = str
}
t.header = reversed
}
t.mutex.Unlock()
t.reqBox.Set(reqHeader, nil)
}
// UpdateProgress updates the search progress
func (t *Terminal) UpdateProgress(progress float32) {
t.mutex.Lock()
@@ -686,6 +703,8 @@ func (t *Terminal) Loop() {
t.printInfo()
case reqList:
t.printList()
case reqHeader:
t.printHeader()
case reqRefresh:
t.suppress = false
case reqRedraw: