m ponybrowser

This commit is contained in:
Mattias Andrée 2012-11-05 21:22:59 +01:00
parent 0d802b2d01
commit 3bdf5ff146

View file

@ -298,7 +298,7 @@ class PonysayTool():
if py < 0:
ponyprint = [] if -py > len(ponyprint) else ponyprint[-py:]
elif py > 0:
ponyprint = py * ['\n'] + ponyprint
ponyprint = py * [''] + ponyprint
ponyprint = ponyprint[:len(ponyprint) if len(ponyprint) < termh else termh]
def findcolumn(line, column):
if Backend.len(line) >= column:
@ -334,13 +334,21 @@ class PonysayTool():
cury = 0
for line in ponies[panely:]:
cury += 1
print('\033[%i;%iH\033[%im%s\033[0m' % (cury, panelx + 1, 1 if panely + cury - 1 == ponyindex else 0, (line + ' ' * panelw)[:panelw]), end='')
if os.path.islink((ponydir + '/' + line + '.pony').replace('//', '/')):
line = '\033[34m%s\033[39m' % ((line + ' ' * panelw)[:panelw])
else:
line = (line + ' ' * panelw)[:panelw]
print('\033[%i;%iH\033[%im%s\033[0m' % (cury, panelx + 1, 1 if panely + cury - 1 == ponyindex else 0, line), end='')
elif printpanel >= 0:
for index in (printpanel, ponyindex):
cury = index - panely
if (0 <= cury) and (cury < termh):
line = ponies[cury + panely]
print('\033[%i;%iH\033[%im%s\033[0m' % (cury, panelx + 1, 1 if panely + cury - 1 == ponyindex else 0, (line + ' ' * panelw)[:panelw]), end='')
if os.path.islink((ponydir + '/' + line + '.pony').replace('//', '/')):
line = '\033[34m%s\033[39m' % ((line + ' ' * panelw)[:panelw])
else:
line = (line + ' ' * panelw)[:panelw]
print('\033[%i;%iH\033[%im%s\033[0m' % (cury, panelx + 1, 1 if panely + cury - 1 == ponyindex else 0, line), end='')
sys.stdout.buffer.flush()
if stored is None: