Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package text
|
|
|
|
import "unicode"
|
|
|
|
// Word boundaries, without a dictionary: a word is a run of letters,
|
|
// digits and underscores, as in the scripts written with spaces between
|
|
// words (Latin, Cyrillic, Greek, Hangul…), except that each Han
|
|
// ideograph, Hiragana and Katakana is a word of its own. Chinese and
|
|
// Japanese are written without spaces and only a dictionary finds their
|
|
// words (UAX #29 leaves them to one); a character at a time is what
|
|
// platforms do without one, rather than a whole sentence as one word.
|
|
// Thai, also written without spaces, keeps its runs: its vowels are
|
|
// combining marks, so a rune at a time would split syllables.
|
|
|
|
// IsWordRune reports whether r is part of a word: a letter, a digit or
|
|
// an underscore.
|
|
func IsWordRune(r rune) bool { return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' }
|
|
|
|
// StandsAlone reports whether r is a word on its own: a Han ideograph
|
|
// (with the iteration mark 々), a Hiragana or a Katakana (with the
|
|
// prolonged sound mark ー).
|
|
func StandsAlone(r rune) bool {
|
|
if r < 0x2e80 {
|
|
return false
|
|
}
|
|
switch r {
|
|
case 0x30fc, 0xff70: // ー and its halfwidth form, of the Common script
|
|
return true
|
|
}
|
|
return IsWordRune(r) && (unicode.Is(unicode.Han, r) || unicode.Is(unicode.Hiragana, r) || unicode.Is(unicode.Katakana, r))
|
|
}
|
|
|
|
// WordBoundary reports whether a and b, next to each other, are in
|
|
// different words or runs of other runes: one is part of a word and the
|
|
// other is not, or either is a word on its own (StandsAlone). Script
|
|
// changes between Latin and Han or kana and kanji are boundaries so.
|
|
func WordBoundary(a, b rune) bool {
|
|
return IsWordRune(a) != IsWordRune(b) || StandsAlone(a) || StandsAlone(b)
|
|
}
|