aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manuals/ponysay.texinfo54
-rwxr-xr-xponysay107
2 files changed, 67 insertions, 94 deletions
diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo
index a17ccd2..0b3ff0f 100644
--- a/manuals/ponysay.texinfo
+++ b/manuals/ponysay.texinfo
@@ -256,7 +256,7 @@ that nothing is piped to stdin, a help message will be printed. If you want to u
@command{ponysay} without arguments and enter the message by hand, you can run
@code{cat | ponysay}.
-@cindex file{best.pony}
+@cindex @file{best.pony}
If no pony is selected, @command{ponysay} will look for a @file{best.pony} file,
this should be a symbolic link to the pony you want as a default. If it is not a
symbolic link, @option{-q} cannot determine which quotes to use.
@@ -280,6 +280,7 @@ symbolic link, @option{-q} cannot determine which quotes to use.
@cindex startup
@cindex on startup
@cindex @file{.bashrc}
+@cindex @file{~/.bashrc}
If you have @command{fortune} installed -- this program may be named
@command{fortune-mod} in your GNU/Linux distributions package repository -- you can
@@ -313,6 +314,7 @@ script, but I haven't used the script so I wouldn't know for sure.
@cindex tty
@cindex linux vt
@cindex @file{.bashrc}
+@cindex @file{~/.bashrc}
If you use TTY and have a custom colour palette, you should also add to your
@file{~/.bashrc}, before @code{fortune | ponysay}:
@@ -330,7 +332,8 @@ If you use TTY and have a custom colour palette, you should also add to your
@node Running on screen
@section Running on @command{screen}
@cindex screen
-@cindex .bashrc
+@cindex @file{.bashrc}
+@cindex @file{~/.bashrc}
@command{screen} will adapt ANSI colour escape sequences to your terminal's
capabilities. This means that if your terminal reports itself as @code{xterm}
@@ -470,7 +473,8 @@ the height in TTY by default.
Most terminals have support for 256 colours, we do however only use the top 240
colours; this is because the lower 16 colours are usually, in contrast to the top 240,
customised. We assume that the top 240 colours have their standard values. In TTY with
-KMS support we dot have any actual (except for @math{2^{24}} + full transparency.)
+KMS support we dot have any actual limit (except for @math{2^{24}} + full
+transparency.)
@cindex xterm
@cindex urxvt
@@ -550,6 +554,9 @@ transparent background, and pixelated are the properties that makes a picture go
@cindex dependencies
@cindex optional dependencies
+We have provided a script that should run one most, if not all shells, named
+@file{./dependency-test.sh} that will help you track down any missing package.
+
@menu
* Required runtime dependencies:: Required runtime dependencies.
* Optional runtime dependencies:: Optional runtime dependencies.
@@ -1288,49 +1295,26 @@ Please inform us about your distribution so we can list it, everypony can see it
@cindex versions
@cindex previous releases
-@heading Version 2.4
-
-@item
-New ponies: @code{blaze}
-@end itemize
@heading Version 2.3
@itemize @bullet
@item
-<<<<<<< HEAD
-Support for 'best.pony' file.
-@item
-`-q` accepts file names.
-=======
Support for @file{best.pony} file.
@item
@option{-q} accepts file names.
->>>>>>> 4fcd0b284ff296b41e08056c2dbf35de614e0320
@item
Improved Unicode support: treats combining characters as invisible.
@item
Optional support for UCS pony names.
@item
-<<<<<<< HEAD
-Pony files and balloon style files can be pipes (as
-well as sockets, doors and as always regular files.)
-@item
-Support cowsay style message compression.
-@itemize @bullet
-@item @code{pinkieoink} → @code{oinkoinkoink}
-@end itemize
-@item
-Support for non-MLP:FiM ponies (known as extraponies),
-although the directory is currently empty.
-@end itemize
-
-=======
Pony files and balloon style files can be pipes (as well as sockets, doors
and as always regular files.)
@item
Support cowsay style message compression.
@item
+New ponies: @file{blaze}
+@item
Pony symlink added:
@itemize @bullet
@item @file{pinkieoink} → @file{oinkoinkoink}
@@ -1345,24 +1329,12 @@ corresponding to @option{-f}, @option{-l}, and @option{-L}.
@end itemize
->>>>>>> 4fcd0b284ff296b41e08056c2dbf35de614e0320
@heading Version 2.2
@itemize @bullet
@item
Full support for arbitrary positioning of balloon in pony files.
@item
-<<<<<<< HEAD
-ANSI colour sequences in pony files are applied only to the pony image,
-not the balloon link or the balloon itself.
-@item
-Support for colours in the message.
-@item
-Support custom balloon styles using the option '-b', '-B' will list all
-available. This list depends on whether you are invoking `ponysay` or `ponythink`.
-@end itemize
-
-=======
ANSI colour sequences in pony files are applied only to the pony image,
not the balloon link or the balloon itself.
@item
@@ -1370,10 +1342,10 @@ Support for colours in the message.
@item
Support custom balloon styles using the option @option{-b}, @option{-B} will list
all available. This list depends on whether you are invoking @command{ponysay}
+or @command{ponythink}
@end itemize
->>>>>>> 4fcd0b284ff296b41e08056c2dbf35de614e0320
@heading Version 2.1.1
Nothing worth mention.
diff --git a/ponysay b/ponysay
index faca1d3..0cd87a3 100755
--- a/ponysay
+++ b/ponysay
@@ -25,7 +25,7 @@ from subprocess import Popen, PIPE
'''
The version of ponysay
'''
-VERSION = '2.3'
+VERSION = '2.4'
'''
@@ -89,8 +89,7 @@ class Ponysay():
for ponydir in ponydirs:
if os.path.isfile(ponydir + 'best.pony') or os.path.islink(ponydir + 'best.pony'):
pony = os.path.realpath(ponydir + 'best.pony') # Canonical path
- if args.opts['-q'] is not None: args.opts['-q'] = [pony]
- else: args.opts['-f'] = [pony]
+ args.opts['-f' if args.opts['-q'] is None else '-q'] = [pony]
break
@@ -275,10 +274,54 @@ class Ponysay():
##
'''
+ Columnise a list and prints it
+ '''
+ def __columnise(self, ponies):
+ termwidth = self.__gettermsize()[1] + 2
+ ponies.sort(key = lambda pony : pony[0])
+ widths = [UCS.dispLen(pony[0]) for pony in ponies]
+ width = max(widths) + 2 # longest pony file name + space between columns
+
+ cols = termwidth // width
+ rows = (len(ponies) + cols - 1) // cols
+ columns = []
+ for c in range(0, cols): columns.append([])
+
+ (y, x) = (0, 0)
+ for j in range(0, len(ponies)):
+ cell = ponies[j][1] + ' ' * (width - widths[j]);
+ columns[x].append(cell)
+ y += 1
+ if y == rows:
+ x += 1
+ y = 0
+
+ diff = rows * cols - len(ponies)
+ if diff > 2:
+ c = cols - 1
+ diff -= 1
+ while diff > 0:
+ columns[c] = columns[c - 1][-diff:] + columns[c]
+ c -= 1
+ columns[c] = columns[c][:-diff]
+ diff -= 1
+ pass
+
+ lines = []
+ for r in range(0, rows):
+ lines.append([])
+ for c in range(0, cols):
+ if r < len(columns[c]):
+ line = lines[r].append(columns[c][r])
+
+ print('\n'.join([''.join(line)[:-2] for line in lines]));
+ print()
+
+
+ '''
Lists the available ponies
'''
def list(self):
- termsize = self.__gettermsize()
quoters = self.__quoters()
for ponydir in ponydirs: # Loop ponydirs
@@ -288,24 +331,12 @@ class Ponysay():
if (len(pony) > 5) and (pony[-5:] == '.pony'):
ponies.append(pony[:-5])
self.__ucsise(ponies)
- ponies.sort()
if len(ponies) == 0:
continue
print('\033[1mponies located in ' + ponydir + '\033[21m')
- width = UCS.dispLen(max(ponies, key = UCS.dispLen)) + 2 # Get the longest ponyfilename lenght + 2 spaces
-
- x = 0
- for pony in ponies:
- spacing = ' ' * (width - UCS.dispLen(pony))
- print(('\033[1m' + pony + '\033[21m' if (pony in quoters) else pony) + spacing, end='') # Print ponyfilename
- x += width
- if x > (termsize[1] - width): # If too wide, make new line
- print()
- x = 0
-
- print('' if x == 0 else '\n');
+ self.__columnise([(pony, '\033[1m' + pony + '\033[21m' if pony in quoters else pony) for pony in ponies])
'''
@@ -327,7 +358,7 @@ class Ponysay():
print('\033[1mponies located in ' + ponydir + '\033[21m')
pseudolinkmap = {}
- self.__ucsise(ponies, pseudolinkmap) ##TODO
+ self.__ucsise(ponies, pseudolinkmap)
pairs = []
for pony in ponies:
if pony in pseudolinkmap:
@@ -362,31 +393,15 @@ class Ponysay():
first = True
for sym in syms:
w += UCS.dispLen(sym)
- if not first:
- item += ' '
- else:
- first = False
+ if first: first = False
+ else: item += ' '
item += '\033[1m' + sym + '\033[21m' if (sym in quoters) else sym
item += ')'
- ponies[item] = w
+ ponies[(item.replace('\033[1m', '').replace('\033[21m', ''), item)] = w
if width < w:
width = w
- width += 2;
- x = 0
- index = 0
- ponylist = list(ponies)
- ponylist.sort(key = lambda pony : pony.split(' ')[0].replace('\033[1m', '').replace('\033[21m', ''))
- for pony in ponylist:
- spacing = ' ' * (width - ponies[pony])
- index += 1
- print(pony + spacing, end='') # Print pony file name
- x += width
- if x > termsize[1] - width: # If too wide, make new line
- print()
- x = 0
-
- print('' if x == 0 else '\n');
+ self.__columnise(list(ponies))
'''
@@ -448,21 +463,7 @@ class Ponysay():
if balloon not in balloonset:
balloonset.add(balloon)
- balloons = list(balloonset)
- balloons.sort()
-
- width = UCS.dispLen(max(balloons, key = UCS.dispLen)) + 2
-
- x = 0
- for balloon in balloons:
- spacing = ' ' * (width - UCS.dispLen(balloon))
- print(balloon + spacing, end='')
- x += width
- if x > (termsize[1] - width):
- print()
- x = 0
-
- print();
+ self.__columnise([(balloon, balloon) for balloon in list(balloonset)])
'''