mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 04:27:16 +02:00
Made EvCels auto-close colors rather than bleed over. This is necessary to avoid accidental color clashes in tables that fill the cells to a |-border edge (particularly for EvForm.
This commit is contained in:
parent
0d5ecb1877
commit
ecf6852d46
5 changed files with 17 additions and 19 deletions
|
|
@ -76,7 +76,7 @@ class ANSIParser(object):
|
|||
|
||||
We also allow to escape colour codes
|
||||
by prepending with a \ for xterm256,
|
||||
an extra { for Merc-style codes
|
||||
an extra | for Merc-style codes
|
||||
"""
|
||||
|
||||
def sub_ansi(self, ansimatch):
|
||||
|
|
|
|||
|
|
@ -429,8 +429,8 @@ def _test():
|
|||
form = EvForm("evennia.utils.evform_test")
|
||||
|
||||
# add data to each tagged form cell
|
||||
form.map(cells={1: "{gTom the Bouncer{n",
|
||||
2: "{yGriatch{n",
|
||||
form.map(cells={1: "|gTom the Bouncer",
|
||||
2: "|yGriatch",
|
||||
3: "A sturdy fellow",
|
||||
4: 12,
|
||||
5: 10,
|
||||
|
|
@ -450,5 +450,4 @@ def _test():
|
|||
form.map(tables={"A": tableA,
|
||||
"B": tableB})
|
||||
# unicode is required since the example contains non-ascii characters
|
||||
#print(unicode(form))
|
||||
return form
|
||||
return unicode(form)
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ FORM = """
|
|||
| xxxxx3xxxxx INT: x6x STA: x7x |
|
||||
| xxxxxxxxxxx LUC: x8x MAG: x9x |
|
||||
| |
|
||||
>----------------------------------------------<
|
||||
| | |
|
||||
| cccccccc | ccccccccccccccccccccccccccccccccccc |
|
||||
| cccccccc | ccccccccccccccccccccccccccccccccccc |
|
||||
| cccAcccc | ccccccccccccccccccccccccccccccccccc |
|
||||
| cccccccc | ccccccccccccccccccccccccccccccccccc |
|
||||
| cccccccc | cccccccccccccccccBccccccccccccccccc |
|
||||
| | |
|
||||
------------------------------------------------
|
||||
>----------.-----------------------------------<
|
||||
| | |
|
||||
| ccccccccc | cccccccccccccccccccccccccccccccccc |
|
||||
| ccccccccc | cccccccccccccccccccccccccccccccccc |
|
||||
| cccAccccc | cccccccccccccccccccccccccccccccccc |
|
||||
| ccccccccc | cccccccccccccccccccccccccccccccccc |
|
||||
| ccccccccc | ccccccccccccccccBccccccccccccccccc |
|
||||
| | |
|
||||
-----------`-------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -646,8 +646,8 @@ class EvCell(object):
|
|||
|
||||
"""
|
||||
|
||||
left = self.border_left_char * self.border_left
|
||||
right = self.border_right_char * self.border_right
|
||||
left = self.border_left_char * self.border_left + ANSIString('|n')
|
||||
right = ANSIString('|n') + self.border_right_char * self.border_right
|
||||
|
||||
cwidth = self.width + self.pad_left + self.pad_right + \
|
||||
max(0,self.border_left-1) + max(0, self.border_right-1)
|
||||
|
|
|
|||
|
|
@ -350,9 +350,8 @@ from evennia.utils import evform
|
|||
class TestEvForm(TestCase):
|
||||
def test_form(self):
|
||||
self.maxDiff = None
|
||||
self.assertEqual(unicode(evform._test()),
|
||||
u'.------------------------------------------------.\n| |\n| Name: \x1b[1m\x1b[32mTom\x1b[1m\x1b[32m \x1b[1m\x1b[32mthe\x1b[1m\x1b[32m \x1b[0m Player: \x1b[1m\x1b[33mGriatch\x1b[0m \x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[0m |\n| \x1b[1m\x1b[32mBouncer\x1b[0m\x1b[0m |\n| |\n >----------------------------------------------<\n| |\n| Desc: A sturdy \x1b[0m STR: 12 \x1b[0m DEX: 10 \x1b[0m |\n| fellow\x1b[0m INT: 5 \x1b[0m STA: 18 \x1b[0m |\n| LUC: 10 MAG: 3 |\n| |\n >----------------------------------------------<\n| | |\n| HP|MV |M\x1b[0m | Skill |Value |Exp \x1b[0m |\n| ~~+~~~+~ | ~~~~~~~~~~~~+~~~~~~~~~~+~~~~~~~~~~~ |\n| **|***\x1b[0m|*\x1b[0m | Shooting |12 |550/1200 \x1b[0m\x1b[0m |\n| |**\x1b[0m |*\x1b[0m | Herbalism |14 |990/1400 \x1b[0m\x1b[0m |\n| | |*\x1b[0m | Smithing |9 |205/900 \x1b[0m |\n| | |\n ------------------------------------------------\n')
|
||||
|
||||
self.assertEqual(evform._test(),
|
||||
u'.------------------------------------------------.\n| |\n| Name: \x1b[0m\x1b[1m\x1b[32mTom\x1b[1m\x1b[32m \x1b[1m\x1b[32mthe\x1b[1m\x1b[32m \x1b[0m \x1b[0m Player: \x1b[0m\x1b[1m\x1b[33mGriatch \x1b[0m\x1b[0m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[0m\x1b[0m |\n| \x1b[0m\x1b[1m\x1b[32mBouncer\x1b[0m \x1b[0m |\n| |\n >----------------------------------------------<\n| |\n| Desc: \x1b[0mA sturdy \x1b[0m \x1b[0m STR: \x1b[0m12 \x1b[0m\x1b[0m\x1b[0m\x1b[0m DEX: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| \x1b[0mfellow\x1b[0m \x1b[0m INT: \x1b[0m5 \x1b[0m\x1b[0m\x1b[0m\x1b[0m STA: \x1b[0m18 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| \x1b[0m \x1b[0m LUC: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m MAG: \x1b[0m3 \x1b[0m\x1b[0m\x1b[0m |\n| |\n >----------.-----------------------------------<\n| | |\n| \x1b[0mHP\x1b[0m|\x1b[0mMV \x1b[0m|\x1b[0mMP\x1b[0m | \x1b[0mSkill \x1b[0m|\x1b[0mValue \x1b[0m|\x1b[0mExp \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| ~~+~~~+~~ | ~~~~~~~~~~~+~~~~~~~~~~+~~~~~~~~~~~ |\n| \x1b[0m**\x1b[0m|\x1b[0m***\x1b[0m\x1b[0m|\x1b[0m**\x1b[0m\x1b[0m | \x1b[0mShooting \x1b[0m|\x1b[0m12 \x1b[0m|\x1b[0m550/1200 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| \x1b[0m \x1b[0m|\x1b[0m**\x1b[0m \x1b[0m|\x1b[0m*\x1b[0m \x1b[0m | \x1b[0mHerbalism \x1b[0m|\x1b[0m14 \x1b[0m|\x1b[0m990/1400 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| \x1b[0m \x1b[0m|\x1b[0m \x1b[0m|\x1b[0m \x1b[0m | \x1b[0mSmithing \x1b[0m|\x1b[0m9 \x1b[0m|\x1b[0m205/900 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n| | |\n -----------`-------------------------------------\n')
|
||||
def test_ansi_escape(self):
|
||||
# note that in a msg() call, the result would be the correct |-----,
|
||||
# in a print, ansi only gets called once, so ||----- is the result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue