util

package
v0.0.0-...-a67dd81 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: MIT, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToRunes

func BytesToRunes(bytea []byte) []rune

BytesToRunes converts byte array into rune array

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) *exec.Cmd

ExecCommand executes the given command with $SHELL

func IsTty

func IsTty() bool

IsTty returns true is stdin is a terminal

func Max

func Max(first int, items ...int) int

Max returns the largest integer

func Max32

func Max32(first int32, second int32) int32

Max32 returns the largest 32-bit integer

func Min32

func Min32(first int32, second int32) int32

Min32 returns the smallest 32-bit integer

func TrimLen

func TrimLen(runes []rune) int

TrimLen returns the length of trimmed rune array

func TrimRight

func TrimRight(runes []rune) []rune

TrimRight returns rune array with trailing white spaces cut off

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 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

Jump to

Keyboard shortcuts

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