Something went wrong. Try again.
Fork of micro-editor/micro
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142package util
// LuaRuneAt is a helper function for lua plugins to return the rune// at an index within a stringfunc LuaRuneAt(str string, runeidx int) string { i := 0 for len(str) > 0 { r, _, size := DecodeCharacterInString(str)
str = str[size:]
if i == runeidx { return string(r) }
i++ } return ""}
// LuaGetLeadingWhitespace returns the leading whitespace of a string (used by lua plugins)func LuaGetLeadingWhitespace(s string) string { ws := []byte{} for len(s) > 0 { r, _, size := DecodeCharacterInString(s) if r == ' ' || r == '\t' { ws = append(ws, byte(r)) } else { break }
s = s[size:] } return string(ws)}
// LuaIsWordChar returns true if the first rune in a string is a word characterfunc LuaIsWordChar(s string) bool { r, _, _ := DecodeCharacterInString(s) return IsWordChar(r)}