util

package
v0.0.0-...-c52b49e Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsUint16

func AsUint16(val int) uint16

func Constrain

func Constrain(val int, min int, max int) int

Constrain limits the given integer with the upper and lower bounds

func Constrain32

func Constrain32(val int32, min int32, max int32) int32

Constrain32 limits the given 32-bit integer with the upper and lower bounds

func DurWithin

func DurWithin(
	val time.Duration, min time.Duration, max time.Duration) time.Duration

DurWithin limits the given time.Duration with the upper and lower bounds

func ExecCommand

func ExecCommand(command string, setpgid bool) *exec.Cmd

ExecCommand executes the given command with $SHELL

func ExecCommandWith

func ExecCommandWith(shell string, command string, setpgid bool) *exec.Cmd

ExecCommandWith executes the given command with the specified shell

func IsTty

func IsTty() bool

IsTty returns true is stdin is a terminal

func IsWindows

func IsWindows() bool

IsWindows returns true on Windows

func KillCommand

func KillCommand(cmd *exec.Cmd) error

KillCommand kills the process for the given command

func Max

func Max(first int, second int) int

Max returns the largest integer

func Max16

func Max16(first int16, second int16) int16

Max16 returns the largest integer

func Max32

func Max32(first int32, second int32) int32

Max32 returns the largest 32-bit integer

func Min

func Min(first int, second int) int

Min returns the smallest integer

func Min32

func Min32(first int32, second int32) int32

Min32 returns the smallest 32-bit integer

func Once

func Once(nextResponse bool) func() bool

Once returns a function that returns the specified boolean value only once

func Read

func Read(fd int, b []byte) (int, error)

Read executes syscall.Read on file descriptor

func RunesWidth

func RunesWidth(runes []rune, prefixWidth int, tabstop int, limit int) (int, int)

RunesWidth returns runes width

func SetNonblock

func SetNonblock(file *os.File, nonblock bool)

SetNonblock executes syscall.SetNonblock on file descriptor

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

func RunesToChars(runes []rune) Chars

func ToChars

func ToChars(bytes []byte) Chars

ToChars converts byte array into rune array

func (*Chars) Bytes

func (chars *Chars) Bytes() []byte

func (*Chars) CopyRunes

func (chars *Chars) CopyRunes(dest []rune)

func (*Chars) Get

func (chars *Chars) Get(i int) rune

func (*Chars) IsBytes

func (chars *Chars) IsBytes() bool

func (*Chars) LeadingWhitespaces

func (chars *Chars) LeadingWhitespaces() int

func (*Chars) Length

func (chars *Chars) Length() int

func (*Chars) Prepend

func (chars *Chars) Prepend(prefix string)

func (*Chars) String

func (chars *Chars) String() string

String returns the string representation of a Chars object.

func (*Chars) ToRunes

func (chars *Chars) ToRunes() []rune

func (*Chars) ToString

func (chars *Chars) ToString() string

func (*Chars) TrailingWhitespaces

func (chars *Chars) TrailingWhitespaces() int

func (*Chars) TrimLength

func (chars *Chars) TrimLength() uint16

TrimLength returns the length after trimming leading and trailing whitespaces

func (*Chars) TrimTrailingWhitespaces

func (chars *Chars) TrimTrailingWhitespaces()

type EventBox

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

EventBox is used for coordinating events

func NewEventBox

func NewEventBox() *EventBox

NewEventBox returns a new EventBox

func (*EventBox) Peek

func (b *EventBox) Peek(event EventType) bool

Peek peeks at the event box if the given event is set

func (*EventBox) Set

func (b *EventBox) Set(event EventType, value interface{})

Set turns on the event type on the box

func (*EventBox) Unwatch

func (b *EventBox) Unwatch(events ...EventType)

Unwatch adds the events to the ignore list

func (*EventBox) Wait

func (b *EventBox) Wait(callback func(*Events))

Wait blocks the goroutine until signaled

func (*EventBox) WaitFor

func (b *EventBox) WaitFor(event EventType)

WaitFor blocks the execution until the event is received

func (*EventBox) Watch

func (b *EventBox) Watch(events ...EventType)

Watch deletes the events from the ignore list

type EventType

type EventType int

EventType is the type for fzf events

type Events

type Events map[EventType]interface{}

Events is a type that associates EventType to any data

func (*Events) Clear

func (events *Events) Clear()

Clear clears the events Unsynchronized; should be called within Wait routine

type Slab

type Slab struct {
	I16 []int16
	I32 []int32
}

func MakeSlab

func MakeSlab(size16 int, size32 int) *Slab

Jump to

Keyboard shortcuts

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