From 454777448f0007a66185d8c62ecc105b2e09237d Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Mon, 29 Aug 2016 09:58:17 -0400 Subject: [PATCH] refactor: User.SetColorIdx -> User.setColorIdx, preparing to abstract user --- chat/message/user.go | 8 ++++---- chat/room.go | 4 ++-- host_test.go | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/chat/message/user.go b/chat/message/user.go index 225cd71..189ec81 100644 --- a/chat/message/user.go +++ b/chat/message/user.go @@ -44,7 +44,7 @@ func NewUser(identity Identifier) *User { done: make(chan struct{}), Ignored: set.New(), } - u.SetColorIdx(rand.Int()) + u.setColorIdx(rand.Int()) return &u } @@ -59,7 +59,7 @@ func NewUserScreen(identity Identifier, screen io.WriteCloser) *User { // Rename the user with a new Identifier. func (u *User) SetID(id string) { u.Identifier.SetID(id) - u.SetColorIdx(rand.Int()) + u.setColorIdx(rand.Int()) } // ReplyTo returns the last user that messaged this user. @@ -83,9 +83,9 @@ func (u *User) ToggleQuietMode() { u.Config.Quiet = !u.Config.Quiet } -// SetColorIdx will set the colorIdx to a specific value, primarily used for +// setColorIdx will set the colorIdx to a specific value, primarily used for // testing. -func (u *User) SetColorIdx(idx int) { +func (u *User) setColorIdx(idx int) { u.colorIdx = idx } diff --git a/chat/room.go b/chat/room.go index 6cc0612..8ebb11d 100644 --- a/chat/room.go +++ b/chat/room.go @@ -106,12 +106,12 @@ func (r *Room) HandleMsg(m message.Message) { } if skip && skipUser == user { - // Skip + // Skip self return } if _, ok := m.(*message.AnnounceMsg); ok { if user.Config.Quiet { - // Skip + // Skip announcements return } } diff --git a/host_test.go b/host_test.go index f8d4362..c959ceb 100644 --- a/host_test.go +++ b/host_test.go @@ -28,7 +28,6 @@ func TestHostGetPrompt(t *testing.T) { var expected, actual string u := message.NewUser(&Identity{id: "foo"}) - u.SetColorIdx(2) actual = GetPrompt(u) expected = "[foo] " @@ -38,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) { u.Config.Theme = &message.Themes[0] actual = GetPrompt(u) - expected = "[\033[38;05;3mfoo\033[0m] " + expected = "[\033[38;05;88mfoo\033[0m] " if actual != expected { t.Errorf("Got: %q; Expected: %q", actual, expected) }