commit c10c3f4
Clayton Craft
·
2023-05-16 19:11:38 +0000 UTC
parent 9d0c33e
Add option to hide join/part messages The current behavior (showing joins/parts) is the default behavior.
3 files changed,
+33,
-11
M
app.go
+25,
-10
1@@ -760,6 +760,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
2 s.MonitorAdd(target)
3 }
4 case irc.SelfNickEvent:
5+ if !app.cfg.StatusEnabled {
6+ break
7+ }
8 var body ui.StyledStringBuilder
9 body.WriteString(fmt.Sprintf("%s\u2192%s", ev.FormerNick, s.Nick()))
10 textStyle := tcell.StyleDefault.Foreground(app.cfg.Colors.Status)
11@@ -776,6 +779,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
12 Readable: true,
13 })
14 case irc.UserNickEvent:
15+ if !app.cfg.StatusEnabled {
16+ break
17+ }
18 line := app.formatEvent(ev)
19 for _, c := range s.ChannelsSharedWith(ev.User) {
20 app.win.AddLine(netID, c, line)
21@@ -814,15 +820,24 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
22 app.lastBuffer = ""
23 }
24 case irc.UserJoinEvent:
25+ if !app.cfg.StatusEnabled {
26+ break
27+ }
28 line := app.formatEvent(ev)
29 app.win.AddLine(netID, ev.Channel, line)
30 case irc.SelfPartEvent:
31 app.win.RemoveBuffer(netID, ev.Channel)
32 delete(app.messageBounds, boundKey{netID, ev.Channel})
33 case irc.UserPartEvent:
34+ if !app.cfg.StatusEnabled {
35+ break
36+ }
37 line := app.formatEvent(ev)
38 app.win.AddLine(netID, ev.Channel, line)
39 case irc.UserQuitEvent:
40+ if !app.cfg.StatusEnabled {
41+ break
42+ }
43 line := app.formatEvent(ev)
44 for _, c := range ev.Channels {
45 app.win.AddLine(netID, c, line)
46@@ -833,6 +848,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
47 topic := ui.IRCString(ev.Topic).String()
48 app.win.SetTopic(netID, ev.Channel, topic)
49 case irc.ModeChangeEvent:
50+ if !app.cfg.StatusEnabled {
51+ break
52+ }
53 line := app.formatEvent(ev)
54 app.win.AddLine(netID, ev.Channel, line)
55 case irc.InviteEvent:
56@@ -927,6 +945,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
57 var linesBefore []ui.Line
58 var linesAfter []ui.Line
59 bounds, hasBounds := app.messageBounds[boundKey{netID, ev.Target}]
60+ boundsNew := bounds
61 for _, m := range ev.Messages {
62 var line ui.Line
63 switch ev := m.(type) {
64@@ -938,6 +957,10 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
65 if line.IsZero() {
66 continue
67 }
68+ boundsNew.Update(&line)
69+ if _, ok := m.(irc.MessageEvent); !ok && !app.cfg.StatusEnabled {
70+ continue
71+ }
72 if hasBounds {
73 c := bounds.Compare(&line)
74 if c < 0 {
75@@ -950,16 +973,8 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
76 }
77 }
78 app.win.AddLines(netID, ev.Target, linesBefore, linesAfter)
79- if len(linesBefore) != 0 {
80- bounds.Update(&linesBefore[0])
81- bounds.Update(&linesBefore[len(linesBefore)-1])
82- }
83- if len(linesAfter) != 0 {
84- bounds.Update(&linesAfter[0])
85- bounds.Update(&linesAfter[len(linesAfter)-1])
86- }
87- if !bounds.IsZero() {
88- app.messageBounds[boundKey{netID, ev.Target}] = bounds
89+ if !boundsNew.IsZero() {
90+ app.messageBounds[boundKey{netID, ev.Target}] = boundsNew
91 }
92 case irc.SearchEvent:
93 app.win.OpenOverlay()
+7,
-0
1@@ -68,6 +68,7 @@ type Config struct {
2 MemberColWidth int
3 MemberColEnabled bool
4 TextMaxWidth int
5+ StatusEnabled bool
6
7 Colors ui.ConfigColors
8
9@@ -102,6 +103,7 @@ func Defaults() Config {
10 MemberColWidth: 16,
11 MemberColEnabled: true,
12 TextMaxWidth: 0,
13+ StatusEnabled: true,
14 Colors: ui.ConfigColors{
15 Status: tcell.ColorGray,
16 Prompt: tcell.ColorDefault,
17@@ -324,6 +326,11 @@ func unmarshal(filename string, cfg *Config) (err error) {
18 return fmt.Errorf("unknown nick color scheme %q", colorStr)
19 }
20 continue
21+ case "status":
22+ if colorStr == "disabled" {
23+ cfg.StatusEnabled = false
24+ continue
25+ }
26 }
27
28 var color tcell.Color
+1,
-1
1@@ -170,7 +170,7 @@ colors {
2 | unread
3 : foreground color for unread buffer names in buffer lists
4 | status
5-: foreground color for status event lines (e.g. join, part, nick changes) in buffers
6+: foreground color for status event lines (e.g. join, part, nick changes) in buffers. "disabled" hides status messages.
7 | nicks
8 : color scheme for user nicks, either "base" (the default, 16 colors) or "extended" (256 colors)
9