Skip to content

Commit

Permalink
Added shortuts bar
Browse files Browse the repository at this point in the history
  • Loading branch information
aQaTL committed Apr 30, 2018
1 parent ab17ed5 commit f3a833f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions fuzzyselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func fuzzySelectEntry(ctx *cli.Context) error {
const (
FsgInputView = "fsgInputView"
FsgOutputView = "fsgOutputView"
FsgShortcutsView = "fsgShortcutsView"
)

type fuzzySelGui struct {
Expand All @@ -81,7 +82,7 @@ type fuzzySelGui struct {

func (fsg *fuzzySelGui) Layout(gui *gocui.Gui) error {
w, h := gui.Size()
if v, err := gui.SetView(FsgInputView, 0, 0, w-1, h/7); err != nil {
if v, err := gui.SetView(FsgInputView, 0, 0, w-1, 2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
Expand All @@ -91,25 +92,36 @@ func (fsg *fuzzySelGui) Layout(gui *gocui.Gui) error {
v.Editable = true
v.Wrap = true

fsg.InputView = v
gui.SetCurrentView(FsgInputView)
fsg.InputView = v
}

if v, err := gui.SetView(FsgOutputView, 0, h/7+1, w-1, h-1); err != nil {
if v, err := gui.SetView(FsgOutputView, 0, 3, w-1, h-4); err != nil {
if err != gocui.ErrUnknownView {
return err
}

v.Title = "Found entries"
v.SelBgColor = gocui.ColorGreen
v.SelFgColor = gocui.ColorBlack
v.Highlight = true

v.Editable = true
v.Editor = gocui.EditorFunc(fsg.OutputViewEditor)

fsg.OutputView = v
}

if v, err := gui.SetView(FsgShortcutsView, 0, h-3, w-1, h-1); err != nil {
if err != gocui.ErrUnknownView {
return err
}

v.Title = "Shortcuts"
v.Editable = false

fmt.Fprintf(v, "Ctrl+C: quit | Tab: switch window | Enter: select highlighted entry")
}

return nil
}

Expand Down

0 comments on commit f3a833f

Please sign in to comment.