38 lines
765 B
Go
38 lines
765 B
Go
package aes
|
|
|
|
import "fmt"
|
|
|
|
// The type implements more or less
|
|
type EffectText struct {
|
|
Effects Effects
|
|
Text string
|
|
}
|
|
|
|
func (et EffectText) String() string {
|
|
return fmt.Sprintf(
|
|
CSI+"%sm%s"+CSI+"0m",
|
|
et.Effects.Format(), et.Text,
|
|
)
|
|
}
|
|
|
|
// Create new EffectText with formatted
|
|
// by the fmt.Sprintf string as text data.
|
|
func ETF(format string, v ...any) EffectText {
|
|
ret := EffectText{}
|
|
ret.Text = fmt.Sprintf(format, v...)
|
|
return ret
|
|
}
|
|
|
|
// Returns the new EffectText with specified
|
|
// effects appended.
|
|
func (et EffectText) With(effects ...Effect) EffectText {
|
|
et.Effects = append(et.Effects, effects...)
|
|
return et
|
|
}
|
|
|
|
// Add the bold effect and return
|
|
// the resulting EffectText.
|
|
func (et EffectText) Bold() EffectText {
|
|
return et.With(EffectBold)
|
|
}
|
|
|