From b11c892158772f508e494b2726a5d4db1bb74d23 Mon Sep 17 00:00:00 2001 From: citrons Date: Sat, 31 May 2025 17:16:38 -0500 Subject: text input box --- client/application.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'client/application.go') diff --git a/client/application.go b/client/application.go index fdb0216..72ec078 100644 --- a/client/application.go +++ b/client/application.go @@ -7,6 +7,7 @@ import ( "citrons.xyz/talk/proto" "citrons.xyz/talk/tui" "zgo.at/termfo/keys" + "os" ) type application struct { @@ -23,7 +24,6 @@ func newApplication(serverAddress string) *application { var app application app.Client = client.New(serverAddress) app.cache = object.NewCache(&app) - app.cmdBuffer.Buffer = buffer.New("buffer") app.currentBuffer = &app.cmdBuffer.Buffer app.cmdBuffer.info("connecting to %s", app.Client.Address) @@ -105,13 +105,18 @@ func (a *application) auth(name string) { } func (a *application) onInput(ev tui.Event) { + tui.Selected = "input" + a.currentBuffer.Scroll(-ev.Mouse.Scroll * 2) + scroll := tui.Size().Height - 5 switch ev.Key { - case keys.Up: - a.currentBuffer.Scroll(1) - case keys.Down: - a.currentBuffer.Scroll(-1) + case keys.PageUp: + a.currentBuffer.Scroll(scroll) + case keys.PageDown: + a.currentBuffer.Scroll(-scroll) } + + a.currentBuffer.TextInput.Update(ev) } func (a *application) show() { @@ -120,8 +125,18 @@ func (a *application) show() { tui.Push("", tui.Box { Width: tui.BoxSize(s.Width), Height: tui.BoxSize(s.Height), }) - a.currentBuffer.Show() + + a.currentBuffer.Show("buffer") + tui.Push("status", tui.Box { + Width: tui.Fill, Height: tui.BoxSize(1), Dir: tui.Right, + Style: &tui.Style {Bg: tui.White, Fg: tui.Black}, + }) + tui.Pop() + a.currentBuffer.TextInput.Show("input") + tui.Pop() tui.DrawLayout() - tui.Present() + if tui.Present() != nil { + os.Exit(-1) + } } -- cgit v1.2.3