Quality of Life update #4
|
@ -22,6 +22,12 @@ type Message struct {
|
||||||
Server net.Conn
|
Server net.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProfileData struct {
|
||||||
|
Username string
|
||||||
|
}
|
||||||
|
|
||||||
|
var Profile ProfileData
|
||||||
|
|
||||||
func (m Message) toSend() {
|
func (m Message) toSend() {
|
||||||
m.Server.Write([]byte(m.Contents))
|
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)
|
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 {
|
if _, err := conn.Write([]byte(message)); err != nil {
|
||||||
log.Fatalf("Error occurred writing to server: %v\n", err)
|
log.Fatalf("Error occurred writing to server: %v\n", err)
|
||||||
}
|
}
|
||||||
|
@ -194,7 +202,7 @@ func layout(g *gocui.Gui) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
chatbox.Autoscroll = true
|
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 {
|
// 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 {
|
if _, err := g.SetCurrentView("textarea"); err != nil {
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
textarea.Title = "Send message"
|
textarea.Title = "Send message (Currently chatting as: " + Profile.Username + ")"
|
||||||
textarea.Wrap = true
|
textarea.Wrap = true
|
||||||
textarea.Editable = true
|
textarea.Editable = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue