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.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Pretty wraps a paragraph as it would, but for its last line, which takes
|
|
// a word from the line before rather than hold one alone.
|
|
func TestPrettyText(t *testing.T) {
|
|
last := func(n *node) string {
|
|
l := n.tl.Lines[len(n.tl.Lines)-1]
|
|
return strings.TrimSpace(string(n.tl.Runes[l.Start:l.End]))
|
|
}
|
|
// The first of these texts whose last line, wrapped as it is, is a
|
|
// word alone: where it wraps depends on the system's fonts.
|
|
words := strings.Fields("Body text wraps its words over as many lines as it takes and then ends on a word that is alone x")
|
|
var plain, pretty *node
|
|
for n := 8; n <= len(words); n++ {
|
|
s := strings.Join(words[:n], " ")
|
|
coreNewTester(func(c *context) {
|
|
coreColumn(c).Width(240).AlignItems(Start).Children(func() {
|
|
plain = coreText(c, s).FontSize(20)
|
|
pretty = coreText(c, s).FontSize(20).Pretty()
|
|
})
|
|
}, 400, 400)
|
|
if len(plain.tl.Lines) >= 2 && !strings.Contains(last(plain), " ") {
|
|
break
|
|
}
|
|
}
|
|
pl, pr := plain.tl.Lines, pretty.tl.Lines
|
|
if len(pl) < 2 || strings.Contains(last(plain), " ") {
|
|
t.Fatalf("no text ends on a word alone: %d lines, the last %q", len(pl), last(plain))
|
|
}
|
|
if len(pr) != len(pl) || !strings.Contains(last(pretty), " ") {
|
|
t.Errorf("%d lines pretty, the last %q", len(pr), last(pretty))
|
|
}
|
|
for i := range len(pl) - 2 {
|
|
if pl[i].Start != pr[i].Start || pl[i].End != pr[i].End {
|
|
t.Errorf("line %d moved: %d-%d, pretty %d-%d", i, pl[i].Start, pl[i].End, pr[i].Start, pr[i].End)
|
|
}
|
|
}
|
|
if !pretty.tl.Params.Pretty {
|
|
t.Error("the layout is not pretty")
|
|
}
|
|
}
|