From bb26887492a6ac5844b85f60b03fbefc34f529a4 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 14 Sep 2024 07:32:44 +0200 Subject: WIP: xA --- xA/xA.go | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 xA/xA.go (limited to 'xA/xA.go') diff --git a/xA/xA.go b/xA/xA.go new file mode 100644 index 0000000..0e2cf36 --- /dev/null +++ b/xA/xA.go @@ -0,0 +1,135 @@ +// Copyright (c) 2024, Přemysl Eric Janouch +// SPDX-License-Identifier: 0BSD + +package main + +import ( + "bufio" + "context" + "encoding/binary" + "flag" + "fmt" + "io" + "log" + "net" + "net/url" + "os" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/app" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/widget" +) + +var ( + debug = flag.Bool("debug", false, "enable debug output") + projectName = "xA" + projectVersion = "?" + addressConnect string +) + +// ----------------------------------------------------------------------------- + +func relayReadFrame(r io.Reader) []byte { + var length uint32 + if err := binary.Read(r, binary.BigEndian, &length); err != nil { + log.Println("Event receive failed: " + err.Error()) + return nil + } + b := make([]byte, length) + if _, err := io.ReadFull(r, b); err != nil { + log.Println("Event receive failed: " + err.Error()) + return nil + } + + if *debug { + log.Printf(" 1 { + flag.Usage() + os.Exit(1) + } + + addressConnect = flag.Arg(0) + + a := app.New() + w := a.NewWindow(projectName) + + // TODO(p): There should also be a widget.NewLabel() next to the entry. + // - Probably another Border, even though this seems odd. + var ( + richtext = widget.NewRichText() + richscroll = container.NewVScroll(richtext) + entry = widget.NewMultiLineEntry() + ) + w.SetContent(container.NewBorder(nil, entry, nil, nil, richscroll)) + + testURL, _ := url.Parse("https://x.com") + richtext.Segments = []widget.RichTextSegment{ + &widget.ParagraphSegment{Texts: []widget.RichTextSegment{ + &widget.TextSegment{Text: "Test"}, + &widget.HyperlinkSegment{Text: "X", URL: testURL}, + &widget.TextSegment{ + Text: " is a website, certainly", + Style: widget.RichTextStyleInline, + }, + }}, + &widget.TextSegment{Style: widget.RichTextStyleParagraph}, + &widget.SeparatorSegment{}, + &widget.TextSegment{Text: "Paragraph"}, + } + richtext.Wrapping = fyne.TextWrapWord + richtext.Refresh() + + w.ShowAndRun() +} -- cgit v1.2.3-70-g09d2