mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-25 05:47:59 +01:00
Bunch of edits
* Make truncater rather readable and indented (hope you won't mind!) * List people in CREDITS (ask to get your name removed or changed) * Make README better
This commit is contained in:
parent
8da0695c47
commit
cc0ddd7c74
4 changed files with 116 additions and 121 deletions
2
COPYING
2
COPYING
|
@ -1,7 +1,7 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2012 Sven-Hendrik Haase, Jan Alexander Steffens and Erkin Batu Altunbaş
|
||||
Copyright (C) 2012 Erkin Batu Altunbaş
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
|
|
16
CREDITS
Normal file
16
CREDITS
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Pretty much all the contributors in alphabetic order.
|
||||
|
||||
# Active developers
|
||||
Erkin Batu Altunbaş
|
||||
Jan Alexander Steffens
|
||||
Mattias Andrée
|
||||
Sven-Hendrik Haase
|
||||
|
||||
# Patchers and other contributors
|
||||
Duane Bekaert
|
||||
Elis
|
||||
James Ross-Gowan
|
||||
Jannis
|
||||
Kyah Rindlisbacher
|
||||
Louis Taylor
|
||||
Pablo Lezaeta
|
21
README.md
21
README.md
|
@ -1,22 +1,23 @@
|
|||
`ponysay` - A cowsay wrapper with ponies.
|
||||
`ponysay` - A cowsay wrapper for ponies.
|
||||
|
||||
![Derp](http://i.imgur.com/xOJbE.png)
|
||||
|
||||
Today your terminal, tomorrow the world!
|
||||
|
||||
Installation on Linux (or other Unix)
|
||||
-------------------------------------
|
||||
|
||||
If you do not already have `cowsay` you will need to install it
|
||||
First of all, you need `cowsay` from your local repositories.
|
||||
Obtain it from [here](http://www.nog.net/~tony/warez/cowsay.shtml) if you wish to compile it yourself.
|
||||
|
||||
apt-get install cowsay # assuming dpkg
|
||||
[Download](https://github.com/erkin/ponysay/downloads) or clone the project.
|
||||
In the terminal, `cd` into the ponysay directory and `make install`.
|
||||
|
||||
[Download](https://github.com/erkin/ponysay/downloads) the latest project. In the terminal, `cd` into the ponysay directory and run
|
||||
This will install ponysay into the $PREFIX (`/usr` by default, meaning you may need to make as root).
|
||||
|
||||
sudo make
|
||||
In order to use ponysay, run:
|
||||
|
||||
This will install ponysay into the $PREFIX (`/usr` by default). In order to use ponysay, run
|
||||
|
||||
ponysay "I am just the cutest pony"
|
||||
ponysay "I am just the cutest pony!"
|
||||
|
||||
Or if you have a specific pony in your mind:
|
||||
|
||||
|
@ -24,9 +25,7 @@ Or if you have a specific pony in your mind:
|
|||
|
||||
### Pony fortune on terminal startup
|
||||
|
||||
This requires that you have the `fortune` utility installed
|
||||
|
||||
apt-get install fortune
|
||||
This requires that you have the `fortune` utility installed. You can install it from your repositories or just fetch the source code from [here](ftp://ftp.ibiblio.org/pub/linux/games/amusements/fortune/).
|
||||
|
||||
You can try [this](http://www.reddit.com/r/mylittlelinux/comments/srixi/using_ponysay_with_a_ponified_fortune_warning/) script to ponify fortunes.
|
||||
|
||||
|
|
|
@ -1,57 +1,36 @@
|
|||
/**
|
||||
* ponysaytruncater — Output truncater used by ponysay to stop large ponies from being printed badly.
|
||||
/* ponysaytruncater
|
||||
* Output truncater used by ponysay to stop
|
||||
* large ponies from being printed badly.
|
||||
*
|
||||
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
* Licensed under WTFPL
|
||||
* See COPYING for details
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define String char*
|
||||
#define boolean char
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Stdin file descriptor ID
|
||||
*/
|
||||
/* Stdin file descriptor ID */
|
||||
#define STDIN 0
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The number of columns on the current line
|
||||
*/
|
||||
/* The number of columns on the current line */
|
||||
static int x = 0;
|
||||
|
||||
/**
|
||||
* Escape sequence state
|
||||
*/
|
||||
/* Escape sequence state */
|
||||
static int esc = 0;
|
||||
|
||||
/**
|
||||
* Last bytes as written
|
||||
*/
|
||||
/* Last bytes as written */
|
||||
static boolean ok = true;
|
||||
|
||||
|
||||
|
||||
|
||||
void write(char b, int width);
|
||||
int toInt(String string);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Mane method!</p>
|
||||
* <p>
|
||||
/* 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.
|
||||
* </p>
|
||||
*
|
||||
* @param argc The number of startup arguments
|
||||
* @param argv The startup arguments, the first is the file itself
|
||||
|
@ -66,7 +45,7 @@ void main(int argc, String* argv)
|
|||
|
||||
char b = 0;
|
||||
|
||||
if (width > 15) //sanity
|
||||
if (width > 15) /* sanity */
|
||||
while (read(STDIN, &b, 1))
|
||||
write(b, width);
|
||||
else
|
||||
|
@ -74,9 +53,7 @@ void main(int argc, String* argv)
|
|||
printf("%c", b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a character to stdout, iff it fits within the terminal
|
||||
/* Writes a character to stdout, iff it fits within the terminal
|
||||
*
|
||||
* @param b The character (byte) to write
|
||||
* @param width The width of the terminal
|
||||
|
@ -92,7 +69,7 @@ void write(char b, int width)
|
|||
{
|
||||
if (x >= width)
|
||||
{
|
||||
// Reset background colour
|
||||
/* Reset background colour */
|
||||
write('\e', width);
|
||||
write('[', width);
|
||||
write('4', width);
|
||||
|
@ -103,20 +80,22 @@ void write(char b, int width)
|
|||
}
|
||||
else if (b == '\t')
|
||||
{
|
||||
// Tab to next pos ≡₈ 0
|
||||
/* Tab to next pos ≡₈ 0 */
|
||||
nx = 8 - (x & 7);
|
||||
for (i = 0; i < nx; i++)
|
||||
write(' ', width);
|
||||
return; //(!)
|
||||
return; /* (!) */
|
||||
}
|
||||
else if (b == '\e')
|
||||
esc = 1;
|
||||
}
|
||||
else if (esc == 1)
|
||||
{
|
||||
if (b == '[') esc = 2; //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 esc = 10; //Nothing to see here, move along
|
||||
/* CSI ends with a letter, m is for colour
|
||||
OSI, OSI P is for palett editing in Linux VT */
|
||||
if (b == '[') esc = 2;
|
||||
else if (b == ']') esc = 3;
|
||||
else esc = 10; /* Nothing to see here, move along */
|
||||
}
|
||||
else if (esc == 2)
|
||||
{
|
||||
|
@ -136,14 +115,19 @@ void write(char b, int width)
|
|||
else
|
||||
esc = 10;
|
||||
|
||||
if ( // Can be printed:
|
||||
(x < width) || // within bounds ∨
|
||||
(esc != 0) || // ∨ escape sequence ∨
|
||||
(ok && ((b & 0xC0) == 0x80))) // ∨ last with printed ∧ not first byte in character
|
||||
if (
|
||||
/* Can be printed:
|
||||
within bounds ∨
|
||||
∨ escape sequence ∨
|
||||
∨ last with printed ∧ not first byte in character */
|
||||
(x < 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
|
||||
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 */
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
|
@ -153,10 +137,7 @@ void write(char b, int width)
|
|||
esc = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string to an integer
|
||||
*
|
||||
/* Converts a string to an integer
|
||||
* @param string The string to convert
|
||||
* @return The integer represented by the string
|
||||
*/
|
||||
|
@ -171,4 +152,3 @@ int toInt(String string)
|
|||
|
||||
return -rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue