- Made many small bugfixes to the @parent and @create functions as well as their underlying methods.
- Made it so user #1 is also affected by the on_player_creation() function. - Added an event folder for custom events, including a working example - Expanded the example commands and parents to include the changes to how they should be initialized. - Added an optional ansi scheme (not active by default)
This commit is contained in:
parent
a32840002c
commit
a9dbac8aae
16 changed files with 397 additions and 35 deletions
36
src/ansi.py
36
src/ansi.py
|
|
@ -105,10 +105,42 @@ class MuxANSIParser(BaseParser):
|
|||
(r'%cw', ANSITable.ansi["white"]),
|
||||
(r'%cW', ANSITable.ansi["back_white"]),
|
||||
]
|
||||
|
||||
class ExtendedANSIParser(MuxANSIParser):
|
||||
"""
|
||||
Extends the standard mux colour commands with {-style commands
|
||||
(shortcuts for writing light/dark text without background)
|
||||
"""
|
||||
def __init__(self):
|
||||
super(ExtendedANSIParser, self).__init__()
|
||||
hilite = ANSITable.ansi['hilite']
|
||||
normal = ANSITable.ansi['normal']
|
||||
self.ansi_subs.extend( [
|
||||
(r'{r', hilite + ANSITable.ansi['red']),
|
||||
(r'{R', normal + ANSITable.ansi['red']),
|
||||
(r'{g', hilite + ANSITable.ansi['green']),
|
||||
(r'{G', normal + ANSITable.ansi['green']),
|
||||
(r'{y', hilite + ANSITable.ansi['yellow']),
|
||||
(r'{Y', normal + ANSITable.ansi['yellow']),
|
||||
(r'{b', hilite + ANSITable.ansi['blue']),
|
||||
(r'{B', normal + ANSITable.ansi['blue']),
|
||||
(r'{m', hilite + ANSITable.ansi['magenta']),
|
||||
(r'{M', normal + ANSITable.ansi['magenta']),
|
||||
(r'{c', hilite + ANSITable.ansi['cyan']),
|
||||
(r'{C', normal + ANSITable.ansi['cyan']),
|
||||
(r'{w', hilite + ANSITable.ansi['white']), #white
|
||||
(r'{W', normal + ANSITable.ansi['white']), #light grey
|
||||
(r'{x', hilite + ANSITable.ansi['black']), #dark grey
|
||||
(r'{X', normal + ANSITable.ansi['black']), #pure black
|
||||
(r'{n', normal) #reset
|
||||
] )
|
||||
|
||||
def parse_ansi(string, strip_ansi=False, strip_formatting=False, parser=MuxANSIParser()):
|
||||
ANSI_PARSER = MuxANSIParser()
|
||||
#ANSI_PARSER = ExtendedANSIParser()
|
||||
|
||||
def parse_ansi(string, strip_ansi=False, strip_formatting=False, parser=ANSI_PARSER):
|
||||
"""
|
||||
Parses a string, subbing color codes as needed.
|
||||
"""
|
||||
return parser.parse_ansi(string, strip_ansi=strip_ansi,
|
||||
strip_formatting=strip_formatting)
|
||||
strip_formatting=strip_formatting)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue