當前位置: 首頁>>代碼示例>>Golang>>正文


Golang termbox-go.Close函數代碼示例

本文整理匯總了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
}
開發者ID:telyn,項目名稱:form,代碼行數:29,代碼來源:main.go

示例2: error_out

func error_out(message string) {

	tb.Close()
	fmt.Print(message)
	os.Exit(1)

}
開發者ID:nickaubert,項目名稱:grin,代碼行數:7,代碼來源:grin.go

示例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()
	}
}
開發者ID:nmuth,項目名稱:dastardly-go,代碼行數:35,代碼來源:game.go

示例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)
		}
	}
}
開發者ID:rbonvall,項目名稱:ejemplos-go,代碼行數:26,代碼來源:termbox.go

示例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
		}
	}
}
開發者ID:0x19,項目名稱:ngrok,代碼行數:25,代碼來源:view.go

示例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()
		}
	}

}
開發者ID:telyn,項目名稱:form,代碼行數:33,代碼來源:main.go

示例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
}
開發者ID:telyn,項目名稱:form,代碼行數:28,代碼來源:form.go

示例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)
	}
}
開發者ID:rwcarlsen,項目名稱:editor,代碼行數:35,代碼來源:main.go

示例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
}
開發者ID:igungor,項目名稱:bingo,代碼行數:28,代碼來源:main.go

示例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)
	}
}
開發者ID:kybin,項目名稱:tor,代碼行數:9,代碼來源:exitmode.go

示例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)
}
開發者ID:pjschlic,項目名稱:gorogue,代碼行數:11,代碼來源:main.go

示例12: main

func main() {
	projection := false
	if len(os.Args) > 1 {
		if os.Args[1] == "-p" {
			projection = true
		}
	}
	tg.Init()
	run(projection)
	tg.Close()
}
開發者ID:cruatta,項目名稱:drawille-go,代碼行數:11,代碼來源:rotating_cube.go

示例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)
		}
	}
}
開發者ID:CasualSuperman,項目名稱:dfc,代碼行數:15,代碼來源:test_input.go

示例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)
}
開發者ID:kybin,項目名稱:tor,代碼行數:15,代碼來源:debug.go

示例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
		}
	}
}
開發者ID:kyleconroy,項目名稱:ngrok,代碼行數:16,代碼來源:view.go


注:本文中的github.com/nsf/termbox-go.Close函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。