feat: port the client to MyGo native UI (0.3.0)
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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+73
@@ -0,0 +1,73 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestTextLines checks that TrackLines reports where the text area wraps
|
||||
// its lines and where they are, as its caret has them.
|
||||
func TestTextLines(t *testing.T) {
|
||||
long := strings.Repeat("word ", 80)
|
||||
s := "one\n" + long + "\nthree\n" + strings.Repeat("short\n", 500)
|
||||
var lines TextLines
|
||||
tt := coreNewTester(func(c *context) { coreTextArea(c, &s).TrackLines(&lines).Fill() }, 400, 300)
|
||||
tt.Frame()
|
||||
st := textAreaState(tt)
|
||||
ed, a := st.editor, st.editor.area
|
||||
if n := lines.Count(); n != 504 {
|
||||
t.Fatalf("Count = %d, want 504", n)
|
||||
}
|
||||
if rows := lines.Rows(0); len(rows) != 1 || rows[0] != 0 {
|
||||
t.Errorf("Rows(0) = %v, want [0]", rows)
|
||||
}
|
||||
rows := lines.Rows(1)
|
||||
if len(rows) < 3 || rows[0] != 0 {
|
||||
t.Fatalf("Rows(1) = %v, want several rows from 0", rows)
|
||||
}
|
||||
start := ed.buf.start(1)
|
||||
for k, r := range rows {
|
||||
_, y, _ := a.caretAt(ed, start+r, 0)
|
||||
// A row's first rune has its caret on that row.
|
||||
if want := lines.Top(1) + float32(k)*a.line.Height; float32(y) != want {
|
||||
t.Errorf("row %d starts at rune %d, at y %v; want %v", k, r, y, want)
|
||||
}
|
||||
}
|
||||
if top, want := lines.Top(2), lines.Top(1)+float32(len(rows))*a.line.Height; top != want {
|
||||
t.Errorf("Top(2) = %v, want %v under the wrapped line", top, want)
|
||||
}
|
||||
if at := lines.At(lines.Top(1) + a.line.Height*1.5); at != 1 {
|
||||
t.Errorf("At inside the wrapped line = %d, want 1", at)
|
||||
}
|
||||
if at := lines.At(-10); at != 0 {
|
||||
t.Errorf("At above = %d, want 0", at)
|
||||
}
|
||||
if at := lines.At(1e9); at != 503 {
|
||||
t.Errorf("At below = %d, want 503", at)
|
||||
}
|
||||
if h := lines.Height(); h < lines.Top(503) {
|
||||
t.Errorf("Height %v is above the last line, at %v", h, lines.Top(503))
|
||||
}
|
||||
|
||||
// An edit: the lines follow the text.
|
||||
tt.Press(20, 10)
|
||||
tt.Release(20, 10)
|
||||
tt.Key(Ctrl, KeyHome)
|
||||
tt.Key(0, KeyEnter)
|
||||
tt.Key(0, KeyEnter)
|
||||
if n := lines.Count(); n != 506 {
|
||||
t.Fatalf("after the edit, Count = %d, want 506", n)
|
||||
}
|
||||
if rows := lines.Rows(3); len(rows) < 3 {
|
||||
t.Errorf("after the edit, the long line has rows %v", rows)
|
||||
}
|
||||
}
|
||||
|
||||
// TestTextLinesBeforeLayout checks that lines not laid out yet are
|
||||
// placed a line apart.
|
||||
func TestTextLinesBeforeLayout(t *testing.T) {
|
||||
var lines TextLines
|
||||
if lines.Count() != 0 || lines.Top(3) <= 0 || lines.At(100) != 0 || len(lines.Rows(0)) != 1 {
|
||||
t.Errorf("zero TextLines: Count %d, Top(3) %v, At %d, Rows %v", lines.Count(), lines.Top(3), lines.At(100), lines.Rows(0))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user