completed tui sidebar scrolling and selecting chat

This commit is contained in:
shinya 2025-08-17 22:58:19 +02:00
parent 440ef38439
commit f69e6db582
2 changed files with 53 additions and 7 deletions

View File

@ -1 +1,39 @@
package tui
package tui
var Colors = struct {
base00 string
base01 string
base02 string
base03 string
base04 string
base05 string
base06 string
base07 string
base08 string
base09 string
base10 string
base11 string
base12 string
base13 string
base14 string
base15 string
base16 string
}{
base00: "\033[31;7m",
base01: "\033[32;7m",
base02: "\033[33;7m",
base03: "\033[34;7m",
base04: "\033[35;7m",
base05: "\033[36;7m",
base06: "\033[37;7m",
base07: "\033[38;7m",
base08: "\033[39;7m",
base09: "\033[310;7m",
base10: "\033[311;7m",
base11: "\033[312;7m",
base12: "\033[313;7m",
base13: "\033[314;7m",
base14: "\033[315;7m",
base15: "\033[316;7m",
base16: "\033[0m",
}

View File

@ -14,9 +14,7 @@ func layoutSidebar(g *gocui.Gui, maxY int) error {
}
v.Title = "Users"
v.Clear()
for _, u := range users {
fmt.Fprintln(v, u+"\n")
}
updateUsersView(g)
}
return nil
}
@ -28,14 +26,24 @@ func updateUsersView(g *gocui.Gui) error {
}
v.Clear()
// TODO: Render profile image of users and change colors of each user maybe?
for i, u := range users {
// Change Selected User In The TUI Window
if i == selectedUserIdx {
fmt.Fprintln(v, fmt.Sprintf(">%s\n", u))
fmt.Fprintf(v, "%s%s%s\n", Colors.base06, u, Colors.base16)
_, y := v.Size()
if i == 0 {
v.SetOrigin(0, 0)
} else {
v.SetOrigin(0, i-y+1)
}
} else {
fmt.Fprintln(v, u+"\n")
fmt.Fprintln(v, u)
}
}
return nil
}