本文整理匯總了Golang中github.com/nsf/termbox-go.Close函數的典型用法代碼示例。如果您正苦於以下問題:Golang Close函數的具體用法?Golang Close怎麽用?Golang Close使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Close函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: draw
func draw() bool {
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
dots := NewCellsBox([]termbox.Cell{dot, dot, dot, dot, dot,
dot, dot, dot, dot, dot,
dot, dot, dot, dot, dot,
dot, dot, dot, dot, dot,
}, 5)
greenPlus := NewCellsBox([]termbox.Cell{greenPlus, greenPlus, greenPlus, greenPlus}, 2)
if err := greenPlus.DrawInto(dots, 1, 2); err != nil {
termbox.Close()
fmt.Fprintf(os.Stderr, "%v1\r\n", err)
return false
}
if err := dots.DrawInto(&TermBox{}, 0, 0); err != nil {
termbox.Close()
fmt.Fprintf(os.Stderr, "%v2\r\n", err)
return false
}
termbox.SetCell(0, 0, '+', termbox.ColorRed, termbox.ColorDefault)
termbox.SetCell(1, 0, '+', termbox.ColorRed, termbox.ColorDefault)
termbox.SetCell(7, 0, '+', termbox.ColorRed, termbox.ColorDefault)
termbox.Flush()
return true
}
示例2: error_out
func error_out(message string) {
tb.Close()
fmt.Print(message)
os.Exit(1)
}
示例3: Run
func (this *Game) Run() {
err := tb.Init()
if err != nil {
panic(err)
}
defer tb.Close()
tb.HideCursor()
this.Draw()
loop:
for {
switch ev := tb.PollEvent(); ev.Type {
case tb.EventKey:
switch ev.Key {
case tb.KeyEsc:
break loop
}
switch ev.Ch {
case 'h':
this.Player.Move(-1, 0)
case 'j':
this.Player.Move(0, 1)
case 'k':
this.Player.Move(0, -1)
case 'l':
this.Player.Move(1, 0)
}
}
this.Draw()
}
}
示例4: main
func main() {
err := tb.Init()
if err != nil {
panic(err)
}
defer tb.Close()
tb.SetInputMode(tb.InputEsc)
tb.Clear(tb.ColorCyan, tb.ColorBlue)
tb.Flush()
loop:
for i := 0; ; i++ {
ev := tb.PollEvent()
switch ev.Type {
case tb.EventKey:
if ev.Key == tb.KeyCtrlC {
break loop
}
tb.SetCell(i, i, ev.Ch, tb.ColorGreen, tb.ColorBlack)
tb.Flush()
case tb.EventError:
panic(ev.Err)
}
}
}
示例5: run
func (v *TermView) run() {
defer close(v.shutdown)
defer termbox.Close()
redraw := v.redraw.Reg()
defer v.redraw.UnReg(redraw)
v.draw()
for {
v.Debug("Waiting for update")
select {
case <-v.flush:
termbox.Flush()
case <-v.updates:
v.draw()
case <-redraw:
v.draw()
case <-v.shutdown:
return
}
}
}
示例6: main
func main() {
field := NewTextField(12, []rune(""), func(val string) bool {
return false
})
field1 := NewTextField(24, []rune(""), func(val string) bool { return true })
field2 := NewTextField(18, []rune(""), func(val string) bool { return true })
form = NewForm([]Field{
Label(field, "First text field, yeah!"),
Label(field1, "Second text field, accompanied by a whole load more words. Like at least nine words but probably more yeah. That's how many words we're going for anyway. This ought to do"),
Label(field2, "Third text field oh boy"),
})
err := termbox.Init()
defer termbox.Close()
if err != nil {
fmt.Println(err)
return
}
if draw() {
fmt.Fprintf(os.Stderr, "drew ok\r\n")
loop:
for {
ev := termbox.PollEvent()
if !form.HandleEvent(&ev) {
log.Print("Exiting because HandleEvent said so")
break loop
}
draw()
}
}
}
示例7: Run
func (f *Form) Run() error {
draw := func() bool {
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
f.DrawInto(&box.TermBox{}, 0, 0)
termbox.Flush()
return true
}
err := termbox.Init()
defer termbox.Close()
if err != nil {
return err
}
if draw() {
f.running = true
for f.running {
ev := termbox.PollEvent()
if !f.HandleEvent(&ev) {
f.running = false
}
draw()
}
} else {
return errors.New("fail sadness")
}
return nil
}
示例8: main
func main() {
flag.Parse()
log.SetFlags(0)
flog, err := os.Create("editor.log")
if err != nil {
log.Fatal(err)
}
defer flog.Close()
lg = log.New(flog, "", 0)
// start termbox
err = termbox.Init()
if err != nil {
log.Print(err)
return
}
defer termbox.Close()
v := &view.LineNum{View: &view.Wrap{}}
//v := &view.Wrap{}
s := &session.Session{
File: flag.Arg(0),
View: v,
ExpandTabs: false,
SmartIndent: true,
Tabwidth: 4,
}
// run ...
err = s.Run()
if err != session.ErrQuit {
lg.Print(err)
}
}
示例9: realMain
func realMain() error {
flag.Parse()
if err := termbox.Init(); err != nil {
return err
}
defer termbox.Close()
termbox.SetInputMode(termbox.InputEsc | termbox.InputMouse)
opts := &gameOpts{}
if *p1 == "" {
opts.p1type = computer
opts.p1name = "8086"
} else {
opts.p1type = human
opts.p1name = *p1
}
if *p2 == "" {
opts.p2type = computer
opts.p2name = "hal"
} else {
opts.p2type = human
opts.p2name = *p2
}
game := newGame(opts)
game.draw()
game.loop()
return nil
}
示例10: Handle
func (m *ExitMode) Handle(ev term.Event) {
if ev.Ch == 'y' {
saveLastPosition(m.f, m.cursor.l, m.cursor.b)
term.Close()
os.Exit(0)
} else if ev.Ch == 'n' || ev.Key == term.KeyCtrlK {
m.mode.ChangeTo(m.mode.normal)
}
}
示例11: main
func main() {
termbox.Init()
termbox.HideCursor()
var p Player
p = *NewPlayer()
p.Draw()
termbox.Flush()
<-time.After(2000 * time.Millisecond)
termbox.Close()
os.Exit(0)
}
示例12: main
func main() {
projection := false
if len(os.Args) > 1 {
if os.Args[1] == "-p" {
projection = true
}
}
tg.Init()
run(projection)
tg.Close()
}
示例13: main
func main() {
termbox.Init()
defer termbox.Close()
termbox.SetInputMode(termbox.InputEsc)
termbox.Flush()
for i := 0; i < 7; i++ {
switch ev := termbox.PollEvent(); ev.Type {
case termbox.EventKey:
fmt.Println(ev)
}
}
}
示例14: debug
func debug(args ...interface{}) {
term.Close()
for _, a := range args {
fmt.Println(a)
}
reader := bufio.NewReader(os.Stdin)
reader.ReadString('\n')
err := term.Init()
if err != nil {
panic(err)
}
term.SetInputMode(term.InputAlt)
}
示例15: run
func (v *TermView) run() {
defer v.ctl.Wait.Done()
defer termbox.Close()
for {
v.Debug("Waiting for update")
select {
case obj := <-v.updates:
v.state = obj.(ui.State)
v.Render()
case <-v.ctl.Shutdown:
return
}
}
}