mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Fix some coloring/formatting bugs we had
This commit is contained in:
parent
e877874cf7
commit
0027117e8c
@ -342,7 +342,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
text = privmsgs.getArgs(args)
|
text = privmsgs.getArgs(args)
|
||||||
L = [self._color(c) for c in text]
|
L = [self._color(c) for c in text]
|
||||||
irc.reply(''.join(L))
|
irc.reply('%s%s' % (''.join(L), '\x03'))
|
||||||
|
|
||||||
def colorstrip(self, irc, msg, args):
|
def colorstrip(self, irc, msg, args):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
@ -250,15 +250,15 @@ def joinModes(modes):
|
|||||||
|
|
||||||
def bold(s):
|
def bold(s):
|
||||||
"""Returns the string s, bolded."""
|
"""Returns the string s, bolded."""
|
||||||
return '\x02%s\x0F' % s
|
return '\x02%s\x02' % s
|
||||||
|
|
||||||
def reverse(s):
|
def reverse(s):
|
||||||
"""Returns the string s, reverse-videoed."""
|
"""Returns the string s, reverse-videoed."""
|
||||||
return '\x16%s\x0F' % s
|
return '\x16%s\x16' % s
|
||||||
|
|
||||||
def underline(s):
|
def underline(s):
|
||||||
"""Returns the string s, underlined."""
|
"""Returns the string s, underlined."""
|
||||||
return '\x1F%s\x0F' % s
|
return '\x1F%s\x1F' % s
|
||||||
|
|
||||||
mircColors = {
|
mircColors = {
|
||||||
None: '',
|
None: '',
|
||||||
@ -292,11 +292,11 @@ def mircColor(s, fg=None, bg=None):
|
|||||||
if fg is None or isinstance(fg, str):
|
if fg is None or isinstance(fg, str):
|
||||||
fg = mircColors[fg]
|
fg = mircColors[fg]
|
||||||
if bg is None:
|
if bg is None:
|
||||||
return '\x03%s%s\x0F' % (fg, s)
|
return '\x03%s%s\x03' % (fg, s)
|
||||||
else:
|
else:
|
||||||
if isinstance(bg, str):
|
if isinstance(bg, str):
|
||||||
bg = mircColors[bg]
|
bg = mircColors[bg]
|
||||||
return '\x03%s,%s%s\x0F' % (fg, bg, s)
|
return '\x03%s,%s%s\x03' % (fg, bg, s)
|
||||||
|
|
||||||
def canonicalColor(s, bg=False, shift=0):
|
def canonicalColor(s, bg=False, shift=0):
|
||||||
"""Assigns an (fg, bg) canonical color pair to a string based on its hash
|
"""Assigns an (fg, bg) canonical color pair to a string based on its hash
|
||||||
|
@ -80,6 +80,8 @@ class FilterTest(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
def testColorize(self):
|
def testColorize(self):
|
||||||
self.assertNotRegexp('colorize foobar', r'\s+')
|
self.assertNotRegexp('colorize foobar', r'\s+')
|
||||||
self.assertRegexp('colorize foobar', r'\x03')
|
self.assertRegexp('colorize foobar', r'\x03')
|
||||||
|
# Make sure we're closing colorize with an 'end color' marker
|
||||||
|
self.assertRegexp('colorize foobar', r'\x03$')
|
||||||
|
|
||||||
_strings = ('Supybot pwns!', '123456', 'A string with \x02bold\x15')
|
_strings = ('Supybot pwns!', '123456', 'A string with \x02bold\x15')
|
||||||
def testColorstrip(self):
|
def testColorstrip(self):
|
||||||
|
@ -91,20 +91,20 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
def testBold(self):
|
def testBold(self):
|
||||||
s = ircutils.bold('foo')
|
s = ircutils.bold('foo')
|
||||||
self.assertEqual(s[0], '\x02')
|
self.assertEqual(s[0], '\x02')
|
||||||
self.assertEqual(s[-1], '\x0F')
|
self.assertEqual(s[-1], '\x02')
|
||||||
|
|
||||||
def testMircColor(self):
|
def testMircColor(self):
|
||||||
# No colors provided should return the same string
|
# No colors provided should return the same string
|
||||||
s = 'foo'
|
s = 'foo'
|
||||||
self.assertEqual(s, ircutils.mircColor(s))
|
self.assertEqual(s, ircutils.mircColor(s))
|
||||||
# Test positional args
|
# Test positional args
|
||||||
self.assertEqual('\x030foo\x0F', ircutils.mircColor(s, 'white'))
|
self.assertEqual('\x030foo\x03', ircutils.mircColor(s, 'white'))
|
||||||
self.assertEqual('\x031,2foo\x0F',ircutils.mircColor(s,'black','blue'))
|
self.assertEqual('\x031,2foo\x03',ircutils.mircColor(s,'black','blue'))
|
||||||
self.assertEqual('\x03,3foo\x0F', ircutils.mircColor(s, None, 'green'))
|
self.assertEqual('\x03,3foo\x03', ircutils.mircColor(s, None, 'green'))
|
||||||
# Test keyword args
|
# Test keyword args
|
||||||
self.assertEqual('\x034foo\x0F', ircutils.mircColor(s, fg='red'))
|
self.assertEqual('\x034foo\x03', ircutils.mircColor(s, fg='red'))
|
||||||
self.assertEqual('\x03,5foo\x0F', ircutils.mircColor(s, bg='brown'))
|
self.assertEqual('\x03,5foo\x03', ircutils.mircColor(s, bg='brown'))
|
||||||
self.assertEqual('\x036,7foo\x0F',
|
self.assertEqual('\x036,7foo\x03',
|
||||||
ircutils.mircColor(s, bg='orange', fg='purple'))
|
ircutils.mircColor(s, bg='orange', fg='purple'))
|
||||||
|
|
||||||
def testMircColors(self):
|
def testMircColors(self):
|
||||||
@ -179,20 +179,15 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
self.assertEqual(ircutils.unColor('\x02bold\x0302,04foo\x03bar\x0f'),
|
self.assertEqual(ircutils.unColor('\x02bold\x0302,04foo\x03bar\x0f'),
|
||||||
'\x02boldfoobar\x0f')
|
'\x02boldfoobar\x0f')
|
||||||
self.assertEqual(ircutils.unColor('\x03foo\x03'), 'foo')
|
self.assertEqual(ircutils.unColor('\x03foo\x03'), 'foo')
|
||||||
self.assertEqual(ircutils.unColor('\x03foo\x0F'), 'foo')
|
self.assertEqual(ircutils.unColor('\x03foo\x0F'), 'foo\x0F')
|
||||||
self.assertEqual(ircutils.unColor('\x0312foo\x03'), 'foo')
|
self.assertEqual(ircutils.unColor('\x0312foo\x03'), 'foo')
|
||||||
self.assertEqual(ircutils.unColor('\x0312,14foo\x03'), 'foo')
|
self.assertEqual(ircutils.unColor('\x0312,14foo\x03'), 'foo')
|
||||||
self.assertEqual(ircutils.unColor('\x03,14foo\x03'), 'foo')
|
self.assertEqual(ircutils.unColor('\x03,14foo\x03'), 'foo')
|
||||||
self.assertEqual(ircutils.unColor('\x03,foo\x03'), ',foo')
|
self.assertEqual(ircutils.unColor('\x03,foo\x03'), ',foo')
|
||||||
# These tests aren't going to pass until I decide how to handle
|
self.assertEqual(ircutils.unColor('\x0312foo\x0F'), 'foo\x0F')
|
||||||
# stripping of \x0f. We don't want to just rampantly remove \x0f
|
self.assertEqual(ircutils.unColor('\x0312,14foo\x0F'), 'foo\x0F')
|
||||||
# because it may be a clear code from some other formatting. Leaving
|
self.assertEqual(ircutils.unColor('\x03,14foo\x0F'), 'foo\x0F')
|
||||||
# it in doesn't adversely affect anything, so for now I'm not removing
|
self.assertEqual(ircutils.unColor('\x03,foo\x0F'), ',foo\x0F')
|
||||||
# it.
|
|
||||||
self.assertEqual(ircutils.unColor('\x0312foo\x0F'), 'foo')
|
|
||||||
self.assertEqual(ircutils.unColor('\x0312,14foo\x0F'), 'foo')
|
|
||||||
self.assertEqual(ircutils.unColor('\x03,14foo\x0F'), 'foo')
|
|
||||||
self.assertEqual(ircutils.unColor('\x03,foo\x0F'), ',foo')
|
|
||||||
|
|
||||||
def testDccIpStuff(self):
|
def testDccIpStuff(self):
|
||||||
def randomIP():
|
def randomIP():
|
||||||
|
Loading…
Reference in New Issue
Block a user