Documentation ¶
Index ¶
- Constants
- func Abs(a int) int
- func Hash(column, row int) int
- func Height(p1, p2 *Position) int
- func Max(x, y int) int
- func Min(x, y int) int
- func UnHash(hash int) (int, int)
- func UnHashNeg(hash int) (int, int)
- func Width(p1, p2 *Position) int
- type ButtonMask
- type Death
- type Engine
- type InputListener
- type Key
- type KeyDispatcher
- type KeyEvent
- type KeyListener
- type Lifecycler
- type ModMask
- type MouseDispatcher
- type MouseEvent
- type MouseListener
- type Pixel
- type PixelGetter
- type PixelSetter
- type Position
- type ResizeDispatcher
- type ResizeEvent
- type ResizeListener
- type Size
- type Style
- type Unicode
Constants ¶
const (
MinusOneMinusOne = 4294967295
)
Variables ¶
This section is empty.
Functions ¶
func Hash ¶
Hash - combines a row and a column into a single integer. Note that it doesn't work with very large numbers.
func UnHash ¶
UnHash - given a hash built with above function, return the original column and row. Note that negative values are not returned correctly. Use UnHashNeg below.
Types ¶
type ButtonMask ¶
type ButtonMask int16
ButtonMask is a mask of mouse buttons and wheel events. Mouse button presses are normally delivered as both press and release events. Mouse wheel events are normally just single impulse events. Windows supports up to eight separate buttons plus all four wheel directions, but XTerm can only support mouse buttons 1-3 and wheel up/down. Its not unheard of for terminals to support only one or two buttons (think Macs). Old terminals, and true emulations (such as vt100) won't support mice at all, of course.
type Death ¶
type Death interface {
DyingChan() chan struct{}
}
Death is provided by both dispatchers and receivers
type Engine ¶
type Engine interface { Death // returns the chan that creator needs to be listen for graceful shutdown Start(ctx context.Context) error // returns error if we cannot start ResizeDispatcher() ResizeDispatcher // returns the event dispatcher, so listeners can call Register(r Receiver) method KeyDispatcher() KeyDispatcher // returns the event dispatcher, so listeners can call Register(r Receiver) method MouseDispatcher() MouseDispatcher // returns the event dispatcher, so listeners can call Register(r Receiver) method CanDisplay(r rune, checkFallbacks bool) bool // checks if a rune can be displayed CharacterSet() string // getter for current charset SetRuneFallback(orig rune, fallback string) // sets a fallback for a rune UnsetRuneFallback(orig rune) // forgets fallback for a rune NumColors() int // returns the number of colors of the current display Size() *Size // returns the size of the current display HasTrueColor() bool // returns true if can display true color Style() Style // returns the terminal styles and palette ActivePixels(pixels []PixelGetter) // registers the active pixels, forgetting the old ones. This behaviour should be found in Pages Redraw(pixels []PixelGetter) // does a buffered redraw of the screen (TODO : should not be used) ShowCursor(where *Position) // shows the cursor at the indicated position HideCursor() // hides the cursor Cursor() *Position // returns the cursor current position Clear() // cleans the screen HasMouse() bool // returns true if mouse support is available }
Engine is the interface of the core
type InputListener ¶
type InputListener interface {
InChan() chan []byte
}
InputListener is implemented by MouseDispatcher and KeyDispatcher
type Key ¶
type Key int16
Key is a generic value for representing keys, and especially special keys (function keys, cursor movement keys, etc.) For normal keys, like ASCII letters, we use Rune, and then expect the application to inspect the Rune() member of the KeyEvent.
type KeyDispatcher ¶
type KeyDispatcher interface { Death InputListener Lifecycler Register(r KeyListener) HasKey(k Key) bool }
we hide our implementation behind this interface
type KeyListener ¶
KeyListener must be implementers of KeyEvent
type Lifecycler ¶
Lifecycler implements a context cancel listener
type ModMask ¶
type ModMask int16
ModMask is a mask of modifier keys. Note that it will not always be possible to report modifier keys.
type MouseDispatcher ¶
type MouseDispatcher interface { ResizeListener InputListener Lifecycler Register(r MouseListener) Enable() Disable() }
MouseDispatcher is implemented in mouse package
type MouseEvent ¶
type MouseEvent interface { Buttons() ButtonMask Modifiers() ModMask Position() (int, int) ButtonNames() string ModName() string }
MouseEvent is an interface that is implemented by mouse package
type MouseListener ¶
type MouseListener interface { Death MouseListen() chan MouseEvent }
MouseListener is implemented by listeners of mouse events
type Pixel ¶
type Pixel interface { PixelGetter PixelSetter }
type PixelGetter ¶
type PixelGetter interface { DrawCh() chan PixelGetter // channel which tells core that pixel needs drawing PositionHash() int // position (x,y) where is pixel is placed Style() (color.Color, color.Color, style.Mask) // style (background and foreground colors, attributes) Rune() rune // the rune pixel contains Width() int // the width of the rune, usually is 1, but unicode adds more to it HasUnicode() bool // helper for not reading unicode everytime Unicode() *Unicode // if unicode, it adds to the rune }
PixelGetter is the complete interface (both setter and getter)
type PixelSetter ¶
type PixelSetter interface { Set(r rune, fg, bg color.Color) // sets both colors and rune so we don't do three calls SetFgBg(fg, bg color.Color) // sets both colors, so we don't do two calls (usually only if the colors have changed) SetForeground(c color.Color) // as name says SetBackground(c color.Color) // as name says SetAttrs(m style.Mask) // as name says SetUnicode(u Unicode) // as name says SetRune(r rune) // sets the content of the pixel and triggers redrawing SetAll(bg, fg color.Color, m style.Mask, r rune, u Unicode) // in case we need to call all changes, without placing too many calls }
PixelSetter is the complete interface (both setter and getter)
type Position ¶
func (*Position) UpdateHash ¶
func (p *Position) UpdateHash()
UpdateHash - refreshes the hash on row/column change
type ResizeDispatcher ¶
type ResizeDispatcher interface { Death Register(r ResizeListener) }
ResizeDispatcher is implemented by core engine
type ResizeEvent ¶
type ResizeEvent interface {
Size() *Size
}
ResizeEvent is an interface that implemented by core
type ResizeListener ¶
type ResizeListener interface { Death ResizeListen() chan ResizeEvent }
ResizeListener is for listeners that must implement this interface
type Size ¶
type Size struct { Columns int // The number of units along the horizontal axis. Rows int // The number of units along the vertical axis. }
Size describes something with width and height.
func (*Size) Add ¶
Add returns a new Size that is the result of increasing the current size by s2 Width and Height.
Directories ¶
Path | Synopsis |
---|---|
The colorful package provides all kinds of functions for working with colors.
|
The colorful package provides all kinds of functions for working with colors. |
Package easing is a go implementation of Robert Penner's Easing Equations - http://robertpenner.com/easing/
|
Package easing is a go implementation of Robert Penner's Easing Equations - http://robertpenner.com/easing/ |
playground
|
|