tbw

package module
v0.0.0-...-635d137 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2015 License: MIT Imports: 1 Imported by: 0

README

#tbw

Interface and API wrapper for termbox-go.

##Use case

Testing and abstraction.

##Example

import (
    tbw "github.com/morcmarc/termbox-wrapper"
)

type MyApp struct {
    TBInstance tbw.TermboxApi
}

// In source file
func main() {
    // NewTermboxWrapper() will return a dummy struct that delegates all calls,
    // just like if you'd be using termbox directly.
    tbwrapper := tbw.NewTermboxWrapper()
    ma := &MyApp{
      TBInstance: tbwrapper
    }
}

// In tests
// You can mock out the termbox depenceny and add your own method
// implementations.
type TBMock struct {
    tbw.TermboxApi
}

func (tbm TBMock) Init() error {
    ...
}

...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TermboxApi

type TermboxApi interface {
	Init() error
	Interrupt()
	Close()
	Flush()
	SetCursor(x, y int)
	HideCursor()
	SetCell(x, y int, ch rune, fg, bg termbox.Attribute)
	CellBuffer() []termbox.Cell
	ParseEvent(data []byte) termbox.Event
	PollRawEvent(data []byte) termbox.Event
	PollEvent() termbox.Event
	Size() (int, int)
	Clear(fg, bg termbox.Attribute) error
	SetInputMode(mode termbox.InputMode) termbox.InputMode
	SetOutputMode(mode termbox.OutputMode) termbox.OutputMode
	Sync() error
}

type TermboxWrapper

type TermboxWrapper struct {
	TermboxApi
}

func NewTermboxWrapper

func NewTermboxWrapper() *TermboxWrapper

func (TermboxWrapper) CellBuffer

func (t TermboxWrapper) CellBuffer() []termbox.Cell

func (TermboxWrapper) Clear

func (t TermboxWrapper) Clear(fg, bg termbox.Attribute) error

func (TermboxWrapper) Close

func (t TermboxWrapper) Close()

func (TermboxWrapper) Flush

func (t TermboxWrapper) Flush()

func (TermboxWrapper) HideCursor

func (t TermboxWrapper) HideCursor()

func (TermboxWrapper) Init

func (t TermboxWrapper) Init() error

func (TermboxWrapper) Interrupt

func (t TermboxWrapper) Interrupt()

func (TermboxWrapper) ParseEvent

func (t TermboxWrapper) ParseEvent(data []byte) termbox.Event

func (TermboxWrapper) PollEvent

func (t TermboxWrapper) PollEvent() termbox.Event

func (TermboxWrapper) PollRawEvent

func (t TermboxWrapper) PollRawEvent(data []byte) termbox.Event

func (TermboxWrapper) SetCell

func (t TermboxWrapper) SetCell(x, y int, ch rune, fg, bg termbox.Attribute)

func (TermboxWrapper) SetCursor

func (t TermboxWrapper) SetCursor(x, y int)

func (TermboxWrapper) SetInputMode

func (t TermboxWrapper) SetInputMode(mode termbox.InputMode) termbox.InputMode

func (TermboxWrapper) SetOutputMode

func (t TermboxWrapper) SetOutputMode(mode termbox.OutputMode) termbox.OutputMode

func (TermboxWrapper) Size

func (t TermboxWrapper) Size() (int, int)

func (TermboxWrapper) Sync

func (t TermboxWrapper) Sync() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL