mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-25 13:57:59 +01:00
when using -o metadata can remove lines at the top and at the bottom of the pony
This commit is contained in:
parent
940e3489d2
commit
e30f25b7b1
1 changed files with 22 additions and 1 deletions
23
ponysay.py
23
ponysay.py
|
@ -1595,6 +1595,8 @@ class Backend():
|
|||
self.hyphen = hyphen
|
||||
self.ballooncolour = ballooncolour
|
||||
self.mode = mode
|
||||
self.balloontop = 0
|
||||
self.balloonbottom = 0
|
||||
|
||||
if self.balloon is not None:
|
||||
self.link = {'\\' : linkcolour + self.balloon.link,
|
||||
|
@ -1617,7 +1619,20 @@ class Backend():
|
|||
if self.pony.startswith('$$$\n'):
|
||||
self.pony = self.pony[4:]
|
||||
infoend = self.pony.index('\n$$$\n')
|
||||
printinfo(self.pony[:infoend])
|
||||
info = self.pony[:infoend].split('\n')
|
||||
for line in info:
|
||||
sep = line.find(':')
|
||||
if sep > 0:
|
||||
key = line[:sep].strip()
|
||||
if key == 'BALLOON TOP':
|
||||
value = line[sep + 1:].strip()
|
||||
if len(value) > 0:
|
||||
self.balloontop = int(value)
|
||||
if key == 'BALLOON BOTTOM':
|
||||
value = line[sep + 1:].strip()
|
||||
if len(value) > 0:
|
||||
self.balloonbottom = int(value)
|
||||
printinfo(info)
|
||||
self.pony = self.pony[infoend + 5:]
|
||||
self.pony = self.mode + self.pony
|
||||
|
||||
|
@ -1832,6 +1847,12 @@ class Backend():
|
|||
|
||||
self.output = self.output.replace(AUTO_PUSH, '').replace(AUTO_POP, '')
|
||||
|
||||
if self.balloon is not None:
|
||||
if (self.balloontop > 0) or (self.balloonbottom > 0):
|
||||
self.output = self.output.split('\n')
|
||||
self.output = self.output[self.balloontop : ~(self.balloonbottom)]
|
||||
self.output = '\n'.join(self.output)
|
||||
|
||||
|
||||
'''
|
||||
Gets colour code att the currect offset in a buffer
|
||||
|
|
Loading…
Reference in a new issue