mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-26 06:07:59 +01:00
wrapping use getcolour() instead of implementing it itself (code deduplication) + getcolour() recognises xterm palette changes
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
d5cd93b87d
commit
aeea52b238
1 changed files with 22 additions and 25 deletions
47
ponysay.py
47
ponysay.py
|
@ -2173,6 +2173,22 @@ class Backend():
|
||||||
i += 1
|
i += 1
|
||||||
di += 1
|
di += 1
|
||||||
rc += c
|
rc += c
|
||||||
|
while c == '0':
|
||||||
|
c = input[i]
|
||||||
|
i += 1
|
||||||
|
rc += c
|
||||||
|
if c == '4':
|
||||||
|
c = input[i]
|
||||||
|
i += 1
|
||||||
|
rc += c
|
||||||
|
if c == ';':
|
||||||
|
c = input[i]
|
||||||
|
i += 1
|
||||||
|
rc += c
|
||||||
|
while c != '\\':
|
||||||
|
c = input[i]
|
||||||
|
i += 1
|
||||||
|
rc += c
|
||||||
elif c == '[':
|
elif c == '[':
|
||||||
while i < n:
|
while i < n:
|
||||||
c = input[i]
|
c = input[i]
|
||||||
|
@ -2290,32 +2306,13 @@ class Backend():
|
||||||
if i < n:
|
if i < n:
|
||||||
d = line[i]
|
d = line[i]
|
||||||
i += 1
|
i += 1
|
||||||
if d == '\033': # TODO this should use Backend.getcolour()
|
if d == '\033':
|
||||||
## Invisible stuff
|
## Invisible stuff
|
||||||
b[bi] = d
|
i -= 1
|
||||||
bi += 1
|
colourseq = Backend.getcolour(line, i)
|
||||||
b[bi] = line[i]
|
b[bi : bi + len(colourseq)] = colourseq
|
||||||
d = line[i]
|
i += len(colourseq)
|
||||||
bi += 1
|
bi += len(colourseq)
|
||||||
i += 1
|
|
||||||
if d == '[':
|
|
||||||
while True:
|
|
||||||
b[bi] = line[i]
|
|
||||||
d = line[i]
|
|
||||||
bi += 1
|
|
||||||
i += 1
|
|
||||||
if (('a' <= d) and (d <= 'z')) or (('A' <= d) and (d <= 'Z')) or (d == '~'):
|
|
||||||
break
|
|
||||||
elif d == ']':
|
|
||||||
b[bi] = line[i]
|
|
||||||
d = line[i]
|
|
||||||
bi += 1
|
|
||||||
i += 1
|
|
||||||
if d == 'P':
|
|
||||||
for j in range(0, 7):
|
|
||||||
b[bi] = line[i]
|
|
||||||
bi += 1
|
|
||||||
i += 1
|
|
||||||
elif (d is not None) and (d != ' '):
|
elif (d is not None) and (d != ' '):
|
||||||
## Fetch word
|
## Fetch word
|
||||||
if indent == -1:
|
if indent == -1:
|
||||||
|
|
Loading…
Reference in a new issue