Colorize /name output with selected theme#249
Merged
shazow merged 3 commits intoshazow:masterfrom Oct 4, 2017
ste5e99:color-names
Merged
Colorize /name output with selected theme#249shazow merged 3 commits intoshazow:masterfrom ste5e99:color-names
shazow merged 3 commits intoshazow:masterfrom
ste5e99:color-names
Conversation
shazow
requested changes
Oct 4, 2017
| body := fmt.Sprintf("%d connected: %s", len(names), strings.Join(names, ", ")) | ||
| names := room.Members.ListPrefix("") | ||
| colNames := make([]string, len(names)) | ||
| theme := msg.From().Config().Theme |
Owner
There was a problem hiding this comment.
I thiiiink it's possible for Theme to be nil.
Contributor
Author
There was a problem hiding this comment.
I'll add a check for nil and write an early exit.
shazow
reviewed
Oct 4, 2017
| room.Send(message.NewSystemMsg(body, msg.From())) | ||
| return nil | ||
| } | ||
|
|
Owner
There was a problem hiding this comment.
for the sake of avoiding subtly different duplicate code, what about something like:
colorize := func(u User) string {
return theme.ColorName(u)
}
if (theme == nil ... etc) {
colorize = func(u User) string {
return u.Name
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In reference to #205.
/namesoutput is now colored with the user's current theme. The upside is that it makes/namesmore appealing. The downside is clients that don't support ANSI escape codes might see a lot of garbage output instead of simple names. I'm not sure how to work around that issue itself.How

/nameslooks with the available themes:I can add a check that skips the coloring if the selected theme is mono. That way a user can at least avoid getting garbage output from
/nameswhen they have no ANSI support.