status fixes, ctrl+pn works as arrow keys

pull/137/head
Simon Let 6 years ago
parent f3d3180f4f
commit 8349400806
  1. 31
      cmd/cli/main.go

@ -124,9 +124,15 @@ func runReshCli() (string, int) {
if err := g.SetKeybinding("", gocui.KeyArrowDown, gocui.ModNone, layout.Next); err != nil { if err := g.SetKeybinding("", gocui.KeyArrowDown, gocui.ModNone, layout.Next); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlN, gocui.ModNone, layout.Next); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, layout.Prev); err != nil { if err := g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, layout.Prev); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlP, gocui.ModNone, layout.Prev); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err) log.Panicln(err)
} }
@ -448,6 +454,9 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
} }
} }
if m.s.highlightedItem >= len(m.s.data) {
m.s.highlightedItem = len(m.s.data) - 1
}
// status line // status line
topBoxSize := 3 // size of the query box up top topBoxSize := 3 // size of the query box up top
realLineLength := maxX - 2 realLineLength := maxX - 2
@ -457,15 +466,16 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
m.s.displayedItemsCount = maxY - topBoxSize - selectedLineCount m.s.displayedItemsCount = maxY - topBoxSize - selectedLineCount
for i, itm := range data { var index int
if i == maxY-topBoxSize-selectedLineCount { for index < len(data) {
if debug { itm := data[index]
log.Println(maxY) if index == maxY-topBoxSize-selectedLineCount {
} // page is full
break break
} }
displayStr, _ := itm.produceLine(longestDateLen, longestFlagsLen, true) displayStr, _ := itm.produceLine(longestDateLen, longestFlagsLen, true)
if m.s.highlightedItem == i { if m.s.highlightedItem == index {
// maxX * 2 because there are escape sequences that make it hard to tell the real string lenght // maxX * 2 because there are escape sequences that make it hard to tell the real string lenght
displayStr = doHighlightString(displayStr, maxX*2) displayStr = doHighlightString(displayStr, maxX*2)
if debug { if debug {
@ -482,9 +492,12 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
} }
} }
v.WriteString(displayStr + "\n") v.WriteString(displayStr + "\n")
// if m.s.highlightedItem == i { index++
// v.SetHighlight(m.s.highlightedItem, true) }
// } // push the status line to the bottom of the page
for index < maxY-topBoxSize-selectedLineCount {
v.WriteString("\n")
index++
} }
// status line // status line
var idxSt, idxEnd int var idxSt, idxEnd int

Loading…
Cancel
Save