m code style + fix issue 169

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-08-12 06:28:30 +02:00
parent f07c6d8631
commit 8f98681290
2 changed files with 21 additions and 21 deletions

View file

@ -189,7 +189,7 @@ class Backend():
c = line[i]
i += 1
if c == '\033':
colour = Backend.getcolour(line, i - 1)
colour = Backend.getColour(line, i - 1)
i += len(colour) - 1
buf += colour
elif c == '\t':
@ -226,7 +226,7 @@ class Backend():
c = line[i]
i += 1
if c == '\033':
colour = Backend.getcolour(line, i - 1)
colour = Backend.getColour(line, i - 1)
i += len(colour) - 1
self.output += colour
else:
@ -335,7 +335,7 @@ class Backend():
i += 1
dollar += c
elif c == '\033':
colour = Backend.getcolour(self.pony, i - 1)
colour = Backend.getColour(self.pony, i - 1)
for b in colour:
self.output += b + colourstack.feed(b);
i += len(colour) - 1
@ -392,7 +392,7 @@ class Backend():
@return :str The escape sequence
'''
@staticmethod
def getcolour(input, offset):
def getColour(input, offset):
(i, n) = (offset, len(input))
rc = input[i]
i += 1
@ -452,7 +452,7 @@ class Backend():
while i < n:
c = input[i]
if c == '\033':
i += len(Backend.getcolour(input, i))
i += len(Backend.getColour(input, i))
else:
i += 1
if not UCS.isCombining(c):
@ -527,7 +527,7 @@ class Backend():
try:
AUTO_PUSH = '\033[01010~'
AUTO_POP = '\033[10101~'
msg = message.replace('\n', AUTO_PUSH + '\n' + AUTO_POP);
msg = message.replace('\n', AUTO_PUSH + '\n' + AUTO_POP)
cstack = ColourStack(AUTO_PUSH, AUTO_POP)
for c in msg:
buf += c + cstack.feed(c)
@ -549,7 +549,7 @@ class Backend():
if d == '\033':
## Invisible stuff
i -= 1
colourseq = Backend.getcolour(line, i)
colourseq = Backend.getColour(line, i)
b[bi : bi + len(colourseq)] = colourseq
i += len(colourseq)
bi += len(colourseq)
@ -599,7 +599,7 @@ class Backend():
w = iwrap
if indent != -1:
buf += line[:indent]
buf += ' ' * indentc
for j in range(bisub, bi):
b[j - bisub] = b[j]
@ -609,7 +609,7 @@ class Backend():
buf += '\n'
w = wrap
if indent != -1:
buf += line[:indent]
buf += ' ' * indentc
w -= indentc
for bb in b[:bi]:
if bb is not None:
@ -627,18 +627,18 @@ class Backend():
buf += '\n'
w = wrap
if indent != -1:
buf + line[:indent]
buf += ' ' * indentc
w -= indentc
buf += '\n'
rc = '\n'.join(line.rstrip() for line in buf[:-1].split('\n'));
rc = '\n'.join(line.rstrip(' ') for line in buf[:-1].split('\n'));
rc = rc.replace('­', ''); # remove soft hyphens
rc = rc.replace('\0', '%s%s%s' % (AUTO_PUSH, self.hyphen, AUTO_POP))
return rc
except Exception as err:
import traceback
errormessage = ''.join(traceback.format_exception(type(err), err, None))
rc = '\n'.join(line.rstrip() for line in buf.split('\n'));
rc = '\n'.join(line.rstrip(' ') for line in buf.split('\n'));
rc = rc.replace('\0', '%s%s%s' % (AUTO_PUSH, self.hyphen, AUTO_POP))
errormessage += '\n---- WRAPPING BUFFER ----\n\n' + rc
try:

View file

@ -106,14 +106,14 @@ class ColourStack():
p = 0 if part == '' else int(part)
i += 1
if p == 0: self.stack[0][1:] = [None, None, [False] * 9]
elif (1 <= p) and (p <= 9): self.stack[0][3][p - 1] = True
elif (21 <= p) and (p <= 29): self.stack[0][3][p - 21] = False
elif 1 <= p <= 9: self.stack[0][3][p - 1] = True
elif 21 <= p <= 29: self.stack[0][3][p - 21] = False
elif p == 39: self.stack[0][1] = None
elif p == 49: self.stack[0][2] = None
elif (30 <= p) and (p <= 37): self.stack[0][1] = part
elif (90 <= p) and (p <= 97): self.stack[0][1] = part
elif (40 <= p) and (p <= 47): self.stack[0][2] = part
elif (100 <= p) and (p <= 107): self.stack[0][2] = part
elif 30 <= p <= 37: self.stack[0][1] = part
elif 90 <= p <= 97: self.stack[0][1] = part
elif 40 <= p <= 47: self.stack[0][2] = part
elif 100 <= p <= 107: self.stack[0][2] = part
elif p == 38:
self.stack[0][1] = '%s;%s;%s' % (part, self.seq[i], self.seq[i + 1])
i += 2