This repository was archived by the owner on Apr 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrorui.go
More file actions
51 lines (44 loc) · 1.29 KB
/
errorui.go
File metadata and controls
51 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"github.com/jroimartin/gocui"
)
func errorfunc(g *gocui.Gui) error {
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
fmt.Println(err)
}
maxX, maxY := g.Size()
// Error Widget
if errorwid, err := g.SetView("errorwid", -1, -1, maxX, maxY-2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
if err := g.SetKeybinding("errorwid", gocui.KeyArrowLeft, gocui.ModNone, backtoSearch); err != nil {
return err
}
if err := g.SetKeybinding("errorwid", gocui.KeyEnter, gocui.ModNone, backtoSearch); err != nil {
return err
}
if err := g.SetKeybinding("errorwid", 'q', gocui.ModNone, quit); err != nil {
return err
}
if _, err := g.SetCurrentView("errorwid"); err != nil {
return err
}
errorwid.Frame = true
errorwid.Wrap = true
fmt.Fprint(errorwid, term_red, "Error! ->", term_res, "\n\n")
fmt.Fprintln(errorwid, string(errorui.Error()))
errorwid.MoveCursor(maxX-1, 0, true)
}
// Help Widget
if errorhelpwid, err := g.SetView("errorhelpwid", -1, maxY-2, maxX, maxY); err != nil {
if err != gocui.ErrUnknownView {
return err
}
errorhelpwid.Frame = true
errorhelpwid.Wrap = true
fmt.Fprintln(errorhelpwid, "Press <enter> / ← to go back to Search , Ctrl-c / (q) to Quit")
}
return nil
}