Add credits and current username to UI

This commit is contained in:
raul 2024-05-06 13:45:06 +02:00
parent f8332d102a
commit bcaa1c12af
1 changed files with 10 additions and 2 deletions

View File

@ -22,6 +22,12 @@ type Message struct {
Server net.Conn
}
type ProfileData struct {
Username string
}
var Profile ProfileData
func (m Message) toSend() {
m.Server.Write([]byte(m.Contents))
}
@ -93,6 +99,8 @@ func sendName(conn net.Conn) {
log.Fatalf("Error occurred sending message to server: %v\n", err)
}
Profile.Username = strings.TrimRight(message, "\n")
if _, err := conn.Write([]byte(message)); err != nil {
log.Fatalf("Error occurred writing to server: %v\n", err)
}
@ -194,7 +202,7 @@ func layout(g *gocui.Gui) error {
return err
}
chatbox.Autoscroll = true
chatbox.Title = "Chat Box"
chatbox.Title = "Chat Box (Find source at https://git.bulgariu.xyz/raul/mini-chat!)"
}
// if button, err := g.SetView("button", maxX/2+32, maxY-4, maxX-28, maxY-2); err != nil {
@ -214,7 +222,7 @@ func layout(g *gocui.Gui) error {
if _, err := g.SetCurrentView("textarea"); err != nil {
log.Panicln(err)
}
textarea.Title = "Send message"
textarea.Title = "Send message (Currently chatting as: " + Profile.Username + ")"
textarea.Wrap = true
textarea.Editable = true
}