From 3bdf5ff146ff4ef0540b29a6420fdca5785b4cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 5 Nov 2012 21:22:59 +0100 Subject: [PATCH] m ponybrowser --- ponysay-tool.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ponysay-tool.py b/ponysay-tool.py index f2bcaa4e..05b0deac 100755 --- a/ponysay-tool.py +++ b/ponysay-tool.py @@ -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: