shortcut.go 765 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package aes
  2. import "fmt"
  3. // The type implements more or less
  4. type EffectText struct {
  5. Effects Effects
  6. Text string
  7. }
  8. func (et EffectText) String() string {
  9. return fmt.Sprintf(
  10. CSI+"%sm%s"+CSI+"0m",
  11. et.Effects.Format(), et.Text,
  12. )
  13. }
  14. // Create new EffectText with formatted
  15. // by the fmt.Sprintf string as text data.
  16. func ETF(format string, v ...any) EffectText {
  17. ret := EffectText{}
  18. ret.Text = fmt.Sprintf(format, v...)
  19. return ret
  20. }
  21. // Returns the new EffectText with specified
  22. // effects appended.
  23. func (et EffectText) With(effects ...Effect) EffectText {
  24. et.Effects = append(et.Effects, effects...)
  25. return et
  26. }
  27. // Add the bold effect and return
  28. // the resulting EffectText.
  29. func (et EffectText) Bold() EffectText {
  30. return et.With(EffectBold)
  31. }