nirvana

package
v0.20.12 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorDefault uint64 = iota << 48
	ColorBlack
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
)
View Source
const (
	ColorDD uint64 = iota << 48
	ColorBB
	ColorBR
	ColorBG
	ColorBY
	ColorBX
	ColorBM
	ColorBC
	ColorBW // BLACK    B //
	ColorRB
	ColorRR
	ColorRG
	ColorRY
	ColorRX
	ColorRM
	ColorRC
	ColorRW // RED      R //
	ColorGB
	ColorGR
	ColorGG
	ColorGY
	ColorGX
	ColorGM
	ColorGC
	ColorGW // GREEN    G //
	ColorYB
	ColorYR
	ColorYG
	ColorYY
	ColorYX
	ColorYM
	ColorYC
	ColorYW // YELLOW   Y //
	ColorXB
	ColorXR
	ColorXG
	ColorXY
	ColorXX
	ColorXM
	ColorXC
	ColorXW // BLUE     X //
	ColorMB
	ColorMR
	ColorMG
	ColorMY
	ColorMX
	ColorMM
	ColorMC
	ColorMW // MAGENTA  M //
	ColorCB
	ColorCR
	ColorCG
	ColorCY
	ColorCX
	ColorCM
	ColorCC
	ColorCW // CYAN     C //
	ColorWB
	ColorWR
	ColorWG
	ColorWY
	ColorWX
	ColorWM
	ColorWC
	ColorWW // WHITE    W //
)
View Source
const (
	Bold uint64 = 1 << (57 + iota)
	Underline
	Reverse
	// Blink
	Normal uint64 = 0
)
View Source
const (
	Ctrl uint64 = 1 << (32 + iota)
	Alt
	Shift
)
View Source
const (
	KeyF1 uint64 = 0xFFFFFFFF - iota
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyInsert
	KeyDelete
	KeyHome
	KeyEnd
	KeyPgup
	KeyPgdn
	KeyArrowUp
	KeyArrowDown
	KeyArrowLeft
	KeyArrowRight
	Mouse
	MouseLeft
	MouseMiddle
	MouseRight
	MouseRelease
	MouseWheelUp
	MouseWheelDown
	KeyCtrlTilde
	KeyCtrl2
	KeyBackspace
	KeyBackspace2
	KeyTab   uint64 = '\t'
	KeyEnter uint64 = '\n'
	KeyEsc   uint64 = 27
)
View Source
const (
	Mouse1_PRESSED = 0
	Mouse1_RELEASED
	Mouse1_CLICKED
	Mouse1_DOUBLE_CLICKED
	Mouse1_TRIPLE_CLICKED
	Mouse2_PRESSED
	Mouse2_RELEASED
	Mouse2_CLICKED
	Mouse2_DOUBLE_CLICKED
	Mouse2_TRIPLE_CLICKED
	Mouse3_PRESSED
	Mouse3_RELEASED
	Mouse3_CLICKED
	Mouse3_DOUBLE_CLICKED
	Mouse3_TRIPLE_CLICKED
	Mouse4_PRESSED
	Mouse4_RELEASED
	Mouse4_CLICKED
	Mouse4_DOUBLE_CLICKED
	Mouse4_TRIPLE_CLICKED
)
View Source
const (
	Right int = iota
	Up
	Left
	Down
	DownRight
	DownLeft
	UpRight
	UpLeft
	PgUp
	PgDown
	Start
	End
)

Variables

View Source
var Colors = [256]FontFace{
	{Fg: termColorDefault, Bg: termColorDefault},
	{Fg: termColorBlack, Bg: termColorBlack}, {Fg: termColorRed, Bg: termColorBlack}, {Fg: termColorGreen, Bg: termColorBlack}, {Fg: termColorYellow, Bg: termColorBlack}, {Fg: termColorBlue, Bg: termColorBlack}, {Fg: termColorMagenta, Bg: termColorBlack}, {Fg: termColorCyan, Bg: termColorBlack}, {Fg: termColorWhite, Bg: termColorBlack},
	{Fg: termColorBlack, Bg: termColorRed}, {Fg: termColorRed, Bg: termColorRed}, {Fg: termColorGreen, Bg: termColorRed}, {Fg: termColorYellow, Bg: termColorRed}, {Fg: termColorBlue, Bg: termColorRed}, {Fg: termColorMagenta, Bg: termColorRed}, {Fg: termColorCyan, Bg: termColorRed}, {Fg: termColorWhite, Bg: termColorRed},
	{Fg: termColorBlack, Bg: termColorGreen}, {Fg: termColorRed, Bg: termColorGreen}, {Fg: termColorGreen, Bg: termColorGreen}, {Fg: termColorYellow, Bg: termColorGreen}, {Fg: termColorBlue, Bg: termColorGreen}, {Fg: termColorMagenta, Bg: termColorGreen}, {Fg: termColorCyan, Bg: termColorGreen}, {Fg: termColorWhite, Bg: termColorGreen},
	{Fg: termColorBlack, Bg: termColorYellow}, {Fg: termColorRed, Bg: termColorYellow}, {Fg: termColorGreen, Bg: termColorYellow}, {Fg: termColorYellow, Bg: termColorYellow}, {Fg: termColorBlue, Bg: termColorYellow}, {Fg: termColorMagenta, Bg: termColorYellow}, {Fg: termColorCyan, Bg: termColorYellow}, {Fg: termColorWhite, Bg: termColorYellow},
	{Fg: termColorBlack, Bg: termColorBlue}, {Fg: termColorRed, Bg: termColorBlue}, {Fg: termColorGreen, Bg: termColorBlue}, {Fg: termColorYellow, Bg: termColorBlue}, {Fg: termColorBlue, Bg: termColorBlue}, {Fg: termColorMagenta, Bg: termColorBlue}, {Fg: termColorCyan, Bg: termColorBlue}, {Fg: termColorWhite, Bg: termColorBlue},
	{Fg: termColorBlack, Bg: termColorMagenta}, {Fg: termColorRed, Bg: termColorMagenta}, {Fg: termColorGreen, Bg: termColorMagenta}, {Fg: termColorYellow, Bg: termColorMagenta}, {Fg: termColorBlue, Bg: termColorMagenta}, {Fg: termColorMagenta, Bg: termColorMagenta}, {Fg: termColorCyan, Bg: termColorMagenta}, {Fg: termColorWhite, Bg: termColorMagenta},
	{Fg: termColorBlack, Bg: termColorCyan}, {Fg: termColorRed, Bg: termColorCyan}, {Fg: termColorGreen, Bg: termColorCyan}, {Fg: termColorYellow, Bg: termColorCyan}, {Fg: termColorBlue, Bg: termColorCyan}, {Fg: termColorMagenta, Bg: termColorCyan}, {Fg: termColorCyan, Bg: termColorCyan}, {Fg: termColorWhite, Bg: termColorCyan},
	{Fg: termColorBlack, Bg: termColorWhite}, {Fg: termColorRed, Bg: termColorWhite}, {Fg: termColorGreen, Bg: termColorWhite}, {Fg: termColorYellow, Bg: termColorWhite}, {Fg: termColorBlue, Bg: termColorWhite}, {Fg: termColorMagenta, Bg: termColorWhite}, {Fg: termColorCyan, Bg: termColorWhite}, {Fg: termColorWhite, Bg: termColorWhite},
}
View Source
var ErrTooLarge = errors.New("Cells.CellBuffer: too large")

ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.

Functions

func Close

func Close()

func Hline

func Hline(y, x, width int, fontFace FontFace)

func Napms

func Napms(ms uint)

func SetFontFace

func SetFontFace(cPair uint8, Bg, Fg uint64)

func Show

func Show(doc *katana.Doc)

func Size

func Size() (height, width int)

func ToCustomU64

func ToCustomU64(str string, color uint64) (result []uint64)

func Vline

func Vline(y, x, width int, fontFace FontFace)

Types

type Cell

type Cell struct {
	Ch    rune
	Color uint8
	Attrs uint8
	Touch bool
}

func CustomFontify

func CustomFontify(m katana.Markup, color uint64) []Cell

func StrToCells

func StrToCells(str string, color, attrs uint8) []Cell

type CellBuffer

type CellBuffer struct {
	// contains filtered or unexported fields
}

A Buffer is a variable-sized buffer of Cell with Read and Write methods. The zero value for Buffer is an empty buffer ready to use.

func (*CellBuffer) Cap

func (b *CellBuffer) Cap() int

Cap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.

func (*CellBuffer) Data

func (b *CellBuffer) Data() []Cell

Bytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like Read, Write, Reset, or Truncate). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads.

func (*CellBuffer) Grow

func (b *CellBuffer) Grow(n int)

Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with ErrTooLarge.

func (*CellBuffer) Len

func (b *CellBuffer) Len() int

Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).

func (*CellBuffer) Next

func (b *CellBuffer) Next(n int) []Cell

Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by Read. If there are fewer than n bytes in the buffer, Next returns the entire buffer. The slice is only valid until the next call to a read or write method.

func (*CellBuffer) ReadFrom

func (b *CellBuffer) ReadFrom(r CellBuffer) (n int, err error)

func (*CellBuffer) Reset

func (b *CellBuffer) Reset()

Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as Truncate(0).

func (*CellBuffer) SetFace

func (b *CellBuffer) SetFace(face uint64)

func (*CellBuffer) String

func (b *CellBuffer) String() (str string)

String returns the contents of the unread portion of the buffer as a string. If the CellBuffer is a nil pointer, it returns "<nil>".

func (*CellBuffer) Truncate

func (b *CellBuffer) Truncate(n int)

Truncate discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It panics if n is negative or greater than the length of the buffer.

func (*CellBuffer) Write

func (b *CellBuffer) Write(p []Cell) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.

func (*CellBuffer) WriteRune

func (b *CellBuffer) WriteRune(r rune) error

func (*CellBuffer) WriteString

func (b *CellBuffer) WriteString(s string) (n int, err error)

WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with ErrTooLarge.

func (*CellBuffer) WriteU64

func (b *CellBuffer) WriteU64(u uint64) error

type FontFace

type FontFace struct {
	Bg, Fg, Attrs uint8
}

type Gps

type Gps struct {
	Y, X int
}

type Pad

type Pad struct {
	Buffer [][]Cell
	Curs   Gps
	Frame  Gps

	Color uint8
	Attrs uint8

	AutoFill bool

	Screen *Window
	// contains filtered or unexported fields
}

func NewPad

func NewPad(w *Window) *Pad

func (*Pad) AddCell

func (p *Pad) AddCell(cell Cell)

func (*Pad) AddCells

func (p *Pad) AddCells(cells []Cell)

func (*Pad) AddCenterCells

func (p *Pad) AddCenterCells(cells []Cell, leftMargin uint)

func (*Pad) AddCh

func (p *Pad) AddCh(ch uint64)

func (*Pad) AddChs

func (p *Pad) AddChs(ch []uint64)

func (*Pad) AddLeftCells

func (p *Pad) AddLeftCells(cells []Cell, width, leftMargin uint)

func (*Pad) AddPreCells

func (p *Pad) AddPreCells(cells []Cell, leftMargin uint)

func (*Pad) AddRightCells

func (p *Pad) AddRightCells(cells []Cell, leftMargin, rightMargin uint)

func (*Pad) AddRune

func (p *Pad) AddRune(r rune)

func (*Pad) AddStr

func (p *Pad) AddStr(str string)

func (*Pad) CustomFontify

func (p *Pad) CustomFontify(m katana.Markup, color uint64)

func (*Pad) Draw

func (p *Pad) Draw()

func (*Pad) GetDefaultCell

func (p *Pad) GetDefaultCell() Cell

func (*Pad) Mv

func (p *Pad) Mv(y, x int)

func (*Pad) ParseMorg

func (p *Pad) ParseMorg(doc *katana.Doc)

func (*Pad) Scroll

func (p *Pad) Scroll(dir int)

func (*Pad) SetCell

func (p *Pad) SetCell(cell Cell)

func (*Pad) SetCells

func (p *Pad) SetCells(cells []Cell)

func (*Pad) SetFace

func (p *Pad) SetFace(face uint64)

func (*Pad) Shoot

func (p *Pad) Shoot(y, x int, cell Cell)

func (*Pad) Shooter

func (p *Pad) Shooter(y, x int, cells []Cell)

func (*Pad) StrToCells

func (p *Pad) StrToCells(str string) []Cell

type Window

type Window struct {
	Height, Width int // maximums of x and y, NOT window size
	CurY, CurX    int // current cursor position
	InitY, InitX  int // screen coords of upper-left-hand corner

	Color  uint8
	Attrs  uint8
	BGChar rune // current background char

	Buffer [][]Cell

	Looper bool
	Scroll bool
	Touch  bool
	Echo   bool
	Curs   bool
	Delay  bool
	Resize bool
}

func Init

func Init() (*Window, error)

func NewWindow

func NewWindow(height, width, yPos, xPos int) *Window

func (*Window) AddCell

func (w *Window) AddCell(cell Cell)

func (*Window) AddCells

func (w *Window) AddCells(cells []Cell)

func (*Window) AddCh

func (w *Window) AddCh(chtype uint64)

func (*Window) AddChs

func (w *Window) AddChs(chs []uint64)

func (*Window) AddStr

func (w *Window) AddStr(str string)

func (*Window) Attroff

func (w *Window) Attroff(attrs uint64)

func (*Window) Attron

func (w *Window) Attron(attrs uint64)

func (*Window) Box

func (w *Window) Box()

func (*Window) ChFace

func (w *Window) ChFace(face uint64)

func (*Window) Clear

func (w *Window) Clear()

func (*Window) CursSet

func (w *Window) CursSet(visibility bool)

func (*Window) Draw

func (w *Window) Draw()

func (*Window) GetDefaultCell

func (w *Window) GetDefaultCell() Cell

func (*Window) GetFace

func (w *Window) GetFace() (ff FontFace)

func (*Window) Getch

func (w *Window) Getch() uint64

func (*Window) Hline

func (w *Window) Hline(y, x, width int)

func (*Window) Mv

func (w *Window) Mv(y, x int) (err bool)

func (*Window) MvAddCells

func (w *Window) MvAddCells(y, x int, cells []Cell) (err bool)

func (*Window) MvAddCh

func (w *Window) MvAddCh(y, x int, chtype uint64) (err bool)

func (*Window) MvAddChs

func (w *Window) MvAddChs(y, x int, chs []uint64) (err bool)

func (*Window) MvChFace

func (w *Window) MvChFace(y, x int, face uint64) (err bool)

func (*Window) Refresh

func (w *Window) Refresh()

func (*Window) SetAttrs

func (w *Window) SetAttrs(attrs uint64)

func (*Window) SetColor

func (w *Window) SetColor(face uint64)

func (*Window) SetFace

func (w *Window) SetFace(face uint64)

func (*Window) Size

func (w *Window) Size() (height, width int)

func (*Window) StrToCells

func (w *Window) StrToCells(str string) []Cell

func (*Window) ValidPos

func (w *Window) ValidPos(pos Gps) bool

int getmouse(MEVENT *event); void getparyx(WINDOW *win, int y, int x); int getstr(char *str); int getnstr(char *str, int n); int halfdelay(int tenths); bool has_colors(void); int hline(chtype ch, int n); void idcok(WINDOW *win, bool bf); void immedok(WINDOW *win, bool bf); chtype inch(void); chtype winch(WINDOW *win); chtype mvinch(int y, int x); chtype mvwinch(WINDOW *win, int y, int x); bool mouse_trafo(int* pY, int* pX, bool to_screen); bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen); int notimeout(WINDOW *win, bool bf); int overlay(const WINDOW *srcwin, WINDOW *dstwin); int raw(void); int noraw(void); int ungetch(int ch); int untouchwin(WINDOW *win); int vline(chtype ch, int n);

func (*Window) Vline

func (w *Window) Vline(y, x, width int)

Jump to

Keyboard shortcuts

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