Documentation ¶
Index ¶
- func DeviceScale() float64
- func GetFontDPI() float64
- func LoadFace(file string, dpi float64, size float64) (font.Face, error)
- func LoadFaceBytes(file []byte, dpi float64, size float64) (font.Face, error)
- func SysKill()
- type ChangeScrollingRegionSeq
- type ConcurrentRW
- type CursorBackSeq
- type CursorDownSeq
- type CursorForwardSeq
- type CursorHideSeq
- type CursorHorizontalSeq
- type CursorNextLineSeq
- type CursorPositionSeq
- type CursorPreviousLineSeq
- type CursorShowSeq
- type CursorUpSeq
- type DeleteLineSeq
- type EmptyAdapter
- type EraseDisplaySeq
- type EraseLineSeq
- type FontWeight
- type Fonts
- type GridCell
- type InputAdapter
- type InsertLineSeq
- type KeyPress
- type MouseButton
- type MouseMotion
- type MouseWheel
- type RestoreCursorPositionSeq
- type SGRBgColor
- type SGRBgTrueColor
- type SGRBold
- type SGRFgColor
- type SGRFgTrueColor
- type SGRItalic
- type SGRReset
- type SGRUnsetBold
- type SGRUnsetItalic
- type SaveCursorPositionSeq
- type ScrollDownSeq
- type ScrollUpSeq
- type Window
- func (g *Window) Draw(screen *ebiten.Image)
- func (g *Window) GetCellsHeight() int
- func (g *Window) GetCellsWidth() int
- func (g *Window) InvalidateBuffer()
- func (g *Window) Kill()
- func (g *Window) Layout(outsideWidth, outsideHeight int) (int, int)
- func (g *Window) PrintChar(r rune, fg, bg color.Color, weight FontWeight)
- func (g *Window) RecalculateBackgrounds()
- func (g *Window) ResetSGR()
- func (g *Window) Run(title string) error
- func (g *Window) RunWithOptions(options ...WindowOption) error
- func (g *Window) SetBg(x, y int, c color.Color)
- func (g *Window) SetBgPixels(x, y int, c color.Color)
- func (g *Window) SetCursorChar(char string)
- func (g *Window) SetCursorColor(color color.Color)
- func (g *Window) SetOnPostDraw(fn func(screen *ebiten.Image))
- func (g *Window) SetOnPreDraw(fn func(screen *ebiten.Image))
- func (g *Window) SetOnUpdate(fn func())
- func (g *Window) SetShader(shader ...shader.Shader)
- func (g *Window) SetShowCursor(val bool)
- func (g *Window) ShowTPS(val bool)
- func (g *Window) Update() error
- type WindowOption
- type WindowSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeviceScale ¶ added in v0.0.9
func DeviceScale() float64
DeviceScale returns the current device scale factor.
If the environment variable CRT_DEVICE_SCALE is set, it will be used instead.
func GetFontDPI ¶ added in v0.0.9
func GetFontDPI() float64
GetFontDPI returns the recommended font DPI for the current device.
func LoadFace ¶
LoadFace loads a font face from a file. The dpi and size are used to generate the font face. Supports ttf and otf.
Example: LoadFace("./fonts/Mono-Regular.ttf", 72.0, 16.0)
func LoadFaceBytes ¶ added in v0.0.4
LoadFaceBytes loads a font face from bytes. The dpi and size are used to generate the font face. The normal, bold, and italic files must be provided. Supports ttf and otf.
Types ¶
type ConcurrentRW ¶
type ConcurrentRW struct {
// contains filtered or unexported fields
}
ConcurrentRW is a concurrent read/write buffer via channels.
func NewConcurrentRW ¶
func NewConcurrentRW() *ConcurrentRW
NewConcurrentRW creates a new concurrent read/write buffer.
func (*ConcurrentRW) Read ¶
func (rw *ConcurrentRW) Read(p []byte) (n int, err error)
Read reads data from the buffer.
func (*ConcurrentRW) Run ¶
func (rw *ConcurrentRW) Run()
Run starts the concurrent read/write buffer.
type CursorBackSeq ¶
type CursorBackSeq struct {
Count int
}
type CursorDownSeq ¶
type CursorDownSeq struct {
Count int
}
type CursorForwardSeq ¶
type CursorForwardSeq struct {
Count int
}
type CursorHideSeq ¶ added in v0.0.7
type CursorHideSeq struct{}
type CursorHorizontalSeq ¶
type CursorHorizontalSeq struct {
Count int
}
type CursorNextLineSeq ¶
type CursorNextLineSeq struct {
Count int
}
type CursorPositionSeq ¶
type CursorPreviousLineSeq ¶
type CursorPreviousLineSeq struct {
Count int
}
type CursorShowSeq ¶ added in v0.0.7
type CursorShowSeq struct{}
type CursorUpSeq ¶
type CursorUpSeq struct {
Count int
}
type DeleteLineSeq ¶
type DeleteLineSeq struct {
Count int
}
type EmptyAdapter ¶
type EmptyAdapter struct{}
func NewEmptyAdapter ¶
func NewEmptyAdapter() *EmptyAdapter
func (*EmptyAdapter) HandleKeyPress ¶
func (e *EmptyAdapter) HandleKeyPress()
func (*EmptyAdapter) HandleMouseButton ¶
func (e *EmptyAdapter) HandleMouseButton(button MouseButton)
func (*EmptyAdapter) HandleMouseMotion ¶
func (e *EmptyAdapter) HandleMouseMotion(motion MouseMotion)
func (*EmptyAdapter) HandleMouseWheel ¶
func (e *EmptyAdapter) HandleMouseWheel(wheel MouseWheel)
func (*EmptyAdapter) HandleWindowSize ¶
func (e *EmptyAdapter) HandleWindowSize(size WindowSize)
type EraseDisplaySeq ¶
type EraseDisplaySeq struct {
Type int
}
type EraseLineSeq ¶
type EraseLineSeq struct {
Type int
}
type FontWeight ¶
type FontWeight byte
FontWeight is the weight of a font at a certain terminal cell.
const ( // FontWeightNormal is the default font weight. FontWeightNormal FontWeight = iota // FontWeightBold is a bold font weight. FontWeightBold // FontWeightItalic is an italic font weight. FontWeightItalic )
type Fonts ¶
func LoadFaces ¶
LoadFaces loads a set of fonts from files. The normal, bold, and italic files must be provided. The dpi and size are used to generate the font faces. Supports ttf and otf.
func LoadFacesBytes ¶ added in v0.0.4
func LoadFacesBytes(normal []byte, bold []byte, italic []byte, dpi float64, size float64) (Fonts, error)
LoadFacesBytes loads a set of fonts from bytes. The normal, bold, and italic files must be provided. The dpi and size are used to generate the font faces. Supports ttf and otf.
type InputAdapter ¶
type InputAdapter interface { HandleMouseButton(button MouseButton) HandleMouseMotion(motion MouseMotion) HandleMouseWheel(wheel MouseWheel) HandleKeyPress() HandleWindowSize(size WindowSize) }
type InsertLineSeq ¶
type InsertLineSeq struct {
Count int
}
type MouseButton ¶
type MouseMotion ¶
type MouseWheel ¶
type RestoreCursorPositionSeq ¶
type RestoreCursorPositionSeq struct{}
type SGRBgColor ¶ added in v0.0.8
type SGRBgColor struct {
Id int
}
type SGRBgTrueColor ¶
type SGRBgTrueColor struct {
R, G, B byte
}
type SGRFgColor ¶ added in v0.0.8
type SGRFgColor struct {
Id int
}
type SGRFgTrueColor ¶
type SGRFgTrueColor struct {
R, G, B byte
}
type SGRUnsetBold ¶
type SGRUnsetBold struct{}
type SGRUnsetItalic ¶
type SGRUnsetItalic struct{}
type SaveCursorPositionSeq ¶
type SaveCursorPositionSeq struct{}
type ScrollDownSeq ¶
type ScrollDownSeq struct {
Count int
}
type ScrollUpSeq ¶
type ScrollUpSeq struct {
Count int
}
type Window ¶
func NewGame ¶
func NewGame(width int, height int, fonts Fonts, tty io.Reader, adapter InputAdapter, defaultBg color.Color) (*Window, error)
NewGame creates a new terminal game with the given dimensions and font faces.
func (*Window) GetCellsHeight ¶ added in v0.0.8
GetCellsHeight returns the number of cells in the y direction.
func (*Window) GetCellsWidth ¶ added in v0.0.8
GetCellsWidth returns the number of cells in the x direction.
func (*Window) InvalidateBuffer ¶ added in v0.0.8
func (g *Window) InvalidateBuffer()
InvalidateBuffer forces the buffer to be redrawn.
func (*Window) PrintChar ¶
func (g *Window) PrintChar(r rune, fg, bg color.Color, weight FontWeight)
PrintChar prints a character to the screen.
func (*Window) RecalculateBackgrounds ¶
func (g *Window) RecalculateBackgrounds()
RecalculateBackgrounds syncs the background colors to the background pixels.
func (*Window) ResetSGR ¶
func (g *Window) ResetSGR()
ResetSGR resets the SGR attributes to their default values.
func (*Window) RunWithOptions ¶ added in v0.0.15
func (g *Window) RunWithOptions(options ...WindowOption) error
func (*Window) SetBg ¶ added in v0.0.8
SetBg sets the background color of a cell and checks if it needs to be redrawn.
func (*Window) SetBgPixels ¶
SetBgPixels sets a chunk of background pixels in the size of the cell.
func (*Window) SetCursorChar ¶ added in v0.0.7
SetCursorChar sets the character that is used for the cursor.
func (*Window) SetCursorColor ¶ added in v0.0.7
SetCursorColor sets the color of the cursor.
func (*Window) SetOnPostDraw ¶ added in v0.0.8
func (g *Window) SetOnPostDraw(fn func(screen *ebiten.Image))
SetOnPostDraw sets a function that is called after the screen is drawn.
func (*Window) SetOnPreDraw ¶ added in v0.0.8
func (g *Window) SetOnPreDraw(fn func(screen *ebiten.Image))
SetOnPreDraw sets a function that is called before the screen is drawn.
func (*Window) SetOnUpdate ¶ added in v0.0.8
func (g *Window) SetOnUpdate(fn func())
SetOnUpdate sets a function that is called every frame.
func (*Window) SetShader ¶ added in v0.0.2
SetShader sets a shader that is applied to the whole screen.
func (*Window) SetShowCursor ¶ added in v0.0.7
SetShowCursor enables or disables the cursor.
type WindowOption ¶ added in v0.0.15
type WindowOption func(window *Window)