Documentation
¶
Index ¶
- func Ansi256ToHex(code int) string
- func Ansi256ToRGB(code int) (r, g, b int)
- func FormatKeyBinding(key tcell.Key, ch rune, mod tcell.ModMask) string
- func GeneratePointsVisual(points int, maxPoints int) string
- func GetDefaultEditor() string
- func OpenInEditor(filename string) error
- func TruncateText(text string, maxWidth int) string
- func TruncateTextWithColors(text string, maxWidth int) string
- type AnsiConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ansi256ToHex ¶
Ansi256ToHex converts ANSI 256 color code to hex color
func Ansi256ToRGB ¶
Ansi256ToRGB converts ANSI 256 color code to RGB values
func FormatKeyBinding ¶
FormatKeyBinding returns a display string for a keyboard shortcut. It handles rune keys, special keys, modifiers (Shift, Ctrl, Alt), and control character sequences (Ctrl+A through Ctrl+Z).
Examples:
- FormatKeyBinding(tcell.KeyCtrlS, 0, 0) → "Ctrl+S"
- FormatKeyBinding(tcell.KeyEnter, 0, tcell.ModShift) → "Shift+Enter"
- FormatKeyBinding(tcell.KeyEscape, 0, 0) → "Esc"
- FormatKeyBinding(tcell.KeyRune, 's', tcell.ModCtrl) → "Ctrl+s"
func GeneratePointsVisual ¶
GeneratePointsVisual formats points as a visual representation using filled/unfilled circles. Points are scaled to a 0-10 display range based on maxPoints configuration.
Parameters:
- points: The task's point value
- maxPoints: The configured maximum points value (for scaling)
Returns: A string with filled (●) and unfilled (◦) circles representing the points value.
Example:
GeneratePointsVisual(5, 10) returns "●●●●●◦◦◦◦◦" (5 filled, 5 unfilled)
func GetDefaultEditor ¶
func GetDefaultEditor() string
GetDefaultEditor returns the user's preferred editor from environment variables. Checks VISUAL, then EDITOR, then falls back to vi.
func OpenInEditor ¶
OpenInEditor opens the specified file in the user's default editor. The function blocks until the editor exits. Returns any error that occurred while running the editor.
func TruncateText ¶
TruncateText truncates text to maxWidth and adds "..." if it exceeds. Does not account for color codes - use TruncateTextWithColors for colored text.
func TruncateTextWithColors ¶
TruncateTextWithColors truncates text to fit within maxWidth, accounting for tview color codes. If truncation occurs, appends "..." to indicate the text was cut. Color codes like [#ffffff] or [red] are not counted toward the visible width.
Types ¶
type AnsiConverter ¶
type AnsiConverter struct {
// contains filtered or unexported fields
}
AnsiConverter converts ANSI escape sequences to tview color tags
func NewAnsiConverter ¶
func NewAnsiConverter(enabled bool) *AnsiConverter
NewAnsiConverter creates a new ANSI converter enabled: if false, returns text unchanged (uses tview.TranslateANSI as fallback)
func (*AnsiConverter) Convert ¶
func (c *AnsiConverter) Convert(text string) string
Convert translates ANSI escape sequences to tview color tags Properly handles foreground, background, and bold attributes