summaryrefslogtreecommitdiff
path: root/client/ui.go
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-01 15:38:17 -0500
committercitrons <citrons@mondecitronne.com>2025-06-01 15:38:17 -0500
commite2dc5b6fbb6adf6f379ef0123c214a196211c305 (patch)
treecc976665dd2e0916af100b5c0f7f629cc1936b01 /client/ui.go
parente740e5478a43358fbbd79636483d000e01f88b7e (diff)
joining channels
Diffstat (limited to 'client/ui.go')
-rw-r--r--client/ui.go86
1 files changed, 86 insertions, 0 deletions
diff --git a/client/ui.go b/client/ui.go
new file mode 100644
index 0000000..386645e
--- /dev/null
+++ b/client/ui.go
@@ -0,0 +1,86 @@
+package main
+
+import (
+ "citrons.xyz/talk/client/window"
+ "citrons.xyz/talk/tui"
+ "zgo.at/termfo/keys"
+ "os"
+)
+
+func (a *application) getWin() window.Window {
+ win := a.windowCache.Open(a.currentWindow)
+ if win == nil {
+ return emptyWindow {a.currentWindow}
+ }
+ return win
+}
+
+func (a *application) onInput(ev tui.Event) {
+ tui.Selected = "input"
+
+ win := a.getWin()
+ win.Input().Update(ev)
+
+ buf := win.Buffer()
+ buf.Scroll(-ev.Mouse.Scroll * 2)
+ scroll := tui.Size().Height - 5
+ switch ev.Key {
+ case keys.PageUp:
+ buf.Scroll(scroll)
+ case keys.PageDown:
+ buf.Scroll(-scroll)
+ case keys.Enter:
+ input := win.Input()
+ if !input.IsEmpty() {
+ is, text := isCommand(input.Text())
+ if !is {
+ win.Send(text)
+ } else {
+ a.processCommand(text)
+ input.SetText("")
+ }
+ }
+ case 'h' | keys.Ctrl:
+ a.currentWindow = cmdWindowLocation {}
+ }
+
+}
+
+func (a *application) showNickBox() {
+ tui.Push("username", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
+ tui.Text("[", nil)
+ name := a.getNick()
+ name = string([]rune(name)[:8])
+ tui.Text(name, nil)
+ tui.Text("] ", nil)
+ tui.Pop()
+}
+
+func (a *application) show() {
+ tui.Clear()
+ s := tui.Size()
+ tui.Push("", tui.Box {
+ Width: tui.BoxSize(s.Width), Height: tui.BoxSize(s.Height),
+ })
+
+ a.getWin().Buffer().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},
+ })
+ a.getWin().ShowStatusLine()
+ tui.Pop()
+
+ tui.Push("input container", tui.Box {
+ Width: tui.Fill, Height: tui.Children, Dir: tui.Right,
+ })
+ a.showNickBox()
+ a.getWin().Input().Show("input")
+ tui.Pop()
+
+ tui.Pop()
+ tui.DrawLayout()
+ if tui.Present() != nil {
+ os.Exit(-1)
+ }
+} \ No newline at end of file