Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Pablo Lezaeta 2012-07-20 19:22:39 -04:00
commit 39f9721778
9 changed files with 144 additions and 32 deletions

View file

@ -134,9 +134,9 @@ uninstall:
clean:
rm -f "ponysaytruncater"
rm "completion/bash-completion-think.sh"
rm "completion/fish-completion-think.fish"
rm "completion/zsh-completion-think.zsh"
rm "manuals/manpage.6.gz"
rm "manuals/manpage.es.6.gz"
rm "ponysay.info.gz"
rm -f "completion/bash-completion-think.sh"
rm -f "completion/fish-completion-think.fish"
rm -f "completion/zsh-completion-think.zsh"
rm -f "manuals/manpage.6.gz"
rm -f "manuals/manpage.es.6.gz"
rm -f "ponysay.info.gz"

View file

@ -30,8 +30,11 @@ Or if you have a specific pony in your mind:
Run `info ponysay`, `man 6 ponysay` or `ponysay -h` for more information.
A Spanish manual is available: `man -L es 6 ponysay`.
#### Gentoo
Theres a package for gentoo, to make install and keeping up to date easy. You can find it in [this overlay](/etu/aidstu-overlay). Package is named `games-misc/ponysay`.
#### Arch Linux
The package is in the official repositories as `community/ponysay`.
#### Gentoo Linux
There is a package for Gentoo, to make installation and keeping it up to date easy. You can find it in [this overlay](/etu/aidstu-overlay). The package is named `games-misc/ponysay`.
### Pony fortune on terminal startup

View file

@ -13,11 +13,11 @@ end
if test -d $systempath
set -g systemponies (ls --color=no $systempath | sed 's/\.pony//')
set -g systemponies (ls --color=no $systempath | sed -e 's/\.pony//' -e 's/_.*//' | perl -pe 's/([a-z])([A-Z])/\1\\\ \2/' )
end
if test -d $homepath
set -g homeponies (ls --color=no $homepath | sed 's/\.pony//')
set -g homeponies (ls --color=no $homepath | sed -e 's/\.pony//' -e 's/_.*//' | perl -pe 's/([a-z])([A-Z])/\1\\\ \2/' )
end

View file

@ -36,7 +36,7 @@ Texts. A copy of the license is included in the section entitled
@title Ponysay
@subtitle A cowsay wrapper for ponies.
@subtitle Covers ponysay version @value{VERSION}.
@author by Mattias Andrée
@author by Mattias Andrée (maandree)
@page
@vskip 0pt plus 1filll
@ -56,7 +56,7 @@ Texts. A copy of the license is included in the section entitled
* Dependencies:: Dependencies.
* Installing:: Installing.
* Extensions:: Extensions.
@c Inner workings->Pony anatomy
* Inner workings:: Inner workings.
* Contributing:: Contributing.
* Ponysay constributors:: Ponysay constributors.
* Ponysay license:: Ponysay license.
@ -189,7 +189,7 @@ by using @code{fortune | ponypipe} instead of using @command{fortune}.
Alternatively use can use @command{pinkie} (or @command{pinkiepie}), which can
be downloaded from @url{https://github.com/maandree/pinkie-pie}, which is just
@code{fortune | ponypipe}.
Their is also a large sed script, similar to @command{ponypipe}: @url{http://www.reddit.com/r/mylittlelinux/comments/srixi/using_ponysay_with_a_ponified_fortune_warning/}
There is also a large sed script, similar to @command{ponypipe}: @url{http://www.reddit.com/r/mylittlelinux/comments/srixi/using_ponysay_with_a_ponified_fortune_warning/}
@node Running on TTY
@ -212,13 +212,13 @@ If you use TTY and have a custom colour palette, you should also add to your
@section Running on @command{screen}
@cindex screen
@command{screen} will adapt ASNI colour escape sequencies to your terminals
@command{screen} will adapt ASNI colour escape sequencies to your terminal's
capabilities. This means that is your terminal reports itself as @code{xterm}
in @code{$TERM} it ponies will lose colours; they will only use the lower 16
colours instread of the top 240 colours. By default, almost all X terminal,
including @command{xterm} and @command{mate-terminal} reports themself as
@code{xterm} in @code{$TERM}, and some reports their actual name in @code{$COLORTERM}.
So before openning @command{screen} you use set @code{$TERM} to @code{xterm-256colour},
So before openning @command{screen} you use set @code{$TERM} to @code{xterm-256color},
if you are using a terminal with support for @code{xterm}'s 256 colours; this
can be done by adding to your @code{~/.bashrc}:
@example
@ -300,6 +300,10 @@ you run @command{ponythink}.
@node Terminals
@section Terminals
@cindex kms
@cindex kernel mode settings
@cindex 9term
@cindex putty
Ponysay works perfectly on @command{xterm}, @command{xterm} like terminals including
@command{putty}, settings may however need to be customised for Unicode Character Set
@ -508,8 +512,88 @@ displayed with the associated ponies. See @ref{Invoking ponysay} for more inform
@node Inner workings
@chapter Inner workings
@cindex inner workings
@cindex hacking
@menu
* Pony anatomy:: Anatomy of pony files.
* Truncation:: Output truncation.
* Languages:: Selection of languages.
@end menu
@node Pony anatomy
@section Pony anatomy
@cindex pony anatomy
@cindex anatomy of pony files
The pony files are cow files used by @command{cowsay}, they are partial Perl-scripts
that assign a value to a scalar variable named @code{$the_cow}. The files use a
predefined scalar named variable named @code{$thoughts}, these are used to create
a link between the message and the pony. The message (and the balloon) it self is
printed by @command{cowsay} and is not definied in the pony files.
The pony images consists of white space, lower half blocks [U+2584], upper half
blocks [U+2580] and ANSI colour sequences (CSI m), and, in TTY, colour value change
sequences (OSI P).
@node Truncation
@section Truncation
@cindex truncation
@cindex output trunction
@cindex kms
@cindex kernel mode settings
Ponysay supports three type of output truncations, cutting away overflow on the right
and truncation the height by either keeping the bottom or keeping the top. By default
the latest is enabled under TTY, cutting away overflow on the right is always enabled
by default.
Truncating the height in TTY is required under Kernel Mode Settings (KMS) support to
keep the colours from being messed up ad the ponies is moved in the screen during
print; this done either by piping to @command{head} (keeps the top) or by piping to
@command{tail} (keeps the bottom.) @command{head} and @command{tail} takes as argument
the number of lines to keep at most.
The size of the terminal, measured in characters, is fetched from @command{stty size},
which returns @code{HEIGHT WIDTH}, and @command{cut} it the used to get either the
height or the width. This required on GNU Coreutils; earlier @command{tput rows} and
@command{tput cols} were used, this however required, the only de facto standard,
package @command{ncurses}, some shells have environment variables for this.
For truncation the width, we have a custom program, named @command{ponysaytruncater},
that is installed to @code{/usr/lib/ponysay/truncater}. It recognised UTF-8 ANSI escape
sequences, including OSI P and CSI m, which is essential for the truncation to be correct.
It also expands tabs to every eigth coloumn and resets the background colour when needed,
and writes ANSI escape sequences that are on the left side of the truncation. The truncater
stops CSI sequences on the first ASCII letter (@code{[a-zA-Z]}), but also stops escape
sequences after the first character after the initial escape if it is not either [ (CSI)
or ] (OSI). For support UTF-8, to handles all bytes that do not match @code{10xxxxxx} as
beginning of a character.
@node Languages
@section Languages
@cindex languages
@cindex script languages
@cindex programming languages
Ponysay is written primarily in GNU Bash shell script (POSIX compliant); the truncater
is however written in C, because it is simple, fast, does not pose addition dependencies,
and is easy to do byte hacking in.
Sometimes shell is too slow, in these cases [that exist today] Perl is used; Perl
is already required by cowsay, is similar to shell, but also supports hash tables.
[maandree: I actually learned Perl just for this.]
@node Contributing
@chapter Contributing
@cindex contributing
@menu
* Providing ponies:: Providing ponies
@ -526,6 +610,9 @@ desktop ponies, implementing it in JavaScript. Browser ponies are available at
There is also a collection of ponies that are not yet pixelated in a Java reimplementation:
@url{https://github.com/maandree/unisay/tree/develop/dev/newponies}
There is a checklist named @code{"pony-checklist"} at the top level of the project
directory. You can use the check which ponies are added and which are not.
@*
New ponies can be created from regular images by using util-say, which is available

View file

@ -1,4 +1,4 @@
Pony checklist bas ed one http://mlp.wikia.com/wiki/List_of_ponies version 2012-(07)Jul-11 06:55
Pony checklist based on http://mlp.wikia.com/wiki/List_of_ponies version 2012-(07)Jul-11 06:55
Ponies with just the name are already added to ponysay.
Why not comment the lines for the ponies you are working on.
@ -532,7 +532,7 @@ S02E17 Unnamed Prince http://images2.wikia.nocookie.net/__cb20120320011919/m
S02E17 Unnamed Princess http://images3.wikia.nocookie.net/__cb20120320011919/mlp/images/thumb/a/ac/Love_poison_princess_s02e17.png/150px-Love_poison_princess_s02e17.png
Unnamed ponies with with pictures available:
Unnamed ponies with pictures available:
Unnamed teacher Earth pony http://images4.wikia.nocookie.net/__cb20120716010319/mlp/images/thumb/8/8b/Math_teacher_pony.png/140px-Math_teacher_pony.png http://www.reddit.com/r/listofponies/comments/wmcha/earth_pony_m_coatgray_manewhite/
S01E03 Unnamed Earth Stallion #1
@ -625,6 +625,10 @@ S02E13 Unnamed Unicorn Baby #1
S02E23 Unnamed Earth Filly #1 http://www.reddit.com/r/listofponies/comments/un6ae/earth_pony_f_coatgreen_manepurple_eyesblue_cmnone/
S02E23 Unnamed Earth Colt #1 http://www.reddit.com/r/listofponies/comments/rs1zd/earth_pony_m_coatgreen_maneblue_eyesblue/
Ponies not listed:
S01E06 The green haired ponies saying: Well I'd never.
More characters:

24
ponysay
View file

@ -1,12 +1,16 @@
#!/usr/bin/env bash
version=1.0
version=1.1
SYSTEMPONIES="/usr/share/ponysay/ponies"
HOMEPONIES="${HOME}/.local/share/ponysay/ponies"
SCRIPTDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get bash script directory
pony="*"
wrap=""
kmscmd=""
[[ "$TERM" = "linux" ]] && kmscmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/ponysay2kmsponysay /g'); do if [[ -f $c ]]; then echo $c; break; fi done)
[[ ! "$kmscmd" = "" ]] && TERM="-linux-"
if [ "$TERM" = "linux" ]; then
SYSTEMPONIES="/usr/share/ponysay/ttyponies"
HOMEPONIES="${HOME}/.local/share/ponysay/ttyponies"
@ -247,14 +251,24 @@ say() {
}
fi
if [[ "$kmscmd" = "" ]]; then
function runcmd {
cowcmd -f "$pony" "$@"
}
else
function runcmd {
cowcmd -f <($kmscmd "$pony") "$@"
}
fi
if [ "$TERM" = "linux" ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'yes' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'y' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = '1' ]; then
if [ "$PONYSAY_BOTTOM" = 'yes' ] || [ "$PONYSAY_BOTTOM" = 'y' ] || [ "$PONYSAY_BOTTOM" = '1' ]; then
cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunctail
runcmd "${wrap:+-W$wrap}" | wtrunc | htrunctail
else
cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunchead
runcmd "${wrap:+-W$wrap}" | wtrunc | htrunchead
fi
else
cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc
runcmd "${wrap:+-W$wrap}" | wtrunc
fi
}
@ -270,7 +284,7 @@ while getopts $opts OPT; do
case ${OPT} in
v) version; exit ;;
h) usage; exit ;;
f) ponies+=( "$OPTARG" ) ;;
f) ponies+=($(echo $OPTARG | sed -e 's/ //g')) ;;
l) list; exit ;;
L) linklist; exit ;;
W) wrap="$OPTARG" ;;

Binary file not shown.

View file

@ -15,6 +15,10 @@ $maxw = 1;
foreach $arg (@ARGV)
{
# Format names from ponyies names
$arg =~ s/([a-z])([A-Z])/\1 \2/;
$arg =~ s/_(.*)/\t(\1)/;
if ($first == 1)
{ $first = 0;
$scrw = $arg;

View file

@ -15,7 +15,7 @@
#define STDIN 0
/* The number of columns on the current line */
static int x = 0;
static int col = 0;
/* Escape sequence state */
static int esc = 0;
@ -30,7 +30,7 @@ int toInt(String string);
/* Mane method!
* The only argument, in addition to the executed file,
* should be the width of the terminal which you get by
* adding <code>`tput cols || echo 0`</code> as and argument.
* adding <code>`tput cols || echo 0`</code> as an argument.
*
* @param argc The number of startup arguments
* @param argv The startup arguments, the first is the file itself
@ -61,13 +61,13 @@ void main(int argc, String* argv)
void write(char b, int width)
{
int i;
char nx;
char tabstop;
if (esc == 0)
{
if (b == '\n')
{
if (x >= width)
if (col >= width)
{
/* Reset background colour */
write('\e', width);
@ -76,13 +76,13 @@ void write(char b, int width)
write('9', width);
write('m', width);
}
x = -1;
col = -1;
}
else if (b == '\t')
{
/* Tab to next pos ≡₈ 0 */
nx = 8 - (x & 7);
for (i = 0; i < nx; i++)
tabstop = 8 - (col & 7);
for (i = 0; i < tabstop; i++)
write(' ', width);
return; /* (!) */
}
@ -92,7 +92,7 @@ void write(char b, int width)
else if (esc == 1)
{
if (b == '[') esc = 2; /* CSI: CSI ends with a letter, m is for colour */
else if (b == ']') esc = 3; /* OSI: OSI P is for palett editing in Linux VT */
else if (b == ']') esc = 3; /* OSI: OSI P is for palette editing in Linux VT */
else esc = 10; /* Nothing to see here, move along */
}
else if (esc == 2)
@ -118,14 +118,14 @@ void write(char b, int width)
within bounds
escape sequence
last with printed not first byte in character */
(x < width) ||
(col < width) ||
(esc != 0) ||
(ok && ((b & 0xC0) == 0x80)))
{
printf("%c", b);
if ((esc == 0) && ((b & 0xC0) != 0x80))
/* Count up columns of not in escape sequnce and */
x++; /* the byte is not the first byte in the character */
col++; /* the byte is not the first byte in the character */
ok = true;
}
else