Skip to content

Commit 9265e09

Browse files
committedMay 4, 2020
add help under status line
1 parent 6539748 commit 9265e09

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎cmd/cli/main.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,19 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
434434
m.s.highlightedItem = len(m.s.data) - 1
435435
}
436436
// status line
437-
topBoxSize := 3 // size of the query box up top
437+
topBoxHeight := 3 // size of the query box up top
438438
realLineLength := maxX - 2
439439
printedLineLength := maxX - 4
440440
selectedCommand := m.s.data[m.s.highlightedItem].cmdLine
441-
var selectedLineCount int = len(selectedCommand)/(printedLineLength) + 1
441+
var statusLineHeight int = len(selectedCommand)/(printedLineLength) + 1
442+
statusLineHeight++ // help line
442443

443-
m.s.displayedItemsCount = maxY - topBoxSize - selectedLineCount
444+
m.s.displayedItemsCount = maxY - topBoxHeight - statusLineHeight
444445

445446
var index int
446447
for index < len(data) {
447448
itm := data[index]
448-
if index == maxY-topBoxSize-selectedLineCount {
449+
if index == maxY-topBoxHeight-statusLineHeight {
449450
// page is full
450451
break
451452
}
@@ -471,7 +472,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
471472
index++
472473
}
473474
// push the status line to the bottom of the page
474-
for index < maxY-topBoxSize-selectedLineCount {
475+
for index < maxY-topBoxHeight-statusLineHeight {
475476
v.WriteString("\n")
476477
index++
477478
}
@@ -499,6 +500,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
499500
idxSt += printedLineLength
500501
nextLine = true
501502
}
503+
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")
502504
if debug {
503505
log.Println("len(data) =", len(m.s.data))
504506
log.Println("highlightedItem =", m.s.highlightedItem)

0 commit comments

Comments
 (0)