diff options
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 29 |
1 files changed, 22 insertions, 7 deletions
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) + } } |
