From 040985719870c3bed3962f4a0cfd43e01592ebab Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sat, 9 Nov 2024 12:53:04 +0100 Subject: WIP: xA: input submission --- xA/xA.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'xA/xA.go') diff --git a/xA/xA.go b/xA/xA.go index 20d814a..ba9229c 100644 --- a/xA/xA.go +++ b/xA/xA.go @@ -919,6 +919,27 @@ func relayRun() { // TODO(p): Indicate in the UI that we're no longer connected. } +// --- Input line -------------------------------------------------------------- + +func inputSubmit(text string) bool { + b := bufferByName(bufferCurrent) + if b == nil { + return false + } + + b.history = append(b.history, text) + b.historyAt = len(b.history) + wEntry.SetText("") + + relaySend(RelayCommandData{Variant: &RelayCommandDataBufferInput{ + BufferName: b.bufferName, + Text: text, + }}, nil) + return true +} + +// --- General UI -------------------------------------------------------------- + func main() { flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), @@ -977,6 +998,14 @@ func main() { wStatus = widget.NewLabelWithStyle( "", fyne.TextAlignTrailing, fyne.TextStyle{}) wEntry = widget.NewMultiLineEntry() + // TODO(p): Rather respond to all keypresses/similar activity. + wEntry.OnChanged = func(text string) { + relaySend(RelayCommandData{Variant: &RelayCommandDataActive{}}, nil) + } + // TODO(p): Make this submit on Enter rather than Shift+Enter. + wEntry.OnSubmitted = func(text string) { + inputSubmit(text) + } top := container.NewVBox( wTopic, -- cgit v1.2.3-70-g09d2