Documentation
¶
Overview ¶
input.go
Index ¶
- func LoadAnimationFile(filename string) ([]string, error)
- func ReadInput(msgs chan<- Msg)
- func SetGlobalRenderer(renderer Renderer)
- type Animation
- type Catalog
- type Cmd
- type Game
- type KeyMsg
- type LocalizationManager
- type Model
- type Msg
- type NestedData
- type Program
- type ProgramOption
- type QuitMsg
- type Renderer
- type SizeMsg
- type StandardRenderer
- func (r *StandardRenderer) AltScreen() bool
- func (r *StandardRenderer) ClearScreen()
- func (r *StandardRenderer) EnterAltScreen()
- func (r *StandardRenderer) ExitAltScreen()
- func (r *StandardRenderer) GetSize() (int, int)
- func (r *StandardRenderer) HideCursor()
- func (r *StandardRenderer) Kill()
- func (r *StandardRenderer) Repaint()
- func (r *StandardRenderer) SetCursor(x, y int)
- func (r *StandardRenderer) SetWindowTitle(title string)
- func (r *StandardRenderer) ShowCursor()
- func (r *StandardRenderer) Start()
- func (r *StandardRenderer) Stop()
- func (r *StandardRenderer) Write(s string)
- type TickMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadAnimationFile ¶
LoadAnimationFile reads and parses animation frames from file separated by "---" Returns slice of frame strings and any file read/parse error
func ReadInput ¶
func ReadInput(msgs chan<- Msg)
ReadInput reads from stdin and sends KeyMsg/QuitMsg to the provided channel Handles escape sequences for arrow keys and Ctrl+C termination
func SetGlobalRenderer ¶
func SetGlobalRenderer(renderer Renderer)
SetGlobalRenderer sets the global renderer instance
Types ¶
type Animation ¶
type Animation struct {
Frames []string
// contains filtered or unexported fields
}
func NewAnimation ¶
NewAnimation creates a new Animation with frames and default 200ms speed
type Catalog ¶
type Cmd ¶
type Cmd func() Msg
type LocalizationManager ¶
type LocalizationManager struct {
// contains filtered or unexported fields
}
func GetLocalizationManager ¶
func GetLocalizationManager() *LocalizationManager
GetLocalizationManager returns singleton instance of LocalizationManager Initializes with default language "fr" on first call
func (*LocalizationManager) GetCurrentLanguage ¶
func (lm *LocalizationManager) GetCurrentLanguage() string
GetCurrentLanguage returns the currently set language code
func (*LocalizationManager) GetSupportedLanguages ¶
func (lm *LocalizationManager) GetSupportedLanguages() ([]string, error)
GetSupportedLanguages scans assets/interface directory for available .json language files Returns slice of language codes and any directory read error
func (*LocalizationManager) SetLanguage ¶
func (lm *LocalizationManager) SetLanguage(lang string) error
SetLanguage loads and sets the catalog for the specified language Returns error if language file cannot be loaded
type NestedData ¶
type NestedData map[string]interface{}
NestedData represents the nested JSON structure from language files
type Program ¶
type Program struct {
Model Model
// contains filtered or unexported fields
}
func NewProgram ¶
func NewProgram(model Model, opts ...ProgramOption) *Program
NewProgram creates a new Program with model and applies provided options
func (*Program) GetRenderer ¶
GetRenderer returns the renderer instance for external access
type ProgramOption ¶
type ProgramOption func(*Program)
func WithAltScreen ¶
func WithAltScreen() ProgramOption
WithAltScreen enables alternate screen buffer for full-screen applications
type Renderer ¶
type Renderer interface {
// Start the renderer
Start()
// Stop the renderer
Stop()
// Kill the renderer
Kill()
// Write to the viewport
Write(string)
// Clear the screen
ClearScreen()
// Full repaint the screen
Repaint()
// Show cursor
ShowCursor()
// Hide cursor
HideCursor()
// Set window title
SetWindowTitle(string)
// Whether or not the alternate screen buffer is enabled.
AltScreen() bool
// Enable the alternate screen buffer.
EnterAltScreen()
// Disable the alternate screen buffer.
ExitAltScreen()
// Position cursor at specific coordinates (0-based)
SetCursor(x, y int)
// Get current terminal dimensions
GetSize() (width int, height int)
}
func GetGlobalRenderer ¶
func GetGlobalRenderer() Renderer
GetGlobalRenderer returns the global renderer instance
func NewRenderer ¶
NewRenderer creates a StandardRenderer with default 24fps frameRate
type StandardRenderer ¶
type StandardRenderer struct {
// contains filtered or unexported fields
}
func (*StandardRenderer) AltScreen ¶
func (r *StandardRenderer) AltScreen() bool
AltScreen returns whether alternate screen buffer is currently active
func (*StandardRenderer) ClearScreen ¶
func (r *StandardRenderer) ClearScreen()
ClearScreen erases entire screen and forces repaint
func (*StandardRenderer) EnterAltScreen ¶
func (r *StandardRenderer) EnterAltScreen()
EnterAltScreen switches to alternate screen buffer for full-screen mode
func (*StandardRenderer) ExitAltScreen ¶
func (r *StandardRenderer) ExitAltScreen()
ExitAltScreen restores normal screen buffer and cursor position
func (*StandardRenderer) GetSize ¶
func (r *StandardRenderer) GetSize() (int, int)
GetSize returns current terminal width and height
func (*StandardRenderer) HideCursor ¶
func (r *StandardRenderer) HideCursor()
HideCursor makes the terminal cursor invisible
func (*StandardRenderer) Kill ¶
func (r *StandardRenderer) Kill()
Kill forcefully stops the renderer and clears the current line
func (*StandardRenderer) Repaint ¶
func (r *StandardRenderer) Repaint()
Repaint resets render state to force full redraw on next flush
func (*StandardRenderer) SetCursor ¶
func (r *StandardRenderer) SetCursor(x, y int)
SetCursor positions cursor at specific coordinates in alternate screen mode
func (*StandardRenderer) SetWindowTitle ¶
func (r *StandardRenderer) SetWindowTitle(title string)
SetWindowTitle sets the terminal window title
func (*StandardRenderer) ShowCursor ¶
func (r *StandardRenderer) ShowCursor()
ShowCursor makes the terminal cursor visible
func (*StandardRenderer) Start ¶
func (r *StandardRenderer) Start()
Start initializes the renderer timer and begins the background rendering loop
func (*StandardRenderer) Stop ¶
func (r *StandardRenderer) Stop()
Stop gracefully shuts down the renderer, flushes output, and shows cursor
func (*StandardRenderer) Write ¶
func (r *StandardRenderer) Write(s string)
Write stores content in render buffer, replacing any previous content