mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
MiRC2png.py:MiRC2png._parseAs{Char,ColourSpec}(): fix indentation.
This commit is contained in:
parent
325a454db7
commit
e0300331fd
94
MiRC2png.py
94
MiRC2png.py
@ -112,58 +112,58 @@ class MiRC2png:
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ _parseAsChar(): Parse single character as regular character and mutate state
|
# {{{ _parseAsChar(): Parse single character as regular character and mutate state
|
||||||
def _parseAsChar(self, char):
|
def _parseAsChar(self, char):
|
||||||
if char == "":
|
if char == "":
|
||||||
self.inCurCol += 1; self.inCurBold = 0 if self.inCurBold else 1;
|
self.inCurCol += 1; self.inCurBold = 0 if self.inCurBold else 1;
|
||||||
elif char == "":
|
elif char == "":
|
||||||
self._State = self._State.STATE_COLOUR_SPEC; self.inCurCol += 1;
|
self._State = self._State.STATE_COLOUR_SPEC; self.inCurCol += 1;
|
||||||
elif char == "":
|
elif char == "":
|
||||||
self.inCurCol += 1; self.inCurItalic = 0 if self.inCurItalic else 1;
|
self.inCurCol += 1; self.inCurItalic = 0 if self.inCurItalic else 1;
|
||||||
elif char == "":
|
elif char == "":
|
||||||
self.inCurCol += 1;
|
self.inCurCol += 1;
|
||||||
self.inCurBold = 0; self.inCurItalic = 0; self.inCurUnderline = 0;
|
self.inCurBold = 0; self.inCurItalic = 0; self.inCurUnderline = 0;
|
||||||
self.inCurColourSpec = "";
|
self.inCurColourSpec = "";
|
||||||
elif char == "":
|
elif char == "":
|
||||||
self.inCurCol += 1
|
self.inCurCol += 1
|
||||||
self.outCurColourBg, self.outCurColourFg = self.outCurColourFg, self.outCurColourBg;
|
self.outCurColourBg, self.outCurColourFg = self.outCurColourFg, self.outCurColourBg;
|
||||||
elif char == "":
|
elif char == "":
|
||||||
self.inCurCol += 1; self.inCurUnderline = 0 if self.inCurUnderline else 1;
|
self.inCurCol += 1; self.inCurUnderline = 0 if self.inCurUnderline else 1;
|
||||||
elif char == " ":
|
elif char == " ":
|
||||||
if self.inCurBold:
|
if self.inCurBold:
|
||||||
colourBg = self._ColourMapBold[self.outCurColourBg]
|
colourBg = self._ColourMapBold[self.outCurColourBg]
|
||||||
else:
|
|
||||||
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
|
||||||
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
|
||||||
if self.inCurUnderline:
|
|
||||||
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
|
||||||
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
|
||||||
else:
|
else:
|
||||||
if self.inCurBold:
|
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
||||||
colourBg = self._ColourMapBold[self.outCurColourBg]
|
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
||||||
colourFg = self._ColourMapBold[self.outCurColourFg]
|
if self.inCurUnderline:
|
||||||
else:
|
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
||||||
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
||||||
colourFg = self._ColourMapNormal[self.outCurColourFg]
|
else:
|
||||||
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
if self.inCurBold:
|
||||||
# XXX implement italic
|
colourBg = self._ColourMapBold[self.outCurColourBg]
|
||||||
self.outImgDraw.text((self.outCurX, self.outCurY), char, colourFg, self.outImgFont)
|
colourFg = self._ColourMapBold[self.outCurColourFg]
|
||||||
if self.inCurUnderline:
|
else:
|
||||||
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
||||||
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
colourFg = self._ColourMapNormal[self.outCurColourFg]
|
||||||
|
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
||||||
|
# XXX implement italic
|
||||||
|
self.outImgDraw.text((self.outCurX, self.outCurY), char, colourFg, self.outImgFont)
|
||||||
|
if self.inCurUnderline:
|
||||||
|
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
||||||
|
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _parseAsColourSpec(): Parse single character as mIRC colour control code sequence and mutate state
|
# {{{ _parseAsColourSpec(): Parse single character as mIRC colour control code sequence and mutate state
|
||||||
def _parseAsColourSpec(self, char):
|
def _parseAsColourSpec(self, char):
|
||||||
if char in set(",0123456789"):
|
if char in set(",0123456789"):
|
||||||
self.inCurColourSpec += char; self.inCurCol += 1;
|
self.inCurColourSpec += char; self.inCurCol += 1;
|
||||||
|
else:
|
||||||
|
self.inCurColourSpec = self.inCurColourSpec.split(",")
|
||||||
|
if len(self.inCurColourSpec) == 2:
|
||||||
|
self.outCurColourFg = int(self.inCurColourSpec[0])
|
||||||
|
self.outCurColourBg = int(self.inCurColourSpec[1] or self.outCurColourBg)
|
||||||
|
elif len(self.inCurColourSpec) == 1:
|
||||||
|
self.outCurColourFg = int(self.inCurColourSpec[0])
|
||||||
else:
|
else:
|
||||||
self.inCurColourSpec = self.inCurColourSpec.split(",")
|
self.outCurColourBg = 1; self.outCurColourFg = 15;
|
||||||
if len(self.inCurColourSpec) == 2:
|
self.inCurColourSpec = ""; self._State = self._State.STATE_CHAR;
|
||||||
self.outCurColourFg = int(self.inCurColourSpec[0])
|
|
||||||
self.outCurColourBg = int(self.inCurColourSpec[1] or self.outCurColourBg)
|
|
||||||
elif len(self.inCurColourSpec) == 1:
|
|
||||||
self.outCurColourFg = int(self.inCurColourSpec[0])
|
|
||||||
else:
|
|
||||||
self.outCurColourBg = 1; self.outCurColourFg = 15;
|
|
||||||
self.inCurColourSpec = ""; self._State = self._State.STATE_CHAR;
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user