diff options
| author | Přemysl Eric Janouch <p@janouch.name> | 2024-11-09 12:53:04 +0100 | 
|---|---|---|
| committer | Přemysl Eric Janouch <p@janouch.name> | 2024-11-09 17:20:20 +0100 | 
| commit | 040985719870c3bed3962f4a0cfd43e01592ebab (patch) | |
| tree | b4bb03ec1660850ae09c3236f08f2a50b5fe47b1 | |
| parent | 79e2d6d31a9790527c37a5527165d7b250ea1a32 (diff) | |
| download | xK-040985719870c3bed3962f4a0cfd43e01592ebab.tar.gz xK-040985719870c3bed3962f4a0cfd43e01592ebab.tar.xz xK-040985719870c3bed3962f4a0cfd43e01592ebab.zip | |
WIP: xA: input submission
| -rw-r--r-- | xA/xA.go | 29 | 
1 files changed, 29 insertions, 0 deletions
| @@ -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, | 
