From cd33ad54372bd53842fd6e04dbb2859f9ab59f51 Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 2 Jun 2025 09:19:23 -0500 Subject: refactor join/leave messages` --- client/channel_window.go | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'client/channel_window.go') diff --git a/client/channel_window.go b/client/channel_window.go index d003ce8..e5b50c3 100644 --- a/client/channel_window.go +++ b/client/channel_window.go @@ -238,7 +238,7 @@ func (cw *channelWindow) ShowStatusLine() { } func (m channelMsg) Id() string { - return m.Object.Id + return "buffer." + m.Object.Id } func (m channelMsg) showDate(bg int32) { @@ -251,49 +251,49 @@ func (m channelMsg) showDate(bg int32) { tui.Pop() } +func (m channelMsg) showName(bg int32) { + nameStyle := tui.Style {Bg: bg, Fg: tui.White} + if m.Fields["f"] == globalApp.uid { + nameStyle.Fg = tui.Cyan + } + if m.window.isGone(m.Fields["f"]) { + nameStyle.Italic = true + } else { + nameStyle.Bold = true + } + tui.Push(m.Id() + ".name", tui.Box { + Width: tui.TextSize, Height: 1, NoWrap: true, + }) + tui.Text(m.window.username(m.Fields["f"]), &nameStyle) + tui.Pop() +} + func (m channelMsg) Show(odd bool) { var bg int32 = colorDefault[odd] + switch m.Kind { - case "join": + case "join", "leave": tui.Push("", tui.Box { Width: tui.Fill, Height: tui.Children, Dir: tui.Left, }) m.showDate(bg) - tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize}) - tui.Text("-> ", &tui.Style {Fg: tui.BrightBlack, Bg: bg}) - tui.Text("join", &tui.Style {Fg: tui.Blue, Bg: bg, Bold: true}) - tui.Text(": ", &tui.Style {Fg: tui.BrightBlack, Bg: bg}) - tui.Text(m.window.username(m.Fields[""]), nil) - tui.Pop() - tui.Pop() - case "leave": + + tui.Push("", tui.Box {Width: tui.Children, Height: 1, Dir: tui.Right}) tui.Push("", tui.Box { - Width: tui.Fill, Height: tui.Children, Dir: tui.Left, + Width: tui.TextSize, Height: tui.TextSize, NoWrap: true, }) - m.showDate(bg) - tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize}) tui.Text("<- ", &tui.Style {Fg: tui.BrightBlack, Bg: bg}) - tui.Text("leave", &tui.Style {Fg: tui.Blue, Bg: bg, Bold: true}) + tui.Text(m.Kind, &tui.Style {Fg: tui.Blue, Bg: bg}) tui.Text(": ", &tui.Style {Fg: tui.BrightBlack, Bg: bg}) - tui.Text(m.window.username(m.Fields[""]), nil) tui.Pop() + m.showName(bg) tui.Pop() - case "m": - nameStyle := tui.Style {Bg: bg, Fg: tui.White} - if m.Fields["f"] == globalApp.uid { - nameStyle.Fg = tui.Cyan - } - if m.window.isGone(m.Fields["f"]) { - nameStyle.Italic = true - } else { - nameStyle.Bold = true - } + tui.Pop() + case "m": tui.Push("", tui.Box {Width: tui.Fill, Height: 1, Dir: tui.Left}) m.showDate(bg) - tui.Push("", tui.Box {Width: tui.TextSize, Height: 1, NoWrap: true}) - tui.Text(m.window.username(m.Fields["f"]), &nameStyle) - tui.Pop() + m.showName(bg) tui.Pop() tui.Push("", tui.Box { -- cgit v1.2.3