Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteNumber ¶
type ByteNumber int
Numeric type that represents the amount of bytes in a string, array or slice.
func IndexNotAny ¶
func IndexNotAny(s, chars string) ByteNumber
IndexNotAny is similar with strings.IndexAny but showing the opposite behavior.
Example ¶
package main import ( "fmt" "github.com/elk-language/go-prompt/strings" ) func main() { fmt.Println(strings.IndexNotAny("golang", "glo")) fmt.Println(strings.IndexNotAny("golang", "gl")) fmt.Println(strings.IndexNotAny("golang", "golang")) }
Output: 3 1 -1
func IndexNotByte ¶
func IndexNotByte(s string, c byte) ByteNumber
IndexNotByte is similar with strings.IndexByte but showing the opposite behavior.
Example ¶
package main import ( "fmt" "github.com/elk-language/go-prompt/strings" ) func main() { fmt.Println(strings.IndexNotByte("golang", 'g')) fmt.Println(strings.IndexNotByte("golang", 'x')) fmt.Println(strings.IndexNotByte("gggggg", 'g')) }
Output: 1 0 -1
func LastIndexNotAny ¶
func LastIndexNotAny(s, chars string) ByteNumber
LastIndexNotAny is similar with strings.LastIndexAny but showing the opposite behavior.
Example ¶
package main import ( "fmt" "github.com/elk-language/go-prompt/strings" ) func main() { fmt.Println(strings.LastIndexNotAny("golang", "agn")) fmt.Println(strings.LastIndexNotAny("golang", "an")) fmt.Println(strings.LastIndexNotAny("golang", "golang")) }
Output: 2 5 -1
func LastIndexNotByte ¶
func LastIndexNotByte(s string, c byte) ByteNumber
LastIndexNotByte is similar with strings.LastIndexByte but showing the opposite behavior.
Example ¶
package main import ( "fmt" "github.com/elk-language/go-prompt/strings" ) func main() { fmt.Println(strings.LastIndexNotByte("golang", 'g')) fmt.Println(strings.LastIndexNotByte("golang", 'x')) fmt.Println(strings.LastIndexNotByte("gggggg", 'g')) }
Output: 4 5 -1
type GraphemeNumber ¶ added in v1.1.0
type GraphemeNumber int
Numeric type that represents the amount of grapheme clusters in a string, array or slice.
func GraphemeCountInString ¶ added in v1.1.0
func GraphemeCountInString(text string) GraphemeNumber
Returns the number of horizontal cells needed to print the given text. It splits the text into its grapheme clusters, calculates each cluster's width, and adds them up to a total.
type RuneNumber ¶
type RuneNumber int
Numeric type that represents the amount of runes in a string, array or slice.
func RuneCountInString ¶ added in v1.1.0
func RuneCountInString(s string) RuneNumber
Get the length of the string in runes.
func RuneIndexNthColumn ¶ added in v1.1.0
func RuneIndexNthColumn(text string, n Width) RuneNumber
Returns the rune index of the nth column (in terms of char width) in the given text.
func RuneIndexNthGrapheme ¶ added in v1.1.0
func RuneIndexNthGrapheme(text string, n GraphemeNumber) RuneNumber
Returns the rune index of the nth grapheme in the given text.
type Width ¶
type Width int
Numeric type that represents the visible width of characters in a string as seen in a terminal emulator.
func GetRuneWidth ¶
Get the width of the rune (how many columns it takes upt in the terminal).