diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-11-09 11:23:15 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-11-09 17:20:20 +0100 |
commit | 9278e0038366aab29f7c7352f606073756d5b750 (patch) | |
tree | f58b6945c4b131f433bf6c6d5e69ccfb418009f0 /xA | |
parent | 98c68ccd0df3e976c3b7992968852e6ae0b9595c (diff) | |
download | xK-9278e0038366aab29f7c7352f606073756d5b750.tar.gz xK-9278e0038366aab29f7c7352f606073756d5b750.tar.xz xK-9278e0038366aab29f7c7352f606073756d5b750.zip |
WIP: xA: add prompt and status
Diffstat (limited to 'xA')
-rw-r--r-- | xA/xA.go | 47 |
1 files changed, 41 insertions, 6 deletions
@@ -141,7 +141,6 @@ type buffer struct { kind RelayBufferKind serverName string lines []bufferLine - // TODO(p): Server by name or by pointer? // Channel: @@ -189,6 +188,8 @@ var ( wTopic *widget.RichText wRichText *widget.RichText wRichScroll *container.Scroll + wPrompt *widget.Label + wStatus *widget.Label wEntry *widget.Entry ) @@ -332,11 +333,38 @@ func refreshBufferList() { } func refreshPrompt() { - // TODO(p): First off, add a prompt, second, refresh it. + var prompt string + if b := bufferByName(bufferCurrent); b == nil { + prompt = "Synchronizing..." + } else if server, ok := servers[b.serverName]; ok { + prompt = server.user + if server.userModes != "" { + prompt += "(" + server.userModes + ")" + } + if prompt == "" { + prompt = "(" + server.state.String() + ")" + } + } + wPrompt.SetText(prompt) } func refreshStatus() { - // TODO(p): First off, add a status, second, refresh it. + var status string + if !bufferAtBottom() { + status += "🡇 " + } + + status += bufferCurrent + if b := bufferByName(bufferCurrent); b != nil { + if b.modes != "" { + status += "(+" + b.modes + ")" + } + if b.hideUnimportant { + status += "<H>" + } + } + + wStatus.SetText(status) } // --- RichText formatting ----------------------------------------------------- @@ -890,16 +918,23 @@ func main() { a.Settings().SetTheme(&customTheme{}) wWindow = a.NewWindow(projectName) - // TODO(p): There should also be a widget.NewLabel() next to the entry. - // - Probably another Border, even though this seems odd. + // TODO(p): Consider using data bindings. wTopic = widget.NewRichText() wTopic.Truncation = fyne.TextTruncateEllipsis wRichText = widget.NewRichText() wRichText.Wrapping = fyne.TextWrapWord wRichScroll = container.NewVScroll(wRichText) + wPrompt = widget.NewLabelWithStyle( + "", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}) + wStatus = widget.NewLabelWithStyle( + "", fyne.TextAlignTrailing, fyne.TextStyle{}) wEntry = widget.NewMultiLineEntry() + bottom := container.NewVBox( + container.NewBorder(nil, nil, wPrompt, wStatus), + wEntry, + ) wWindow.SetContent(container.NewBorder( - wTopic, wEntry, nil, nil, wRichScroll)) + wTopic, bottom, nil, nil, wRichScroll)) go relayRun() |