Documentation
¶
Index ¶
- func AsUint16(val int) uint16
- func AtExit(fn func())
- func CompareVersions(v1, v2 string) int
- func Constrain[T cmp.Ordered](val, minimum, maximum T) T
- func IsTty(file *os.File) bool
- func IsWindows() bool
- func KillCommand(cmd *exec.Cmd) error
- func MayFoldToAscii(r rune) bool
- func Once(nextResponse bool) func() bool
- func Read(fd int, b []byte) (int, error)
- func RepeatToFill(str string, length int, limit int) string
- func RunAtExitFuncs()
- func RunOnce(f func()) func()
- func RunesWidth(runes []rune, prefixWidth int, tabstop int, limit int) (int, int)
- func SetNonblock(file *os.File, nonblock bool)
- func SetStdin(file *os.File)
- func StringWidth(s string) int
- func StringsWidth(str string, prefixWidth int, tabstop int, limit int) (int, int)
- func ToKebabCase(s string) string
- func Truncate(input string, limit int) ([]rune, int)
- type AtomicBool
- type Chars
- func (chars *Chars) Bytes() []byte
- func (chars *Chars) CopyRunes(dest []rune, from int)
- func (chars *Chars) Get(i int) rune
- func (chars *Chars) IsBytes() bool
- func (chars *Chars) LeadingWhitespaces() int
- func (chars *Chars) Length() int
- func (chars *Chars) Lines(multiLine bool, maxLines int, wrapCols int, wrapSignWidth int, tabstop int, ...) ([][]rune, bool)
- func (chars *Chars) MayFoldToAscii() bool
- func (chars *Chars) NumLines(atMost int) (int, bool)
- func (chars *Chars) Prepend(prefix string)
- func (chars *Chars) Runes() []rune
- func (chars *Chars) SliceRight(last int)
- func (chars *Chars) String() string
- func (chars *Chars) ToRunes() []rune
- func (chars *Chars) ToString() string
- func (chars *Chars) TrailingWhitespaces() int
- func (chars *Chars) TrimLength() uint16
- func (chars *Chars) TrimSuffix(runes []rune)
- func (chars *Chars) TrimTrailingWhitespaces(maxIndex int)
- type ConcurrentSet
- type EventBox
- type EventType
- type Events
- type Executor
- type Slab
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtExit ¶
func AtExit(fn func())
AtExit registers the function fn to be called on program termination. The functions will be called in reverse order they were registered.
func CompareVersions ¶
CompareVersions compares two version strings
func KillCommand ¶
KillCommand kills the process for the given command
func MayFoldToAscii ¶ added in v0.74.3
MayFoldToAscii reports whether case folding or normalization could turn r into an ASCII character.
func RepeatToFill ¶
RepeatToFill repeats the given string to fill the given width
func RunAtExitFuncs ¶
func RunAtExitFuncs()
RunAtExitFuncs runs any functions registered with AtExit().
func RunesWidth ¶
RunesWidth returns runes width
func SetNonblock ¶
SetNonblock executes syscall.SetNonblock on file descriptor
func StringWidth ¶
StringWidth returns string width where each CR/LF character takes 1 column
func StringsWidth ¶ added in v0.68.0
StringsWidth returns the width of the string
func ToKebabCase ¶
ToKebabCase converts the given CamelCase string to kebab-case
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool is a boxed-class that provides synchronized access to the underlying boolean value
func NewAtomicBool ¶
func NewAtomicBool(initialState bool) *AtomicBool
NewAtomicBool returns a new AtomicBool
func (*AtomicBool) Get ¶
func (a *AtomicBool) Get() bool
Get returns the current boolean value synchronously
func (*AtomicBool) Set ¶
func (a *AtomicBool) Set(newState bool) bool
Set updates the boolean value synchronously
type Chars ¶
type Chars struct {
// XXX Piggybacking item index here is a horrible idea. But I'm trying to
// minimize the memory footprint by not wasting padded spaces.
Index int32
// contains filtered or unexported fields
}
func RunesToChars ¶
RunesToChars adopts the caller's slice rather than copying it, so the caller must not keep mutating it. See Runes for why.
func (*Chars) LeadingWhitespaces ¶
func (*Chars) MayFoldToAscii ¶ added in v0.74.3
MayFoldToAscii reports whether the text holds a rune that case folding or normalization could turn into an ASCII character. When false, an ASCII pattern character can only match the identical ASCII rune, which is what lets the prefilter scan the rune array directly.
func (*Chars) Runes ¶ added in v0.74.3
Runes returns the underlying rune slice, or nil if the text is kept as bytes. Read only. The result aliases the text, so writing to it would change the text without updating the cached fold bit, and the prefilter would then reject items it should match. Copy before mutating.
func (*Chars) SliceRight ¶ added in v0.60.0
func (*Chars) ToRunes ¶
ToRunes returns the text as runes. In rune mode the result aliases the text and must not be mutated, see Runes. In byte mode it is a fresh slice.
func (*Chars) TrailingWhitespaces ¶
func (*Chars) TrimLength ¶
TrimLength returns the length after trimming leading and trailing whitespaces
func (*Chars) TrimSuffix ¶ added in v0.60.0
func (*Chars) TrimTrailingWhitespaces ¶
type ConcurrentSet ¶ added in v0.63.0
type ConcurrentSet[T comparable] struct { // contains filtered or unexported fields }
ConcurrentSet is a thread-safe set implementation.
func NewConcurrentSet ¶ added in v0.63.0
func NewConcurrentSet[T comparable]() *ConcurrentSet[T]
NewConcurrentSet creates a new ConcurrentSet.
func (*ConcurrentSet[T]) Add ¶ added in v0.63.0
func (s *ConcurrentSet[T]) Add(item T)
Add adds an item to the set.
func (*ConcurrentSet[T]) ForEach ¶ added in v0.63.0
func (s *ConcurrentSet[T]) ForEach(fn func(item T))
ForEach iterates over each item in the set and applies the provided function.
func (*ConcurrentSet[T]) Remove ¶ added in v0.63.0
func (s *ConcurrentSet[T]) Remove(item T)
Remove removes an item from the set.
type EventBox ¶
type EventBox struct {
// contains filtered or unexported fields
}
EventBox is used for coordinating events
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func (*Executor) ExecCommand ¶
ExecCommand executes the given command with $SHELL