Documentation
¶
Overview ¶
Package blockfont provides block letter rendering for terminal applications using ASCII block characters. It includes high-level widgets for charmbracelet/bubbletea integration, vim-style text editing, animations, and comprehensive styling support.
Index ¶
- Constants
- Variables
- func AlignLines(lines []string, alignment Alignment, width int) []string
- func CalculateTotalWidth(runes []rune, cursorIdx int, isInsertMode bool) int
- func CenterLines(lines []string, width int) []string
- func GetAnimationInterval() time.Duration
- func GetDisplayWidth(text string) int
- func GetGradientColor(value float64, colors []string) string
- func GetLetterWidth(char rune) int
- func GetProgressColor(progress float64) string
- func GetTotalWidth(word string) int
- func GetWPMColor(wpm int) string
- func InsertAt(base, overlay string, x int) string
- func InvertLine(line string) string
- func JoinBlockLines(lines [][]string, spacing int) []string
- func LeftJustify(lines []string, margin int) []string
- func MaxLineWidth(lines []string) int
- func PadToWidth(line string, width int) string
- func RemoveANSI(s string) string
- func RenderPlainText(text string, color string) []string
- func RenderText(text string) string
- func RenderWithCursor(text string, cursorIdx int, highlights []CharHighlight, isInsertMode bool, ...) []string
- func RenderWord(word string) [][]string
- func RightJustify(lines []string, width int) []string
- func VisibleStringWidth(s string) int
- func WrapOnWordBoundaries(text string, maxWidth int) []string
- func WrapWithColor(text, color string) string
- type Alignment
- type AnimationTickMsg
- type Animator
- type Buffer
- func (b *Buffer) CharAt(x, y int) rune
- func (b *Buffer) CharUnderCursor() rune
- func (b *Buffer) Clone() *Buffer
- func (b *Buffer) CurrentLine() string
- func (b *Buffer) CursorIndex() int
- func (b *Buffer) CursorPosition() (x, y int)
- func (b *Buffer) Delete(n int) string
- func (b *Buffer) DeleteLine() string
- func (b *Buffer) DeleteToEndOfLine() string
- func (b *Buffer) GetRegister() string
- func (b *Buffer) Insert(text string)
- func (b *Buffer) IsInsertMode() bool
- func (b *Buffer) Lines() []string
- func (b *Buffer) Mode() Mode
- func (b *Buffer) MoveDown(n int)
- func (b *Buffer) MoveLeft(n int)
- func (b *Buffer) MoveRight(n int)
- func (b *Buffer) MoveToFirstLine()
- func (b *Buffer) MoveToLastLine()
- func (b *Buffer) MoveToLineEnd()
- func (b *Buffer) MoveToLineStart()
- func (b *Buffer) MoveUp(n int)
- func (b *Buffer) ReplaceChar(r rune)
- func (b *Buffer) SetCursorIndex(index int)
- func (b *Buffer) SetCursorPosition(x, y int)
- func (b *Buffer) SetMode(mode Mode)
- func (b *Buffer) SetRegister(text string)
- func (b *Buffer) SetText(text string)
- func (b *Buffer) Text() string
- type CharHighlight
- type CursorStyle
- type Mode
- type StyleConfig
- type Theme
- type TransitionType
- type Widget
- func (w *Widget) Blur()
- func (w *Widget) Buffer() *Buffer
- func (w *Widget) ColorCharacter(index int, color lipgloss.Color)
- func (w *Widget) ColorRange(start, end int, color lipgloss.Color)
- func (w *Widget) DisableAnimations()
- func (w *Widget) DisableVimMode()
- func (w *Widget) EnableAnimations()
- func (w *Widget) EnableVimMode()
- func (w *Widget) Focus()
- func (w *Widget) Init() tea.Cmd
- func (w *Widget) IsAnimating() bool
- func (w *Widget) IsFocused() bool
- func (w *Widget) Mode() Mode
- func (w *Widget) Render() []string
- func (w *Widget) RenderCentered(width int) []string
- func (w *Widget) ResetColors()
- func (w *Widget) SetAlignment(alignment Alignment)
- func (w *Widget) SetHeight(height int)
- func (w *Widget) SetHighlights(highlights []CharHighlight)
- func (w *Widget) SetText(text string)
- func (w *Widget) SetTheme(theme Theme)
- func (w *Widget) SetWidth(width int)
- func (w *Widget) Text() string
- func (w *Widget) TriggerAnimation(t TransitionType) tea.Cmd
- func (w *Widget) Update(msg tea.Msg) (*Widget, tea.Cmd)
- func (w *Widget) View() string
- type WidgetOptions
- type WordCarouselAnimator
- func (w *WordCarouselAnimator) GetCurrentOffset() int
- func (w *WordCarouselAnimator) GetCurrentScale() float64
- func (w *WordCarouselAnimator) GetNextOffset() int
- func (w *WordCarouselAnimator) GetNextOpacity() float64
- func (w *WordCarouselAnimator) GetPrevOffset() int
- func (w *WordCarouselAnimator) GetPrevOpacity() float64
- func (w *WordCarouselAnimator) TriggerTransition()
- func (w *WordCarouselAnimator) Update() bool
Constants ¶
const ( ANSIReset = "\033[0m" ANSIRed = "\033[1;31m" ANSIGreen = "\033[1;32m" ANSIOrange = "\033[1;33m" ANSIYellow = "\033[1;33m" // Alias for orange ANSIBlue = "\033[1;34m" ANSIMagenta = "\033[1;35m" ANSICyan = "\033[1;36m" ANSIWhite = "\033[1;37m" ANSIInverse = "\033[7m" ANSIDim = "\033[2m" ANSIBold = "\033[1m" ANSIItalic = "\033[3m" ANSIUnderline = "\033[4m" )
ANSI escape code constants for terminal styling
const AnimationInterval = 50 * time.Millisecond
AnimationInterval is the default tick interval for animations
const LetterHeight = 6
LetterHeight is the height of all block letters in lines
const LetterSpacing = 1
LetterSpacing is the spacing between letters in characters
Variables ¶
var BlockLetters = map[rune][]string{
'a': {
" ",
" ",
"██████",
"██ ██",
"████◤█",
" ",
},
'b': {
"██ ",
"██ ",
"█████◣",
"██ ◢█",
"█████◤",
" ",
},
'c': {
" ",
" ",
"◢████◣",
"██ ",
"◥████◤",
" ",
},
'd': {
" ██",
" ██",
"◢█████",
"██ ◢█",
"◥█████",
" ",
},
'e': {
" ",
" ",
"◢████◣",
"███ ◢█",
"◥███ ",
" ",
},
'f': {
" ◢███ ",
" ██ ",
"████ ",
" ██ ",
" ██ ",
" ",
},
'g': {
" ",
"◢█████",
"██ ██",
"◥█████",
" ██",
"◥████◤",
},
'h': {
"██ ",
"██ ",
"█████◣",
"██ ██",
"██ ██",
" ",
},
'i': {
" ██ ",
" ",
"████ ",
" ██ ",
"██████",
" ",
},
'j': {
" ██",
" ",
" ████",
" ██",
"◢█ ██",
"◥████◤",
},
'k': {
"██ ",
"██◢█◤ ",
"███◤ ",
"██◥█◣ ",
"██ ◥█ ",
" ",
},
'l': {
"████ ",
" ██ ",
" ██ ",
" ██ ",
"██████",
" ",
},
'm': {
" ",
" ",
"██◣◢██◣",
"███████",
"██ █ ██",
" ",
},
'n': {
" ",
" ",
"█████◣",
"██ ██",
"██ ██",
" ",
},
'o': {
" ",
" ",
"◢████◣",
"██ ██",
"◥████◤",
" ",
},
'p': {
" ",
" ",
"█████◣",
"██ ██",
"█████◤",
"██ ",
},
'q': {
" ",
" ",
"◢█████",
"██ ██",
"◥█████",
" ██",
},
'r': {
" ",
" ",
"██◢██ ",
"███◤ ",
"██ ",
" ",
},
's': {
" ",
"◢████ ",
"◥██◣ ",
" ◥█◣ ",
"████◤ ",
" ",
},
't': {
" ",
" ██ ",
"██████",
" ██ ",
" ◥███",
" ",
},
'u': {
" ",
" ",
"██ ██",
"██ ██",
"◥█████",
" ",
},
'v': {
" ",
" ",
"██ ██",
" ◥██◤ ",
" ██ ",
" ",
},
'w': {
" ",
" ",
"██ █ ██",
"███████",
"◥█◤ ◥█◤",
" ",
},
'x': {
" ",
" ",
"◥█◣◢█◤",
" ◥██◤ ",
"◢█◤◥█◣",
" ",
},
'y': {
" ",
" ",
"██ ██",
"◥█ █◤",
" ◥██◤ ",
" ◢█◤ ",
},
'z': {
" ",
" ",
"██████",
" ◢██◤ ",
"██████",
" ",
},
'A': {
" ◢██◣ ",
"◢█ █◣",
"██████",
"██ ██",
"██ ██",
" ",
},
'B': {
"█████◣",
"██ ◥█",
"██████",
"██ ◢█",
"█████◤",
" ",
},
'C': {
" ◢████",
"◢█ ",
"██ ",
"◥█ ",
" ◥████",
" ",
},
'D': {
"█████◣",
"██ ◥█",
"██ █",
"██ ◢█",
"█████◤",
" ",
},
'E': {
"██████",
"██ ",
"████ ",
"██ ",
"██████",
" ",
},
'F': {
"██████",
"██ ",
"████ ",
"██ ",
"██ ",
" ",
},
'G': {
"◢█████",
"██ ",
"██ ███",
"██ ██",
"◥████◤",
" ",
},
'H': {
"██ ██",
"██ ██",
"██████",
"██ ██",
"██ ██",
" ",
},
'I': {
"██████",
" ██ ",
" ██ ",
" ██ ",
"██████",
" ",
},
'J': {
"██████",
" ██",
" ██",
"██ ██",
"◥████◤",
" ",
},
'K': {
"██ ◢█◤",
"██◢█◤ ",
"███◣ ",
"██◥█◣ ",
"██ ◥█◣",
" ",
},
'L': {
"██ ",
"██ ",
"██ ",
"██ ",
"██████",
" ",
},
'M': {
"██◣◢██",
"██████",
"██ █ █",
"██ █",
"██ █",
" ",
},
'N': {
"██◣ ██",
"███◣██",
"██◥███",
"██ ◥██",
"██ ██",
" ",
},
'O': {
"◢████◣",
"██ ██",
"██ ██",
"██ ██",
"◥████◤",
" ",
},
'P': {
"█████◣",
"██ ◥█",
"█████◤",
"██ ",
"██ ",
" ",
},
'Q': {
"◢████◣",
"██ ██",
"██ ██",
"██ ◥█◤",
"◥███◤█",
" ",
},
'R': {
"█████◣",
"██ ◥█",
"█████◤",
"██◥█◣ ",
"██ ◥█◣",
" ",
},
'S': {
"◢████◣",
"██ ",
"◥████◣",
" ██",
"◥████◤",
" ",
},
'T': {
"██████",
" ██ ",
" ██ ",
" ██ ",
" ██ ",
" ",
},
'U': {
"██ ██",
"██ ██",
"██ ██",
"██ ██",
"◥████◤",
" ",
},
'V': {
"██ ██",
"██ ██",
"◥█ █◤",
" ◥██◤ ",
" ◥◤ ",
" ",
},
'W': {
"██ ██",
"██ ██",
"██ █ ██",
"███████",
"◥█◤ ◥█◤",
" ",
},
'X': {
"██ ██",
" ◥██◤ ",
" ██ ",
" ◢██◣ ",
"██ ██",
" ",
},
'Y': {
"◥█ █◤",
" ◥██◤ ",
" ██ ",
" ██ ",
" ██ ",
" ",
},
'Z': {
"█████◤",
" ◢█◤ ",
" ◢█◤ ",
"◢█◤ ",
"██████",
" ",
},
' ': {
" ",
" ",
" ",
" ",
" ",
" ",
},
',': {
" ",
" ",
" ",
" ██ ",
" ◥█ ",
" ",
},
'.': {
" ",
" ",
" ",
" ",
" ██ ",
" ",
},
';': {
" ",
" ██ ",
" ",
" ██ ",
" ◥█ ",
" ",
},
':': {
" ",
" ██ ",
" ",
" ██ ",
" ",
" ",
},
'!': {
" ██ ",
" ██ ",
" ██ ",
" ",
" ██ ",
" ",
},
'?': {
"◢████◣",
"██ ◢█◤",
" ◢█◤ ",
" ",
" ██ ",
" ",
},
'-': {
" ",
" ",
"██████",
" ",
" ",
" ",
},
'\'': {
" ██ ",
" ◥█ ",
" ",
" ",
" ",
" ",
},
'"': {
"██ ██",
"◥█ ◥█",
" ",
" ",
" ",
" ",
},
'(': {
" ◢█",
"◢█ ",
"██ ",
"◥█ ",
" ◥█",
" ",
},
')': {
"█◣ ",
" █◣",
" ██",
" █◤",
"█◤ ",
" ",
},
'[': {
"███",
"██ ",
"██ ",
"██ ",
"███",
" ",
},
']': {
"███",
" ██",
" ██",
" ██",
"███",
" ",
},
'{': {
" ◢█",
" ██",
"◢█ ",
" ██",
" ◥█",
" ",
},
'}': {
"█◣ ",
"██ ",
" █◣",
"██ ",
"█◤ ",
" ",
},
'<': {
" ◢█",
" ◢█ ",
"◢█ ",
" ◥█ ",
" ◥█",
" ",
},
'>': {
"█◣ ",
" █◣ ",
" █◣",
" █◤ ",
"█◤ ",
" ",
},
'/': {
" ",
" ◢█◤",
" ◢█◤ ",
" ◢█◤ ",
"◢█◤ ",
" ",
},
'\\': {
" ",
"◥█◣ ",
" ◥█◣ ",
" ◥█◣ ",
" ◥█◣",
" ",
},
'|': {
" ██ ",
" ██ ",
" ██ ",
" ██ ",
" ██ ",
" ",
},
'_': {
" ",
" ",
" ",
" ",
"██████",
" ",
},
'+': {
" ",
" ██ ",
"██████",
" ██ ",
" ",
" ",
},
'=': {
" ",
"██████",
" ",
"██████",
" ",
" ",
},
'*': {
" ",
"◥█ █◤",
" ████ ",
"◢█ █◣",
" ",
" ",
},
'&': {
" ◢██◣ ",
"◢█ █◣",
"◥█◢█◤█",
"██◥█◢█",
"◥███◥█",
" ",
},
'@': {
" ◢███◣ ",
"██ ◢██◣",
"██ █ ██",
"██ ◥███",
" ◥███ ",
" ",
},
'#': {
" ██ ██ ",
"███████",
" ██ ██ ",
"███████",
" ██ ██ ",
" ",
},
'$': {
" ◢███ ",
"██ █ ",
" ███ ",
" █ ██",
" ███◤ ",
" ",
},
'%': {
"██ ◢█",
"██ ◢█◤",
" ◢█◤ ",
" ◢█◤██",
"◢█◤ ██",
" ",
},
'^': {
" ◢█◣ ",
"◢█ █◣",
" ",
" ",
" ",
" ",
},
'`': {
"█◣ ",
" ◥█",
" ",
" ",
" ",
" ",
},
'~': {
" ",
"◢█◣ ◢█",
"█◥███◤",
" ",
" ",
" ",
},
'0': {
"◢████◣",
"██ ██",
"██ ██",
"██ ██",
"◥████◤",
" ",
},
'1': {
" ◢██ ",
"████ ",
" ██ ",
" ██ ",
"██████",
" ",
},
'2': {
"◢████◣",
" ██",
" ◢███◤",
"◢█◤ ",
"██████",
" ",
},
'3': {
"█████◣",
" ◥█",
" ◢███◤",
" ◢█",
"█████◤",
" ",
},
'4': {
"◢█ ██",
"██ ██",
"██████",
" ██",
" ██",
" ",
},
'5': {
"██████",
"██ ",
"█████◣",
" ◥█",
"█████◤",
" ",
},
'6': {
"◢████◣",
"██ ",
"█████◣",
"██ ◥█",
"◥████◤",
" ",
},
'7': {
"██████",
" ◢█◤",
" ◢█◤ ",
" ◢█◤ ",
"◢█◤ ",
" ",
},
'8': {
"◢████◣",
"██ ██",
"◥████◤",
"◢█ █◣",
"◥████◤",
" ",
},
'9': {
"◢████◣",
"██ ██",
"◥█████",
" ██",
"◥████◤",
" ",
},
}
BlockLetters maps runes to their block letter representation. Each letter is 6 lines tall and variable width. Uses block elements for solid letters with smooth corners:
██ full blocks - solid letter bodies ◢ ◣ ◤ ◥ - filled triangles for smooth rounded corners
Triangles replace blocks only at curved edges to eliminate blocky corners.
var DefaultTheme = Theme{ Primary: lipgloss.Color("#FFFFFF"), Secondary: lipgloss.Color("#888888"), Accent: lipgloss.Color("#FFB347"), Correct: lipgloss.Color("#32CD32"), Incorrect: lipgloss.Color("#FF6B6B"), Cursor: lipgloss.Color("#FFFFFF"), Delete: lipgloss.Color("#FF4444"), Change: lipgloss.Color("#FF8C00"), Target: lipgloss.Color("#00FF00"), Pending: lipgloss.Color("#666666"), }
DefaultTheme provides a default color theme
var GradientColors = []string{
"#8B0000", "#B22222", "#CD5C5C", "#F08080",
"#FF6B35", "#FF8C00", "#FFA500", "#FFB347",
"#FFD700", "#ADFF2F", "#32CD32", "#00FF00",
}
GradientColors provides a gradient from red (slow) to green (fast)
var KartozaTheme = Theme{ Primary: lipgloss.Color("#FFFFFF"), Secondary: lipgloss.Color("#888888"), Accent: lipgloss.Color("#FF6B35"), Correct: lipgloss.Color("#32CD32"), Incorrect: lipgloss.Color("#FF4444"), Cursor: lipgloss.Color("#FFB347"), Delete: lipgloss.Color("#B22222"), Change: lipgloss.Color("#FF6B35"), Target: lipgloss.Color("#00FF00"), Pending: lipgloss.Color("#555555"), }
KartozaTheme provides a Kartoza-branded color theme
Functions ¶
func AlignLines ¶
AlignLines aligns lines according to the specified alignment and width.
func CalculateTotalWidth ¶
CalculateTotalWidth calculates the total display width including cursor
func CenterLines ¶
CenterLines centers each line within the given width. ANSI escape codes are excluded from width calculations.
func GetAnimationInterval ¶
GetAnimationInterval returns the recommended tick interval
func GetDisplayWidth ¶
GetDisplayWidth returns the display width of text when rendered in large font
func GetGradientColor ¶
GetGradientColor returns a color from the gradient based on a value (0.0 to 1.0)
func GetLetterWidth ¶
GetLetterWidth returns the width of a letter in runes (for proper Unicode handling).
func GetProgressColor ¶
GetProgressColor returns a color based on progress value (0.0 to 1.0)
func GetTotalWidth ¶
GetTotalWidth returns the total display width of a word in the block font.
func GetWPMColor ¶
GetWPMColor returns a color based on words per minute value
func InsertAt ¶
InsertAt inserts overlay text at position x in the base string. Handles overlapping text composition while preserving ANSI codes.
func InvertLine ¶
InvertLine inverts a single line using ANSI inverse video. This swaps foreground/background colors for the entire line.
func JoinBlockLines ¶
JoinBlockLines joins multiple lines from RenderWord with the specified spacing.
func LeftJustify ¶
LeftJustify left-justifies lines with optional left margin.
func MaxLineWidth ¶
MaxLineWidth returns the maximum visible width across all lines.
func PadToWidth ¶
PadToWidth pads or truncates a string to the exact visible width. ANSI escape codes are preserved.
func RemoveANSI ¶
RemoveANSI removes ANSI escape codes from a string. This is useful for calculating visible width of styled text.
func RenderPlainText ¶
RenderPlainText renders plain text in large font without any highlighting. Used for reference/target text display.
func RenderText ¶
RenderText renders text as block letters and returns a single string with lines joined. This is a convenience function for simple rendering without per-character control.
func RenderWithCursor ¶
func RenderWithCursor(text string, cursorIdx int, highlights []CharHighlight, isInsertMode bool, maxWidth int, theme Theme) []string
RenderWithCursor renders text with cursor and character-level highlighting support. Returns multiple lines (6 per row of characters + 1 underline row) that can be displayed. This is the full-featured rendering function used by typing/editing applications.
func RenderWord ¶
RenderWord renders a word as block letters, returning each line separately. Each rune in the returned slices corresponds to one character of the original word.
func RightJustify ¶
RightJustify right-justifies lines within the given width. ANSI escape codes are excluded from width calculations.
func VisibleStringWidth ¶
VisibleStringWidth calculates the visible width of a string, excluding ANSI escape codes. Returns the rune count of the visible text.
func WrapOnWordBoundaries ¶
WrapOnWordBoundaries wraps text at word boundaries (spaces) to fit within maxWidth. Returns the text split into multiple lines.
func WrapWithColor ¶
WrapWithColor wraps text with ANSI color codes.
Types ¶
type AnimationTickMsg ¶
type AnimationTickMsg struct{}
AnimationTickMsg is sent when animation should update
type Animator ¶
type Animator struct {
// Current values (0.0 to 1.0 representing animation progress)
Position float64
Opacity float64
Scale float64
// Animation state
IsAnimating bool
// contains filtered or unexported fields
}
Animator handles spring-based animations for smooth transitions
func NewAnimator ¶
func NewAnimator() *Animator
NewAnimator creates a new animator with default spring settings
func (*Animator) GetOffset ¶
GetOffset returns the vertical offset based on position (for slide animations)
func (*Animator) GetOpacityLevel ¶
GetOpacityLevel returns opacity as a value from 0.0 to maxOpacity
func (*Animator) GetScaleFactor ¶
GetScaleFactor returns scale factor (e.g., 0.7 to 1.0)
func (*Animator) Reset ¶
func (a *Animator) Reset()
Reset stops any animation and resets to default state
func (*Animator) TriggerTransition ¶
func (a *Animator) TriggerTransition(t TransitionType)
TriggerTransition starts an animation of the specified type
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a text buffer with cursor position for vim-style editing
func (*Buffer) CharUnderCursor ¶
CharUnderCursor returns the character under the cursor
func (*Buffer) CurrentLine ¶
CurrentLine returns the current line
func (*Buffer) CursorIndex ¶
CursorIndex returns the absolute character index in the buffer
func (*Buffer) CursorPosition ¶
CursorPosition returns the cursor position (x=column, y=line)
func (*Buffer) DeleteLine ¶
DeleteLine deletes the current line
func (*Buffer) DeleteToEndOfLine ¶
DeleteToEndOfLine deletes from cursor to end of line
func (*Buffer) GetRegister ¶
GetRegister returns the yank register content
func (*Buffer) IsInsertMode ¶
IsInsertMode returns true if in insert mode
func (*Buffer) MoveToFirstLine ¶
func (b *Buffer) MoveToFirstLine()
MoveToFirstLine moves cursor to first line
func (*Buffer) MoveToLastLine ¶
func (b *Buffer) MoveToLastLine()
MoveToLastLine moves cursor to last line
func (*Buffer) MoveToLineEnd ¶
func (b *Buffer) MoveToLineEnd()
MoveToLineEnd moves cursor to end of line
func (*Buffer) MoveToLineStart ¶
func (b *Buffer) MoveToLineStart()
MoveToLineStart moves cursor to start of line
func (*Buffer) ReplaceChar ¶
ReplaceChar replaces the character under the cursor
func (*Buffer) SetCursorIndex ¶
SetCursorIndex sets cursor by absolute character index
func (*Buffer) SetCursorPosition ¶
SetCursorPosition sets the cursor position
func (*Buffer) SetRegister ¶
SetRegister sets the yank register content
type CharHighlight ¶
type CharHighlight int
CharHighlight represents different highlight states for characters
const ( // HighlightNone indicates no highlight HighlightNone CharHighlight = iota // HighlightCorrect indicates correctly typed/matched HighlightCorrect // HighlightIncorrect indicates incorrectly typed/mismatched HighlightIncorrect // HighlightCursor indicates cursor position HighlightCursor // HighlightDelete indicates text to be deleted HighlightDelete // HighlightChange indicates text to be changed HighlightChange // HighlightTarget indicates target/goal text HighlightTarget // HighlightPending indicates untyped/pending text HighlightPending )
type CursorStyle ¶
type CursorStyle int
CursorStyle represents how the cursor should be displayed
const ( // CursorBlock uses a block cursor (inverts character) CursorBlock CursorStyle = iota // CursorLine uses a vertical line cursor CursorLine // CursorUnderline uses an underline cursor CursorUnderline )
type Mode ¶
type Mode int
Mode represents vim editing modes
const ( // ModeNormal is the default mode for navigation and commands ModeNormal Mode = iota // ModeInsert is for typing text ModeInsert // ModeVisual is for selecting text ModeVisual // ModeVisualLine is for selecting whole lines ModeVisualLine // ModeVisualBlock is for selecting rectangular blocks ModeVisualBlock // ModeCommand is for entering ex commands ModeCommand )
type StyleConfig ¶
type StyleConfig struct {
Theme Theme
CursorStyle CursorStyle
}
StyleConfig holds styling configuration for the widget
func DefaultStyleConfig ¶
func DefaultStyleConfig() StyleConfig
DefaultStyleConfig returns the default style configuration
type Theme ¶
type Theme struct {
// Primary color for main text
Primary lipgloss.Color
// Secondary color for dimmed/inactive text
Secondary lipgloss.Color
// Accent color for highlights
Accent lipgloss.Color
// Correct color for correctly matched text
Correct lipgloss.Color
// Incorrect color for incorrectly matched text
Incorrect lipgloss.Color
// Cursor color for cursor highlights
Cursor lipgloss.Color
// Delete color for text to be deleted
Delete lipgloss.Color
// Change color for text to be changed
Change lipgloss.Color
// Target color for target/goal text
Target lipgloss.Color
// Pending color for untyped text
Pending lipgloss.Color
}
Theme holds colors and styles for block font rendering
type TransitionType ¶
type TransitionType int
TransitionType represents different animation transition types
const ( // TransitionSlideUp slides content up TransitionSlideUp TransitionType = iota // TransitionSlideDown slides content down TransitionSlideDown // TransitionFadeIn fades content in TransitionFadeIn // TransitionFadeOut fades content out TransitionFadeOut // TransitionScale scales content TransitionScale )
type Widget ¶
type Widget struct {
// contains filtered or unexported fields
}
Widget is a high-level component for rendering block text in bubbletea applications. It implements tea.Model for easy integration.
func NewWidget ¶
func NewWidget(opts WidgetOptions) *Widget
NewWidget creates a new Widget with the given options
func (*Widget) ColorCharacter ¶
ColorCharacter sets a color for a specific character index
func (*Widget) ColorRange ¶
ColorRange sets a color for a range of characters
func (*Widget) DisableAnimations ¶
func (w *Widget) DisableAnimations()
DisableAnimations disables animations
func (*Widget) DisableVimMode ¶
func (w *Widget) DisableVimMode()
DisableVimMode disables vim-style editing
func (*Widget) EnableAnimations ¶
func (w *Widget) EnableAnimations()
EnableAnimations enables animations
func (*Widget) EnableVimMode ¶
func (w *Widget) EnableVimMode()
EnableVimMode enables vim-style editing
func (*Widget) IsAnimating ¶
IsAnimating returns whether an animation is in progress
func (*Widget) RenderCentered ¶
RenderCentered renders the text centered within the given width
func (*Widget) SetAlignment ¶
SetAlignment sets the text alignment
func (*Widget) SetHighlights ¶
func (w *Widget) SetHighlights(highlights []CharHighlight)
SetHighlights sets character-level highlights
func (*Widget) TriggerAnimation ¶
func (w *Widget) TriggerAnimation(t TransitionType) tea.Cmd
TriggerAnimation starts an animation
type WidgetOptions ¶
type WidgetOptions struct {
// Width is the target width for rendering
Width int
// Height is the target height (optional)
Height int
// Alignment controls text alignment
Alignment Alignment
// VimMode enables vim-style editing
VimMode bool
// Animate enables animations
Animate bool
// WordWrap enables word wrapping
WordWrap bool
// CursorStyle controls cursor appearance
CursorStyle CursorStyle
// Theme provides colors and styles
Theme Theme
}
WidgetOptions configures the Widget behavior
func DefaultWidgetOptions ¶
func DefaultWidgetOptions() WidgetOptions
DefaultWidgetOptions returns sensible defaults
type WordCarouselAnimator ¶
type WordCarouselAnimator struct {
// Positions (0.0 to 1.0)
PrevPos float64
CurrentPos float64
NextPos float64
// State
IsAnimating bool
// contains filtered or unexported fields
}
WordCarouselAnimator handles the three-word carousel animation Used for speed reading applications
func NewWordCarouselAnimator ¶
func NewWordCarouselAnimator() *WordCarouselAnimator
NewWordCarouselAnimator creates a new carousel animator
func (*WordCarouselAnimator) GetCurrentOffset ¶
func (w *WordCarouselAnimator) GetCurrentOffset() int
GetCurrentOffset returns vertical offset for current word
func (*WordCarouselAnimator) GetCurrentScale ¶
func (w *WordCarouselAnimator) GetCurrentScale() float64
GetCurrentScale returns scale factor for current word
func (*WordCarouselAnimator) GetNextOffset ¶
func (w *WordCarouselAnimator) GetNextOffset() int
GetNextOffset returns vertical offset for next word
func (*WordCarouselAnimator) GetNextOpacity ¶
func (w *WordCarouselAnimator) GetNextOpacity() float64
GetNextOpacity returns opacity for next word (max 60%)
func (*WordCarouselAnimator) GetPrevOffset ¶
func (w *WordCarouselAnimator) GetPrevOffset() int
GetPrevOffset returns vertical offset for previous word
func (*WordCarouselAnimator) GetPrevOpacity ¶
func (w *WordCarouselAnimator) GetPrevOpacity() float64
GetPrevOpacity returns opacity for previous word (max 50%)
func (*WordCarouselAnimator) TriggerTransition ¶
func (w *WordCarouselAnimator) TriggerTransition()
TriggerTransition starts the word carousel animation
func (*WordCarouselAnimator) Update ¶
func (w *WordCarouselAnimator) Update() bool
Update advances all springs by one frame
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
animated
command
Animated example demonstrating blockfont widget with animations.
|
Animated example demonstrating blockfont widget with animations. |
|
demo
command
Demo application showcasing all blockfont library features.
|
Demo application showcasing all blockfont library features. |
|
editor
command
Editor example demonstrating vim-style editing with blockfont.
|
Editor example demonstrating vim-style editing with blockfont. |
|
lowercase_preview
command
Preview all lowercase letters.
|
Preview all lowercase letters. |
|
simple
command
Simple example demonstrating basic blockfont usage.
|
Simple example demonstrating basic blockfont usage. |
