IsWordBreak defines what counts as a word break for the purposes of selecting words. r1 is the rune in question, r2 is the rune past r1 in the direction you are moving. Pass -1 for r2 if there is no rune past r1.
(r1, r2 rune)
| 1965 | // r1 is the rune in question, r2 is the rune past r1 in the direction you are moving. |
| 1966 | // Pass -1 for r2 if there is no rune past r1. |
| 1967 | func IsWordBreak(r1, r2 rune) bool { |
| 1968 | if r2 == -1 { |
| 1969 | if unicode.IsSpace(r1) || unicode.IsSymbol(r1) || unicode.IsPunct(r1) { |
| 1970 | return true |
| 1971 | } |
| 1972 | return false |
| 1973 | } |
| 1974 | if unicode.IsSpace(r1) || unicode.IsSymbol(r1) { |
| 1975 | return true |
| 1976 | } |
| 1977 | if unicode.IsPunct(r1) && r1 != rune('\'') { |
| 1978 | return true |
| 1979 | } |
| 1980 | if unicode.IsPunct(r1) && r1 == rune('\'') { |
| 1981 | if unicode.IsSpace(r2) || unicode.IsSymbol(r2) || unicode.IsPunct(r2) { |
| 1982 | return true |
| 1983 | } |
| 1984 | return false |
| 1985 | } |
| 1986 | return false |
| 1987 | } |
| 1988 | |
| 1989 | // concealDots creates an n-length []rune of bullet characters. |
| 1990 | func concealDots(n int) []rune { |
no outgoing calls
no test coverage detected