Documentation
¶
Index ¶
- Constants
- func AsJson(i interface{}) string
- func CaseAwareContains(haystack, needle string) bool
- func CaseInsensitiveContains(haystack, needle string) bool
- func Clamp(x int, min int, max int) int
- func ContainsUppercase(s string) bool
- func Decolorise(str string) string
- func DeleteTodos(fileName string, todosToDelete []Todo, commentChar byte) ([]byte, error)
- func DropMergeCommit(fileName string, hash string, commentChar byte) error
- func EditRebaseTodo(filePath string, changes []TodoChange, commentChar byte) error
- func EqualSlices[T comparable](slice1 []T, slice2 []T) bool
- func EscapeSpecialChars(str string) string
- func FilePath(skip int) string
- func FilterStrings(needle string, haystack []string, useFuzzySearch bool) []string
- func Find(pattern string, data []string, useFuzzySearch bool) fuzzy.Matches
- func FindFrom(pattern string, data fuzzy.Source, useFuzzySearch bool) fuzzy.Matches
- func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string
- func FindStringSubmatch(str string, regexpStr string) (bool, []string)
- func FindSubstrings(pattern string, data []string) fuzzy.Matches
- func FindSubstringsFrom(pattern string, data fuzzy.Source) fuzzy.Matches
- func ForEachLineInFile(path string, f func(string, int)) error
- func FormatPaths(paths []string) string
- func GetProjectRoot() string
- func IsValidHexValue(v string) bool
- func Limit(values []string, limit int) []string
- func LimitStr(value string, limit int) string
- func Loader(now time.Time, config config.SpinnerConfig) string
- func MaxFn[T any](items []T, fn func(T) int) int
- func ModuloWithWrap(n, max int) int
- func Move[T any](slice []T, fromIndex int, toIndex int) []T
- func MoveElement[T any](slice []T, from int, to int) []T
- func MoveFixupCommitDown(fileName string, originalHash string, fixupHash string, changeToFixup bool, ...) error
- func MoveTodosDown(fileName string, todosToMove []Todo, isInRebase bool, commentChar byte) error
- func MoveTodosUp(fileName string, todosToMove []Todo, isInRebase bool, commentChar byte) error
- func MuiltiGroupBy[T any, K comparable](slice []T, f func(T) []K) map[K][]T
- func MustConvertToInt(s string) int
- func NewDummyCommon() *common.Common
- func NewDummyCommonWithUserConfigAndAppState(userConfig *config.UserConfig, appState *config.AppState) *common.Common
- func NewDummyLog() *logrus.Entry
- func NextIndex(numbers []int, currentNumber int) int
- func NextIntInCycle(sl []int, current int) int
- func NormalizeLinefeeds(str string) string
- func Partition[T any](slice []T, test func(T) bool) ([]T, []T)
- func Pop[T any](slice []T) (T, []T)
- func Prepend[T any](slice []T, values ...T) []T
- func PrependStrToTodoFile(filePath string, linesToPrepend []byte) error
- func PrevIndex(numbers []int, currentNumber int) int
- func PrevIntInCycle(sl []int, current int) int
- func ReadRebaseTodoFile(fileName string, commentChar byte) ([]todo.Todo, error)
- func Remove[T any](slice []T, index int) []T
- func RemoveUpdateRefsForCopiedBranch(fileName string, commentChar byte) error
- func RenderDisplayStrings(displayStringsArr [][]string, columnAlignments []Alignment) ([]string, []int)
- func ResolvePlaceholderString(str string, arguments map[string]string) string
- func ResolveTemplate(templateStr string, object interface{}, funcs template.FuncMap) (string, error)
- func Safe(f func())
- func SafeTruncate(str string, limit int) string
- func SafeWithError(f func() error) error
- func ScanLinesAndTruncateWhenLongerThanBuffer(maxBufferSize int) func(data []byte, atEOF bool) (int, []byte, error)
- func SetCustomColors(customColors map[string]string) map[string]style.TextStyle
- func Shift[T any](slice []T) (T, []T)
- func ShortHash(hash string) string
- func SortRange(x int, y int) (int, int)
- func SplitLines(multilineString string) []string
- func SplitNul(str string) []string
- func StackTrace() string
- func StringArraysOverlap(strArrA []string, strArrB []string) bool
- func StringWidth(s string) int
- func TruncateWithEllipsis(str string, limit int) string
- func UnixToDateSmart(now time.Time, timestamp int64, longTimeFormat string, shortTimeFormat string) string
- func UnixToTimeAgo(timestamp int64) string
- func ValuesAtIndices[T any](slice []T, indices []int) []T
- func WithPadding(str string, padding int, alignment Alignment) string
- func WrapError(err error) error
- func WrapViewLinesToWidth(wrap bool, text string, width int) ([]string, []int, []int)
- func WriteRebaseTodoFile(fileName string, todos []todo.Todo, commentChar byte) error
- type Alignment
- type ColumnConfig
- type HistoryBuffer
- type OnceWriter
- type StringStack
- type ThreadSafeMap
- func (m *ThreadSafeMap[K, V]) Clear()
- func (m *ThreadSafeMap[K, V]) Delete(key K)
- func (m *ThreadSafeMap[K, V]) Get(key K) (V, bool)
- func (m *ThreadSafeMap[K, V]) Has(key K) bool
- func (m *ThreadSafeMap[K, V]) IsEmpty() bool
- func (m *ThreadSafeMap[K, V]) Keys() []K
- func (m *ThreadSafeMap[K, V]) Len() int
- func (m *ThreadSafeMap[K, V]) Set(key K, value V)
- func (m *ThreadSafeMap[K, V]) Values() []V
- type Todo
- type TodoChange
Constants ¶
const ( SECONDS_IN_SECOND = 1 SECONDS_IN_MINUTE = 60 SECONDS_IN_HOUR = 3600 SECONDS_IN_DAY = 86400 SECONDS_IN_WEEK = 604800 SECONDS_IN_YEAR = 31536000 SECONDS_IN_MONTH = SECONDS_IN_YEAR / 12 )
const COMMIT_HASH_SHORT_SIZE = 8
Variables ¶
This section is empty.
Functions ¶
func CaseAwareContains ¶ added in v0.39.0
func CaseInsensitiveContains ¶ added in v0.39.0
func ContainsUppercase ¶ added in v0.39.0
func Decolorise ¶ added in v0.7.1
Decolorise strips a string of color
func DeleteTodos ¶ added in v0.41.0
Unlike the other functions in this file, which write the changed todos file back to disk, this one returns the new content as a byte slice. This is because when deleting update-ref todos, we must perform a "git rebase --edit-todo" command to pass the changed todos to git so that it can do some housekeeping around the deleted todos. This can only be done by our caller.
func DropMergeCommit ¶ added in v0.45.0
func EditRebaseTodo ¶ added in v0.38.0
func EditRebaseTodo(filePath string, changes []TodoChange, commentChar byte) error
Read a git-rebase-todo file, change the actions for the given commits, and write it back
func EqualSlices ¶ added in v0.44.0
func EqualSlices[T comparable](slice1 []T, slice2 []T) bool
Compares two slices for equality
func EscapeSpecialChars ¶ added in v0.30.1
EscapeSpecialChars - Replaces all special chars like \n with \\n
func FilePath ¶ added in v0.36.0
returns the path of the file that calls the function. 'skip' is the number of stack frames to skip.
func FilterStrings ¶ added in v0.41.0
func FindNamedMatches ¶ added in v0.32.1
func FindStringSubmatch ¶ added in v0.20.1
func FindSubstrings ¶ added in v0.41.0
Drop-in replacement for fuzzy.Find (except that it doesn't fill out MatchedIndexes or Score, but we are not using these)
func FindSubstringsFrom ¶ added in v0.41.0
Drop-in replacement for fuzzy.FindFrom (except that it doesn't fill out MatchedIndexes or Score, but we are not using these)
func ForEachLineInFile ¶ added in v0.28.2
func FormatPaths ¶ added in v0.41.0
Returns comma-separated list of paths, with ellipsis if there are more than 3 e.g. "foo, bar, baz, [...3 more]"
func GetProjectRoot ¶ added in v0.1.71
func GetProjectRoot() string
GetProjectRoot returns the path to the root of the project. Only to be used in testing contexts, as with binaries it's unlikely this path will exist on the machine
func IsValidHexValue ¶ added in v0.30.1
func Loader ¶ added in v0.2.0
func Loader(now time.Time, config config.SpinnerConfig) string
Loader dumps a string to be displayed as a loader
func ModuloWithWrap ¶ added in v0.11.1
used to keep a number n between 0 and max, allowing for wraparounds
func Move ¶ added in v0.40.0
Removes the element at the 'fromIndex' and then inserts it at 'toIndex'. Operates on the input slice. Expected use is to reassign the result to the input slice.
func MoveElement ¶ added in v0.38.0
Returns a new slice with the element at index 'from' moved to index 'to'. Does not mutate original slice.
func MoveFixupCommitDown ¶ added in v0.38.0
func MoveTodosDown ¶ added in v0.41.0
func MoveTodosUp ¶ added in v0.41.0
func MuiltiGroupBy ¶ added in v0.35.0
func MuiltiGroupBy[T any, K comparable](slice []T, f func(T) []K) map[K][]T
Similar to a regular GroupBy, except that each item can be grouped under multiple keys, so the callback returns a slice of keys instead of just one key.
func MustConvertToInt ¶ added in v0.22.0
func NewDummyCommon ¶ added in v0.32.1
func NewDummyCommonWithUserConfigAndAppState ¶ added in v0.41.0
func NewDummyLog ¶ added in v0.23.1
NewDummyLog creates a new dummy Log for testing
func NextIndex ¶ added in v0.7.1
NextIndex returns the index of the element that comes after the given number
func NextIntInCycle ¶ added in v0.15.1
NextIntInCycle returns the next int in a slice, returning to the first index if we've reached the end
func NormalizeLinefeeds ¶ added in v0.1.79
NormalizeLinefeeds - Removes all Windows and Mac style line feeds
func Partition ¶ added in v0.40.0
returns two slices: the first is for elements that pass the test, the second for those that don't.
func Pop ¶ added in v0.40.0
func Pop[T any](slice []T) (T, []T)
Pops item from the end of the slice and returns it, along with the updated slice Mutates original slice. Intended usage is to reassign the slice result to the input slice.
func Prepend ¶ added in v0.40.0
func Prepend[T any](slice []T, values ...T) []T
Prepends items to the beginning of a slice. E.g. Prepend([]int{1,2}, 3, 4) = []int{3,4,1,2} Mutates original slice. Intended usage is to reassign the slice result to the input slice.
func PrependStrToTodoFile ¶ added in v0.38.0
func PrevIndex ¶ added in v0.7.1
PrevIndex returns the index that comes before the given number, cycling if we reach the end
func PrevIntInCycle ¶ added in v0.15.1
PrevIntInCycle returns the prev int in a slice, returning to the first index if we've reached the end
func ReadRebaseTodoFile ¶ added in v0.38.0
func Remove ¶ added in v0.40.0
Removes the element at the given index. Intended usage is to reassign the result to the input slice.
func RemoveUpdateRefsForCopiedBranch ¶ added in v0.42.0
func RenderDisplayStrings ¶ added in v0.14.4
func RenderDisplayStrings(displayStringsArr [][]string, columnAlignments []Alignment) ([]string, []int)
defaults to left-aligning each column. If you want to set the alignment of each column, pass in a slice of Alignment values. returns a list of strings that should be joined with "\n", and an array of the column positions
func ResolvePlaceholderString ¶ added in v0.2.2
ResolvePlaceholderString populates a template with values
func ResolveTemplate ¶ added in v0.23.1
func Safe ¶ added in v0.23.1
func Safe(f func())
Safe will close tcell if a panic occurs so that we don't end up in a malformed terminal state
func SafeTruncate ¶ added in v0.30.1
func SafeWithError ¶ added in v0.27.1
func ScanLinesAndTruncateWhenLongerThanBuffer ¶ added in v0.42.0
func ScanLinesAndTruncateWhenLongerThanBuffer(maxBufferSize int) func(data []byte, atEOF bool) (int, []byte, error)
ScanLinesAndTruncateWhenLongerThanBuffer returns a split function that can be used with bufio.Scanner.Split(). It is very similar to bufio.ScanLines, except that it will truncate lines that are longer than the scanner's read buffer (whereas bufio.ScanLines will return an error in that case, which is often difficult to handle).
If you are using your own buffer for the scanner, you must set maxBufferSize to the same value as the max parameter that you passed to scanner.Buffer(). Otherwise, maxBufferSize must be set to bufio.MaxScanTokenSize.
func SetCustomColors ¶ added in v0.35.0
func Shift ¶ added in v0.40.0
func Shift[T any](slice []T) (T, []T)
Shifts item from the beginning of the slice and returns it, along with the updated slice. Mutates original slice. Intended usage is to reassign the slice result to the input slice.
func SplitLines ¶
SplitLines takes a multiline string and splits it on newlines currently we are also stripping \r's which may have adverse effects for windows users (but no issues have been raised yet)
func StackTrace ¶ added in v0.27.1
func StackTrace() string
func StringArraysOverlap ¶ added in v0.22.0
func StringWidth ¶ added in v0.43.0
func TruncateWithEllipsis ¶ added in v0.15.3
TruncateWithEllipsis returns a string, truncated to a certain length, with an ellipsis
func UnixToDateSmart ¶ added in v0.39.0
func UnixToDateSmart(now time.Time, timestamp int64, longTimeFormat string, shortTimeFormat string) string
formats the date in a smart way, if the date is today, it will show the time, otherwise it will show the date
func UnixToTimeAgo ¶ added in v0.20.1
func ValuesAtIndices ¶ added in v0.39.0
func WithPadding ¶
WithPadding pads a string as much as you want
func WrapError ¶ added in v0.23.1
WrapError wraps an error for the sake of showing a stack trace at the top level the go-errors package, for some reason, does not return nil when you try to wrap a non-error, so we're just doing it here
func WrapViewLinesToWidth ¶ added in v0.45.0
Wrap lines to a given width, and return: - the wrapped lines - the line indices of the wrapped lines, indexed by the original line indices - the line indices of the original lines, indexed by the wrapped line indices If wrap is false, the text is returned as is. This code needs to behave the same as `gocui.lineWrap` does.
Types ¶
type ColumnConfig ¶ added in v0.39.0
type HistoryBuffer ¶ added in v0.41.0
type HistoryBuffer[T any] struct { // contains filtered or unexported fields }
func NewHistoryBuffer ¶ added in v0.41.0
func NewHistoryBuffer[T any](maxSize int) *HistoryBuffer[T]
func (*HistoryBuffer[T]) PeekAt ¶ added in v0.41.0
func (self *HistoryBuffer[T]) PeekAt(index int) (T, error)
func (*HistoryBuffer[T]) Push ¶ added in v0.41.0
func (self *HistoryBuffer[T]) Push(item T)
type OnceWriter ¶ added in v0.36.0
type OnceWriter struct {
// contains filtered or unexported fields
}
func NewOnceWriter ¶ added in v0.36.0
func NewOnceWriter(writer io.Writer, f func()) *OnceWriter
type StringStack ¶ added in v0.35.0
type StringStack struct {
// contains filtered or unexported fields
}
func (*StringStack) Clear ¶ added in v0.35.0
func (self *StringStack) Clear()
func (*StringStack) IsEmpty ¶ added in v0.35.0
func (self *StringStack) IsEmpty() bool
func (*StringStack) Pop ¶ added in v0.35.0
func (self *StringStack) Pop() string
func (*StringStack) Push ¶ added in v0.35.0
func (self *StringStack) Push(s string)
type ThreadSafeMap ¶ added in v0.36.0
type ThreadSafeMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewThreadSafeMap ¶ added in v0.36.0
func NewThreadSafeMap[K comparable, V any]() *ThreadSafeMap[K, V]
func (*ThreadSafeMap[K, V]) Clear ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Clear()
func (*ThreadSafeMap[K, V]) Delete ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Delete(key K)
func (*ThreadSafeMap[K, V]) Get ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Get(key K) (V, bool)
func (*ThreadSafeMap[K, V]) Has ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Has(key K) bool
func (*ThreadSafeMap[K, V]) IsEmpty ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) IsEmpty() bool
func (*ThreadSafeMap[K, V]) Keys ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Keys() []K
func (*ThreadSafeMap[K, V]) Len ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Len() int
func (*ThreadSafeMap[K, V]) Set ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Set(key K, value V)
func (*ThreadSafeMap[K, V]) Values ¶ added in v0.36.0
func (m *ThreadSafeMap[K, V]) Values() []V
type TodoChange ¶ added in v0.41.0
type TodoChange struct { Hash string NewAction todo.TodoCommand }