-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfill_in_blank.go
37 lines (29 loc) · 1 KB
/
fill_in_blank.go
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
package quiz
import (
"github.com/crazcalm/term-quiz/interface"
"github.com/crazcalm/term-quiz/questions"
"github.com/jroimartin/gocui"
"log"
)
//FBInit -- Initializes the Fill in the Blank gui interface
func FBInit(g *gocui.Gui, q *questions.Question, count string) (err error) {
//The Answers
as := q.Answers
//Highlight the selected view and make it green
g.Highlight = true
g.SelFgColor = gocui.ColorGreen
//Add content to gui
questionFrame := gui.NewQuestionFrame("questionFrame")
question := gui.NewQuestion("question", count, q.Question)
answerBlank := gui.NewAnswer(gui.BoxBlank, gui.BoxBlank, as.Answers[0].Answer)
infoBar := gui.NewInfoBar(gui.InfoBarName, gui.InfoBarFillInBlank)
g.SetManager(questionFrame, question, answerBlank, infoBar)
//Add keybindings
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, gui.Quit); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, FillInAnswer); err != nil {
log.Panicln(err)
}
return nil
}