mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-24 17:50:15 +09:00
More actions and view relocation
This commit is contained in:
@@ -231,3 +231,19 @@ func EscapePath(path string) string {
|
||||
path = filepath.ToSlash(path)
|
||||
return strings.Replace(path, "/", "%", -1)
|
||||
}
|
||||
|
||||
// GetLeadingWhitespace returns the leading whitespace of the given byte array
|
||||
func GetLeadingWhitespace(b []byte) []byte {
|
||||
ws := []byte{}
|
||||
for len(b) > 0 {
|
||||
r, size := utf8.DecodeRune(b)
|
||||
if r == ' ' || r == '\t' {
|
||||
ws = append(ws, byte(r))
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
b = b[size:]
|
||||
}
|
||||
return ws
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user