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
+91
@@ -0,0 +1,91 @@
|
||||
package richtext
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestDocumentLinkEndsWithLine checks that typing at the end of a line
|
||||
// linked whole, its newline too, doesn't continue the link.
|
||||
func TestDocumentLinkEndsWithLine(t *testing.T) {
|
||||
d := NewDocument(NewText("abc\nxyz"))
|
||||
d.SetSelection(0, 4)
|
||||
d.SetLink("u")
|
||||
d.SetSelection(3, 3)
|
||||
if l := d.TypingAttributes().Link; l != "" {
|
||||
t.Fatalf("typing link %q", l)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDocumentFormattingFromNewline checks the formats of a selection
|
||||
// that starts at a newline: those of the runes after it.
|
||||
func TestDocumentFormattingFromNewline(t *testing.T) {
|
||||
d := NewDocument(TextOf(Paragraph{Runs: []Run{{Text: "plain"}}}, Paragraph{Runs: []Run{{Text: "BOLD", Attributes: Attributes{Weight: 700}}}}))
|
||||
d.SetSelection(5, 10)
|
||||
if f := d.Formatting(); f.Bold != FormatOn {
|
||||
t.Fatalf("bold %v", f.Bold)
|
||||
}
|
||||
d.ToggleBold()
|
||||
if d.Text().AttributesAt(7).Bold() {
|
||||
t.Fatal("⌘B didn't take bold off")
|
||||
}
|
||||
}
|
||||
|
||||
// TestDocumentInsertLeavesCaret checks that inserting over a selection
|
||||
// leaves the caret after what was inserted, as typing and pasting do.
|
||||
func TestDocumentInsertLeavesCaret(t *testing.T) {
|
||||
d := NewDocument(NewText("hello world"))
|
||||
d.SetSelection(6, 11)
|
||||
d.InsertText("there")
|
||||
if a, c := d.Selection(); a != 11 || c != 11 {
|
||||
t.Fatalf("InsertText: selection %d, %d", a, c)
|
||||
}
|
||||
d.SetSelection(0, 1)
|
||||
d.Insert(NewText("A\nB"))
|
||||
if a, c := d.Selection(); a != 3 || c != 3 {
|
||||
t.Fatalf("Insert: selection %d, %d", a, c)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDocumentFormatToEnd checks that formatting to the end of the text
|
||||
// formats what typing gets in a last empty paragraph.
|
||||
func TestDocumentFormatToEnd(t *testing.T) {
|
||||
d := NewDocument(NewText("abc\n"))
|
||||
d.SetSelection(0, 4)
|
||||
d.ToggleBold()
|
||||
d.SetSelection(4, 4)
|
||||
if !d.TypingAttributes().Bold() {
|
||||
t.Fatal("typing at the end isn't bold")
|
||||
}
|
||||
}
|
||||
|
||||
// TestDocumentNoOpSteps checks that commands changing nothing make no
|
||||
// step of undo, and that a full history keeps its steps through them.
|
||||
func TestDocumentNoOpSteps(t *testing.T) {
|
||||
d := NewDocument(NewText("abc"))
|
||||
d.SetSelection(0, 3)
|
||||
v := d.Version()
|
||||
d.SetLink("")
|
||||
d.ToggleChecked(0)
|
||||
if d.Version() != v || d.CanUndo() {
|
||||
t.Fatalf("version %d → %d, can undo %v", v, d.Version(), d.CanUndo())
|
||||
}
|
||||
for range 200 {
|
||||
d.InsertText("x")
|
||||
}
|
||||
n := len(d.undo)
|
||||
d.Edit(func(*Edit) {})
|
||||
if len(d.undo) != n {
|
||||
t.Fatalf("undo steps %d → %d", n, len(d.undo))
|
||||
}
|
||||
}
|
||||
|
||||
// TestDocumentInsertTextCRLF checks that InsertText takes the newlines of
|
||||
// other systems as typing does.
|
||||
func TestDocumentInsertTextCRLF(t *testing.T) {
|
||||
d := NewDocument(NewText("ab"))
|
||||
d.InsertText("c\r\nd\re")
|
||||
if got := d.Text().String(); got != "abc\nd\ne" {
|
||||
t.Fatalf("text %q", got)
|
||||
}
|
||||
if _, c := d.Selection(); c != 7 {
|
||||
t.Fatalf("caret at %d, want 7", c)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user