Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add irc.utils.irc_color_to_ansi() #249

Merged
merged 1 commit into from Sep 18, 2018
Merged

Add irc.utils.irc_color_to_ansi() #249

merged 1 commit into from Sep 18, 2018

Conversation

spaceone
Copy link
Contributor

Translates IRC color/bold/etc codes into ANSI escape sequences, so that the output can be printed on a terminal.

Example:

from circuits.protocols.irc.utils import irc_color_to_ansi
colorstring = '\x0300white\x03 \x0301black\x03 \x0302blue\x03 \x0303green\x03 \x0304red\x03 '
colorstring += '\x0305brown\x03 \x0306magenta\x03 \x0307orange\x03 \x0308yellow\x03 '
colorstring += '\x0309lightgreen\x03 \x0310cyan\x03 \x0311lightcyan\x03 \x0312lightblue\x03 '
colorstring += '\x0313pink\x03 \x0314grey\x03 \x0315lightgrey\x03\x0f'
print(irc_color_to_ansi('hi \x02bold\x02 \x1ditalic\x1d \x1funderline\x1f \x1estrikethrough\x1e'))
print(irc_color_to_ansi(colorstring))
print(irc_color_to_ansi(colorstring.replace(' \x03', ' \x0301,')))

@spaceone spaceone self-assigned this Sep 17, 2018
@spaceone
Copy link
Contributor Author

prologic
prologic previously approved these changes Sep 18, 2018
from circuits.protocols.irc.utils import irc_color_to_ansi
colorstring = '\x0300white\x03 \x0301black\x03 \x0302blue\x03 \x0303green\x03 \x0304red\x03 '
colorstring += '\x0305brown\x03 \x0306magenta\x03 \x0307orange\x03 \x0308yellow\x03 '
colorstring += '\x0309lightgreen\x03 \x0310cyan\x03 \x0311lightcyan\x03 \x0312lightblue\x03 '
colorstring += '\x0313pink\x03 \x0314grey\x03 \x0315lightgrey\x03\x0f'
print(irc_color_to_ansi('hi \x02bold\x02 \x1ditalic\x1d \x1funderline\x1f \x1estrikethrough\x1e'))
print(irc_color_to_ansi(colorstring))
print(irc_color_to_ansi(colorstring.replace(' \x03', ' \x0301,')))
@spaceone
Copy link
Contributor Author

I added a test case :-)

@prologic prologic merged commit 4923743 into master Sep 18, 2018
@spaceone spaceone deleted the irc_ansi_color branch November 29, 2018 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants