Skip to content

Commit e838d69

Browse files
committedMar 22, 2020
add a few common keybindings to cli
1 parent 22c338a commit e838d69

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
 

‎cmd/cli/main.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func runReshCli() (string, int) {
6363
if config.Debug {
6464
debug = true
6565
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
66+
log.Println("DEBUG is ON")
6667
}
6768

6869
sessionID := flag.String("sessionID", "", "resh generated session id")
@@ -120,6 +121,12 @@ func runReshCli() (string, int) {
120121
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
121122
log.Panicln(err)
122123
}
124+
if err := g.SetKeybinding("", gocui.KeyCtrlG, gocui.ModNone, quit); err != nil {
125+
log.Panicln(err)
126+
}
127+
if err := g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, quit); err != nil {
128+
log.Panicln(err)
129+
}
123130
if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, layout.SelectExecute); err != nil {
124131
log.Panicln(err)
125132
}
@@ -559,20 +566,27 @@ func (m manager) Layout(g *gocui.Gui) error {
559566

560567
for i, itm := range m.s.data {
561568
if i == maxY {
562-
log.Println(maxY)
569+
if debug {
570+
log.Println(maxY)
571+
}
563572
break
564573
}
565574
displayStr := itm.display
566575
if m.s.highlightedItem == i {
567576
// use actual min requried length instead of 420 constant
568577
displayStr = doHighlightString(displayStr, 420)
569-
log.Println("### HightlightedItem string :", displayStr)
570-
} else {
578+
if debug {
579+
log.Println("### HightlightedItem string :", displayStr)
580+
}
581+
} else if debug {
571582
log.Println(displayStr)
572583
}
573584
if strings.Contains(displayStr, "\n") {
574585
log.Println("display string contained \\n")
575586
displayStr = strings.ReplaceAll(displayStr, "\n", "#")
587+
if debug {
588+
log.Println("display string contained \\n")
589+
}
576590
}
577591
v.WriteString(displayStr + "\n")
578592
// if m.s.highlightedItem == i {

0 commit comments

Comments
 (0)