This commit is contained in:
foglar 2025-09-04 16:14:54 +02:00
parent 1eebca289f
commit 56827fa470
3 changed files with 13 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"whspbrd/pkg/cell_size" "whspbrd/pkg/cell_size"
//"whspbrd/pkg/clean_image" "whspbrd/pkg/clean_image"
"whspbrd/pkg/render_image" "whspbrd/pkg/render_image"
"github.com/jroimartin/gocui" "github.com/jroimartin/gocui"
@ -48,9 +48,9 @@ func layoutInput(g *gocui.Gui, maxX, maxY int) error {
func updateChatView(v *gocui.View) { func updateChatView(v *gocui.View) {
v.Clear() v.Clear()
//clear := cleanimage.NewKittyImageCleaner() clear := cleanimage.NewKittyImageCleaner()
// TODO: In future optimize this to only clear certain part of screen // TODO: In future optimize this to only clear certain part of screen
//fmt.Print(clear.DeleteAllVisiblePlacements(true)) fmt.Print(clear.DeleteByColumn(23, false))
for i, msg := range chatData.Messages { for i, msg := range chatData.Messages {
decoded, err := base64.StdEncoding.DecodeString(msg.Content) decoded, err := base64.StdEncoding.DecodeString(msg.Content)

View File

@ -7,6 +7,7 @@ import (
//"math" //"math"
//"strings" //"strings"
//"whspbrd/pkg/cell_size" //"whspbrd/pkg/cell_size"
"whspbrd/pkg/clean_image"
"whspbrd/pkg/render_image" "whspbrd/pkg/render_image"
//"whspbrd/pkg/resize_image" //"whspbrd/pkg/resize_image"
@ -34,6 +35,8 @@ func updateContactsView(g *gocui.Gui) error {
} }
v.Clear() v.Clear()
clear := cleanimage.NewKittyImageCleaner()
fmt.Print(clear.DeleteByColumn(2, false))
// TODO: If no contacts then error, create some add contacts window or hello to WhspBrd // TODO: If no contacts then error, create some add contacts window or hello to WhspBrd
LoadMessages(users[selectedUserIdx]) LoadMessages(users[selectedUserIdx])
@ -45,17 +48,17 @@ func updateContactsView(g *gocui.Gui) error {
} }
_, maxY := g.Size() _, maxY := g.Size()
h := min(len(users), (maxY / 2) - 1) h := min(len(users), (maxY/2)-1)
startI := max(0, min(selectedUserIdx - (h / 2), len(users) - h)) startI := max(0, min(selectedUserIdx-(h/2), len(users)-h))
fmt.Fprint(v, "\n\n") fmt.Fprint(v, "\n\n")
for i := startI; i < startI + h; i++ { for i := startI; i < startI+h; i++ {
u := users[i] u := users[i]
fmt.Fprint(v, "\t\t\t\t") fmt.Fprint(v, "\t\t\t\t")
icon_path := fmt.Sprintf("./configs/servers/default/users/%s/icon.png", u) icon_path := fmt.Sprintf("./configs/servers/default/users/%s/icon.png", u)
render_image.RenderImage(icon_path, 3 + 2 * (i - startI), 2, 30, 30, false) render_image.RenderImage(icon_path, 3+2*(i-startI), 2, 30, 30, false)
if i == selectedUserIdx { if i == selectedUserIdx {
fmt.Fprintln(v, "\x1b[7m"+u+"\x1b[0m\n") fmt.Fprintln(v, "\x1b[7m"+u+"\x1b[0m\n")

View File

@ -9,7 +9,10 @@ import (
var users []string var users []string
var prevWidth, prevHeight int var prevWidth, prevHeight int
func Run() { func Run() {
LoadContacts("configs/servers/default") LoadContacts("configs/servers/default")
g, err := gocui.NewGui(gocui.OutputNormal) g, err := gocui.NewGui(gocui.OutputNormal)