String

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type String

type String struct {
	// contains filtered or unexported fields
}

String represents a unit of data in a draw table with a specific style.

func FieldsFunc

func FieldsFunc(s *String, sep string) []*String

FieldsFunc splits a string into fields using a function to determine the separator.

Parameters:

  • s: The string to split.
  • sep: The function to determine the separator.

Returns:

  • []*String: The fields of the string.

func Join

func Join(elems []*String, sep string) *String

Join joins a slice of strings with a separator.

Parameters:

  • elems: The slice of strings to join.
  • sep: The separator to join the strings with.

Returns:

  • *String: The joined string.

Behaviors:

  • If the slice of strings is empty, a nil string is returned.
  • The style of the first string is used for the joined string.
  • The separator is not added to the end of the joined string.

func NewString

func NewString(content string) *String

NewDtUnit creates a new DtUnit with the given content and style.

Parameters:

  • content: The content of the unit.

Returns:

  • *DtUnit: The new DtUnit.

func Repeat

func Repeat(s *String, count int) *String

Repeat repeats a string count times.

Parameters:

  • s: The string to repeat.
  • count: The number of times to repeat the string.

Returns:

  • *String: The repeated string.

Behaviors:

  • If the count is less than or equal to 0, nil is returned.

func (*String) AppendRune

func (s *String) AppendRune(r rune)

AppendRune appends a rune to the content of the unit.

Parameters:

  • r: The rune to append.

func (*String) AppendString

func (s *String) AppendString(otherS string)

AppendString appends a string to the content of the unit.

Parameters:

  • otherS: The string to append.

func (*String) Copy

func (s *String) Copy() com.Copier

Copy returns a copy of the unit.

Returns:

  • com.Copier: A copy of the unit.

func (*String) Equals

func (s *String) Equals(other com.Equaler) bool

Equals implements common.Objecter.

func (*String) Fields

func (s *String) Fields() []*String

Fields splits a string into fields.

Returns:

  • []*String: The fields of the string.

func (*String) GetContent

func (s *String) GetContent() string

GetContent returns the content of the unit.

Returns:

  • string: The content of the unit.

func (*String) GetLength

func (s *String) GetLength() int

GetLength returns the length of the content.

Returns:

  • int: The length of the content.

func (*String) PrependRune

func (s *String) PrependRune(r rune)

PrependRune prepends a rune to the content of the unit.

Parameters:

  • r: The rune to prepend.

func (*String) PrependString

func (s *String) PrependString(otherS string)

PrependString prepends a string to the content of the unit.

Parameters:

  • otherS: The string to prepend.

func (*String) ReplaceSuffix

func (s *String) ReplaceSuffix(suffix string) bool

ReplaceSuffix replaces the end of the string with the given suffix. It fails if the suffix is longer than the string.

Parameters:

  • suffix: The suffix to replace the end of the string.

Returns:

  • bool: True if the suffix was replaced, and false otherwise.

func (*String) Runes

func (s *String) Runes(width, height int) ([][]rune, error)

Runes returns the content of the unit as a slice of runes.

Parameters:

  • width: The width of the table.
  • height: The height of the table.

Returns:

  • [][]rune: The content of the unit as a slice of runes.
  • error: An error if the content could not be converted to runes.

Behaviors:

  • Always assume that the width and height are greater than 0. No need to check for this.
  • Never errors.

func (*String) String

func (s *String) String() string

String returns the content of the unit as a string.

Returns:

  • string: The content of the unit.

func (*String) TrimEnd

func (s *String) TrimEnd(limit int) *String

TrimEnd trims the end of the string to the given limit.

Parameters:

  • limit: The limit to trim the string to.

Returns:

  • *String: The trimmed string.

Behaviors:

  • If the limit is less than or equal to 0, the string is set to an empty string.
  • If the limit is greater than the length of the string, the string is unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL