Documentation
¶
Overview ¶
Package tinge provides a fluent API for creating styled text output in terminal applications. It uses lipgloss for styling and offers a chainable interface for building formatted text.
Example usage:
package main
import "github.com/your-username/tinge"
func main() {
// Basic colored text
tinge.Styled().
Green("Hello, ").
Bold("World!").
Newline().
Write()
// Complex formatting with indentation
tinge.Styled().
Bold("Project Status:").
Newline().
Indent(2).
Green("✓ ").
Text("Tests passing").
Newline().
Indent(2).
Red("✗ ").
Text("Build failed").
Newline().
Indent(2).
Yellow("⚠ ").
Text("Warnings found").
Write()
// Using custom styles
tinge.Styled().
With(tinge.Blue, tinge.Bold).
Text("Important notice").
Space().
With(tinge.Grey).
Text("(read carefully)").
Write()
// Building strings for later use
message := tinge.Styled().
Pink("Welcome to ").
BoldItalic("Tinge").
Space().
BlueDark("v1.0.0").
String()
println(message)
}
Output examples:
Hello, World! Project Status: ✓ Tests passing ✗ Build failed ⚠ Warnings found Important notice (read carefully) Welcome to Tinge v1.0.0
Copyright 2025 The Tinge Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Index ¶
- Variables
- func SetWriter(output io.Writer)
- type StyledText
- func (s *StyledText) Blue(text string) *StyledText
- func (s *StyledText) BlueDark(text string) *StyledText
- func (s *StyledText) Bold(text string) *StyledText
- func (s *StyledText) BoldItalic(text string) *StyledText
- func (s *StyledText) Green(text string) *StyledText
- func (s *StyledText) GreenDark(text string) *StyledText
- func (s *StyledText) GreenLight(text string) *StyledText
- func (s *StyledText) Grey(text string) *StyledText
- func (s *StyledText) GreyDark(text string) *StyledText
- func (s *StyledText) Indent(spaces int) *StyledText
- func (s *StyledText) Italic(text string) *StyledText
- func (s *StyledText) Newline() *StyledText
- func (s *StyledText) Pink(text string) *StyledText
- func (s *StyledText) Red(text string) *StyledText
- func (s *StyledText) Space(n ...int) *StyledText
- func (s *StyledText) String() string
- func (s *StyledText) Text(text string) *StyledText
- func (s *StyledText) With(styles ...TextStyle) *StyledTextBuilder
- func (s *StyledText) Write(output ...io.Writer)
- func (s *StyledText) Yellow(text string) *StyledText
- type StyledTextBuilder
- type TextStyle
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Grey = lipgloss.NewStyle().Foreground(lipgloss.Color("#909194")) GreyDark = lipgloss.NewStyle().Foreground(lipgloss.Color("#454e6d")) Green = lipgloss.NewStyle().Foreground(lipgloss.Color("#50FA7B")) GreenLight = lipgloss.NewStyle().Foreground(lipgloss.Color("#3fed7b")) GreenDark = lipgloss.NewStyle().Foreground(lipgloss.Color("#3C9258")) Red = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff5555")) Pink = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff79c6")) Yellow = lipgloss.NewStyle().Foreground(lipgloss.Color("#f1fa8c")) Blue = lipgloss.NewStyle().Foreground(lipgloss.Color("#a4ffff")) BlueDark = lipgloss.NewStyle().Foreground(lipgloss.Color("#8be9fd")) Bold = lipgloss.NewStyle().Bold(true) Italic = lipgloss.NewStyle().Italic(true) )
Functions ¶
Types ¶
type StyledText ¶
type StyledText struct {
// contains filtered or unexported fields
}
func Styled ¶
func Styled() *StyledText
func (*StyledText) Blue ¶
func (s *StyledText) Blue(text string) *StyledText
func (*StyledText) BlueDark ¶
func (s *StyledText) BlueDark(text string) *StyledText
func (*StyledText) Bold ¶
func (s *StyledText) Bold(text string) *StyledText
func (*StyledText) BoldItalic ¶
func (s *StyledText) BoldItalic(text string) *StyledText
func (*StyledText) Green ¶
func (s *StyledText) Green(text string) *StyledText
func (*StyledText) GreenDark ¶
func (s *StyledText) GreenDark(text string) *StyledText
func (*StyledText) GreenLight ¶
func (s *StyledText) GreenLight(text string) *StyledText
func (*StyledText) Grey ¶
func (s *StyledText) Grey(text string) *StyledText
func (*StyledText) GreyDark ¶
func (s *StyledText) GreyDark(text string) *StyledText
func (*StyledText) Indent ¶
func (s *StyledText) Indent(spaces int) *StyledText
func (*StyledText) Italic ¶
func (s *StyledText) Italic(text string) *StyledText
func (*StyledText) Newline ¶
func (s *StyledText) Newline() *StyledText
func (*StyledText) Pink ¶
func (s *StyledText) Pink(text string) *StyledText
func (*StyledText) Red ¶
func (s *StyledText) Red(text string) *StyledText
func (*StyledText) Space ¶
func (s *StyledText) Space(n ...int) *StyledText
func (*StyledText) String ¶
func (s *StyledText) String() string
func (*StyledText) Text ¶
func (s *StyledText) Text(text string) *StyledText
func (*StyledText) With ¶
func (s *StyledText) With(styles ...TextStyle) *StyledTextBuilder
func (*StyledText) Write ¶ added in v0.1.0
func (s *StyledText) Write(output ...io.Writer)
func (*StyledText) Yellow ¶
func (s *StyledText) Yellow(text string) *StyledText
type StyledTextBuilder ¶
type StyledTextBuilder struct {
// contains filtered or unexported fields
}
func (*StyledTextBuilder) Text ¶
func (b *StyledTextBuilder) Text(content string) *StyledText
Click to show internal directories.
Click to hide internal directories.