@@ -31,14 +31,14 @@ type User struct {
3131 closeOnce sync.Once
3232
3333 mu sync.Mutex
34- Config UserConfig
34+ config UserConfig
3535 replyTo * User // Set when user gets a /msg, for replying.
3636}
3737
3838func NewUser (identity Identifier ) * User {
3939 u := User {
4040 Identifier : identity ,
41- Config : DefaultUserConfig ,
41+ config : DefaultUserConfig ,
4242 joined : time .Now (),
4343 msg : make (chan Message , messageBuffer ),
4444 done : make (chan struct {}),
@@ -56,6 +56,18 @@ func NewUserScreen(identity Identifier, screen io.WriteCloser) *User {
5656 return u
5757}
5858
59+ func (u * User ) Config () UserConfig {
60+ u .mu .Lock ()
61+ defer u .mu .Unlock ()
62+ return u .config
63+ }
64+
65+ func (u * User ) SetConfig (cfg UserConfig ) {
66+ u .mu .Lock ()
67+ u .config = cfg
68+ u .mu .Unlock ()
69+ }
70+
5971// Rename the user with a new Identifier.
6072func (u * User ) SetID (id string ) {
6173 u .Identifier .SetID (id )
@@ -76,24 +88,12 @@ func (u *User) SetReplyTo(user *User) {
7688 u .replyTo = user
7789}
7890
79- // ToggleQuietMode will toggle whether or not quiet mode is enabled
80- func (u * User ) ToggleQuietMode () {
81- u .mu .Lock ()
82- defer u .mu .Unlock ()
83- u .Config .Quiet = ! u .Config .Quiet
84- }
85-
8691// setColorIdx will set the colorIdx to a specific value, primarily used for
8792// testing.
8893func (u * User ) setColorIdx (idx int ) {
8994 u .colorIdx = idx
9095}
9196
92- // Block until user is closed
93- func (u * User ) Wait () {
94- <- u .done
95- }
96-
9797// Disconnect user, stop accepting messages
9898func (u * User ) Close () {
9999 u .closeOnce .Do (func () {
@@ -144,15 +144,13 @@ func (u *User) SetHighlight(s string) error {
144144 return err
145145 }
146146 u .mu .Lock ()
147- u .Config .Highlight = re
147+ u .config .Highlight = re
148148 u .mu .Unlock ()
149149 return nil
150150}
151151
152152func (u * User ) render (m Message ) string {
153- u .mu .Lock ()
154- cfg := u .Config
155- u .mu .Unlock ()
153+ cfg := u .Config ()
156154 switch m := m .(type ) {
157155 case PublicMsg :
158156 return m .RenderFor (cfg ) + Newline
0 commit comments