minor changes

pull/137/head
Simon Let 6 years ago
parent 9265e09938
commit 312f92168f
  1. 26
      cmd/cli/main.go

@ -133,21 +133,23 @@ func runReshCli() (string, int) {
if err := g.SetKeybinding("", gocui.KeyCtrlP, gocui.ModNone, layout.Prev); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlP, gocui.ModNone, layout.Prev); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
if err := g.SetKeybinding("", gocui.KeyArrowRight, gocui.ModNone, layout.SelectPaste); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, quit); err != nil { if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, layout.SelectExecute); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, layout.SelectExecute); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlG, gocui.ModNone, layout.AbortPaste); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyArrowRight, gocui.ModNone, layout.SelectPaste); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlG, gocui.ModNone, layout.AbortPaste); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, quit); err != nil {
log.Panicln(err) log.Panicln(err)
} }
if err := g.SetKeybinding("", gocui.KeyCtrlR, gocui.ModNone, layout.SwitchModes); err != nil { if err := g.SetKeybinding("", gocui.KeyCtrlR, gocui.ModNone, layout.SwitchModes); err != nil {
log.Panicln(err) log.Panicln(err)
} }
@ -439,14 +441,18 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
printedLineLength := maxX - 4 printedLineLength := maxX - 4
selectedCommand := m.s.data[m.s.highlightedItem].cmdLine selectedCommand := m.s.data[m.s.highlightedItem].cmdLine
var statusLineHeight int = len(selectedCommand)/(printedLineLength) + 1 var statusLineHeight int = len(selectedCommand)/(printedLineLength) + 1
statusLineHeight++ // help line
m.s.displayedItemsCount = maxY - topBoxHeight - statusLineHeight helpLineHeight := 1
const helpLine = "HELP: type to search, UP/DOWN to select, RIGHT to edit, ENTER to execute, CTRL+G to abort, CTRL+C/D to quit; " +
"TIP: when resh-cli is launched command line is used as initial search query"
mainViewHeight := maxY - topBoxHeight - statusLineHeight - helpLineHeight
m.s.displayedItemsCount = mainViewHeight
var index int var index int
for index < len(data) { for index < len(data) {
itm := data[index] itm := data[index]
if index == maxY-topBoxHeight-statusLineHeight { if index == mainViewHeight {
// page is full // page is full
break break
} }
@ -472,7 +478,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
index++ index++
} }
// push the status line to the bottom of the page // push the status line to the bottom of the page
for index < maxY-topBoxHeight-statusLineHeight { for index < mainViewHeight {
v.WriteString("\n") v.WriteString("\n")
index++ index++
} }
@ -500,7 +506,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
idxSt += printedLineLength idxSt += printedLineLength
nextLine = true nextLine = true
} }
v.WriteString("HELP: type to search, UP/DOWN to select, RIGHT to edit, ENTER to execute, CTRL+G to abort, CTRL+C/D to quit") v.WriteString(helpLine)
if debug { if debug {
log.Println("len(data) =", len(m.s.data)) log.Println("len(data) =", len(m.s.data))
log.Println("highlightedItem =", m.s.highlightedItem) log.Println("highlightedItem =", m.s.highlightedItem)

Loading…
Cancel
Save