mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-07 05:26:43 +01:00
cleanup
This commit is contained in:
parent
1e0b26af59
commit
639452aa16
5 changed files with 1104 additions and 1306 deletions
23
configure
vendored
23
configure
vendored
|
@ -11,14 +11,14 @@ licenseFiles='COPYING'
|
|||
|
||||
|
||||
|
||||
oldInstalledFiles='bin/ponysaytruncater lib/ponysay/list.pl lib/ponysay/linklist.pl lib/ponysay/pq4ps lib/ponysay/pq4ps.pl lib/ponysay/pq4ps-list lib/ponysay/pq4ps-list.pl'
|
||||
oldInstalledDirs='share/ponies share/ttyponies'
|
||||
oldCompiledFiles='ponysaytruncater ponysay.install'
|
||||
oldInstalledFiles='bin/ponysaytruncater lib/ponysay/truncater lib/ponysay/list.pl lib/ponysay/linklist.pl lib/ponysay/pq4ps lib/ponysay/pq4ps.pl lib/ponysay/pq4ps-list lib/ponysay/pq4ps-list.pl bin/ponysay.py bin/ponythink.py'
|
||||
oldInstalledDirs='lib/ponysay share/ponies share/ttyponies'
|
||||
oldCompiledFiles='truncater ponysaytruncater ponysay.install'
|
||||
oldCompiledDirs=''
|
||||
|
||||
installedFiles='bin/ponysay bin/ponythink bin/ponysay.py bin/ponythink.py doc/ponysay.pdf share/info/ponysay.info.gz share/info/ponythink.info.gz'
|
||||
installedFiles='bin/ponysay bin/ponythink doc/ponysay.pdf share/info/ponysay.info.gz share/info/ponythink.info.gz'
|
||||
installedDirs='share/ponysay lib/ponysay'
|
||||
compiledFiles='truncater ponysay.info.gz ponysay.py.install'
|
||||
compiledFiles='ponysay.info.gz ponysay.py.install'
|
||||
compiledDirs='quotes'
|
||||
|
||||
for man in $manFiles; do
|
||||
|
@ -91,7 +91,7 @@ for arg in "$@"; do
|
|||
fi
|
||||
done
|
||||
|
||||
compileMethods='core truncater manpages ponysaycompletion ponythinkcompletion'
|
||||
compileMethods='core quotes manpages ponysaycompletion ponythinkcompletion'
|
||||
installMethods='install-min'"$installPdf$installInfo$installMan$installManEs$installBash$installFish$installZsh"
|
||||
if [ ! "$installInfo" = '' ]; then
|
||||
compileMethods="$compileMethods infomanual"
|
||||
|
@ -160,16 +160,11 @@ function makeMakefile()
|
|||
echo
|
||||
echo 'default: '"$compileMethods"
|
||||
echo
|
||||
echo 'all: core truncater quotes manpages infomanual ponysaycompletion ponythinkcompletion'
|
||||
echo 'all: core quotes manpages infomanual ponysaycompletion ponythinkcompletion'
|
||||
echo
|
||||
|
||||
echo "core:"
|
||||
correctPrefix 'ponysay.py'
|
||||
echo
|
||||
|
||||
echo "truncater:"
|
||||
echo -en '\t'
|
||||
echo '$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o "truncater" "truncater.c"'
|
||||
correctPrefix 'ponysay'
|
||||
echo
|
||||
|
||||
echo "quotes:"
|
||||
|
@ -210,9 +205,7 @@ function makeMakefile()
|
|||
echo
|
||||
echo -en '\t' ; echo 'mkdir -p "$(INSTALLDIR)/bin/"'
|
||||
echo -en '\t' ; echo 'install "ponysay" "$(INSTALLDIR)/bin/ponysay"'
|
||||
echo -en '\t' ; echo 'install "ponysay.py" "$(INSTALLDIR)/bin/ponysay.py"'
|
||||
echo -en '\t' ; echo 'ln -sf "ponysay" "$(INSTALLDIR)/bin/ponythink"'
|
||||
echo -en '\t' ; echo 'ln -sf "ponysay.py" "$(INSTALLDIR)/bin/ponythink.py"'
|
||||
echo
|
||||
echo -en '\t' ; echo 'mkdir -p "$(INSTALLDIR)/lib/ponysay/"'
|
||||
echo -en '\t' ; echo 'install -s "truncater" "$(INSTALLDIR)/lib/ponysay/truncater"'
|
||||
|
|
1097
ponysay.py
1097
ponysay.py
File diff suppressed because it is too large
Load diff
38
testpony
38
testpony
|
@ -1,38 +0,0 @@
|
|||
indent $balloon15$[0m
|
||||
$\$
|
||||
$\$
|
||||
$\$
|
||||
$\$
|
||||
[39;49m $\$ [48;5;233m[38;5;24m▄[39;49m[38;5;233m▄ ▄▄ ▄▄[39;49m
|
||||
[38;5;233m▀[48;5;24m [39;49m[38;5;233m▄ [38;5;61m▄ [48;5;233m [48;5;235m [48;5;233m [39;49m[38;5;61m [48;5;233m [48;5;24m [48;5;233m [39;49m
|
||||
[48;5;233m [48;5;24m [48;5;233m[38;5;232m▄[39;49m[38;5;62m▄[38;5;61m▄[48;5;16m [39;49m[38;5;61m▄[48;5;61m[38;5;16m▄[39;49m[38;5;61m▄ [38;5;233m▄ [48;5;233m [48;5;235m [48;5;233m[38;5;235m▄[39;49m[38;5;233m▄ ▄[48;5;233m[38;5;24m▄[48;5;24m [48;5;233m [39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;61m▄[48;5;232m [48;5;24m[38;5;23m▄[48;5;232m[38;5;98m▄[48;5;16m[38;5;62m▄▄▄▄[48;5;60m▄[48;5;98m[38;5;232m▄[48;5;232m[38;5;24m▄[48;5;24m [48;5;233m [39;49m[38;5;24m [38;5;233m▄[48;5;233m[38;5;235m▄[48;5;235m [38;5;233m▄[39;49m[38;5;233m▀ ▄▄▄[48;5;233m[38;5;24m▄[48;5;24m [38;5;233m▄[39;49m[38;5;233m▀ ▄▄[39;49m
|
||||
[48;5;62m [48;5;55m [38;5;62m▄[48;5;62m[38;5;25m▄[48;5;98m▄[48;5;25m [38;5;98m▄[48;5;98m[38;5;17m▄[48;5;232m[38;5;24m▄[48;5;24m [38;5;233m▄ [48;5;233m [39;49m[38;5;233m▄[48;5;233m[38;5;235m▄[48;5;235m [38;5;233m▄[48;5;233m [39;49m[38;5;233m▄[48;5;233m[38;5;235m▄ [48;5;235m[38;5;233m▄[48;5;233m[38;5;24m▄[48;5;24m [38;5;233m▄[48;5;233m [39;49m[38;5;233m▄[48;5;233m[38;5;24m▄▄[48;5;24m [48;5;233m [39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄ [48;5;25m [38;5;98m▄[48;5;98m[38;5;17m▄[48;5;62m[38;5;23m▄[38;5;17m▄[48;5;17m [48;5;24m [48;5;233m[38;5;24m▄[48;5;24m [48;5;233m [48;5;235m [38;5;233m▄[48;5;233m [38;5;24m▄▄[48;5;24m [48;5;233m▄[48;5;24m [38;5;233m▄[39;49m[38;5;233m▀[39;49m
|
||||
[38;5;62m▄▄▄[48;5;62m[38;5;55m▄[38;5;61m▄▄▄▄[48;5;55m▄[48;5;61m[38;5;55m▄[48;5;62m[38;5;25m▄[48;5;25m[38;5;98m▄[38;5;62m▄[48;5;98m[38;5;17m▄[48;5;17m[38;5;24m▄[48;5;24m[38;5;17m▄[48;5;17m[38;5;69m▄[48;5;68m[38;5;16m▄[48;5;69m▄[48;5;16m [48;5;24m▄[48;5;16m[38;5;24m▄[48;5;24m[38;5;23m▄[48;5;232m[38;5;62m▄[48;5;98m▄[48;5;234m [48;5;235m [48;5;233m [38;5;24m▄[48;5;24m [38;5;233m▄▄▄ ▄▄[39;49m[38;5;233m▀▀[39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m [38;5;55m▄[38;5;25m▄▄▄▄[48;5;55m▄[48;5;25m [48;5;62m▄[48;5;98m[38;5;232m▄[48;5;17m[38;5;24m▄[48;5;69m[38;5;16m▄[48;5;16m[38;5;231m▄[38;5;24m▄[48;5;231m [48;5;16m ▄[48;5;23m[38;5;62m▄[48;5;98m[38;5;25m▄[48;5;25m [48;5;98m[38;5;62m▄[48;5;235m [48;5;233m [48;5;24m [38;5;233m▄[48;5;232m[38;5;24m▄[48;5;24m [48;5;232m▄[48;5;24m [48;5;233m▄▄▄[39;49m[38;5;233m▄[39;49m
|
||||
[48;5;62m [48;5;55m[38;5;61m▄[48;5;61m [38;5;25m▄[48;5;25m[38;5;195m▄ [48;5;233m [48;5;24m [48;5;16m [48;5;24m [48;5;231m[38;5;17m▄[48;5;17m[38;5;24m▄[48;5;24m [48;5;23m [48;5;62m[38;5;98m▄[48;5;25m [48;5;62m [48;5;235m [48;5;233m [48;5;24m [48;5;233m [48;5;24m [48;5;233m[38;5;24m▄▄[48;5;24m[38;5;232m▄ [48;5;232m[38;5;24m▄[48;5;24m[38;5;233m▄▄▄▄▄[39;49m[38;5;233m▀[39;49m
|
||||
[38;5;62m▀[48;5;55m▄[48;5;61m[38;5;55m▄ [48;5;25m▄ [38;5;195m▄ [38;5;232m▄[48;5;232m[38;5;24m▄[48;5;24m [38;5;232m▄[48;5;232m[38;5;24m▄[48;5;98m[38;5;62m▄[48;5;25m▄[48;5;98m[38;5;234m▄[48;5;235m [48;5;233m [48;5;24m [48;5;233m [48;5;24m [48;5;232m[38;5;24m▄[48;5;24m[38;5;232m▄ ▄ [48;5;233m[38;5;24m▄[39;49m[38;5;233m▄[39;49m
|
||||
[38;5;62m▀[48;5;55m▄[48;5;61m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;25m[38;5;55m▄ [48;5;195m[38;5;25m▄[48;5;19m▄[48;5;195m▄[48;5;232m▄[48;5;24m[38;5;232m▄[38;5;233m▄[48;5;232m[38;5;24m▄[48;5;24m [38;5;233m▄▄[48;5;233m [38;5;24m▄▄[48;5;24m [48;5;23m▄[48;5;62m[38;5;232m▄[38;5;98m▄[48;5;234m [48;5;235m [48;5;233m [48;5;24m [48;5;233m [48;5;24m [48;5;232m[38;5;24m▄[48;5;24m [48;5;233m [39;49m[38;5;233m▀▀[48;5;24m▄▄▄[39;49m[38;5;233m▀[39;49m
|
||||
[48;5;62m [48;5;61m [48;5;25m [48;5;232m[38;5;25m▄▄[48;5;25m [38;5;232m▄[48;5;233m[38;5;24m▄[48;5;24m [38;5;233m▄[48;5;233m[38;5;235m▄[48;5;235m [48;5;233m▄ [48;5;24m [48;5;233m [48;5;24m [48;5;232m[38;5;24m▄[48;5;24m[38;5;233m▄▄ [48;5;233m[38;5;232m▄[39;49m[38;5;62m▄[39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;61m ▄[48;5;25m[38;5;195m▄ ▄ [38;5;232m▄[48;5;233m[38;5;24m▄[48;5;24m [38;5;17m▄▄▄[48;5;233m[38;5;61m▄[48;5;235m▄[38;5;234m▄[38;5;233m▄▄▄[48;5;233m[38;5;24m▄[48;5;24m [38;5;233m▄▄ [48;5;233m[38;5;232m▄[39;49m[38;5;62m▄[48;5;233m▄[48;5;232m[38;5;61m▄[48;5;62m▄[48;5;55m▄[48;5;62m [39;49m
|
||||
[38;5;62m▄▄[48;5;62m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m[38;5;55m▄[48;5;55m[38;5;25m▄[48;5;25m [38;5;232m▄[48;5;233m[38;5;24m▄[48;5;24m[38;5;61m▄[48;5;17m▄[48;5;61m[38;5;16m▄▄▄[48;5;16m[38;5;61m▄▄[48;5;61m[38;5;17m▄[48;5;233m[38;5;24m▄▄[48;5;24m [38;5;233m▄[48;5;233m[38;5;16m▄[39;49m[38;5;233m▄[48;5;233m[38;5;98m▄[48;5;232m[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;55m[38;5;25m▄▄[48;5;61m▄▄[38;5;55m▄[48;5;62m▄[39;49m[38;5;62m▄[39;49m
|
||||
[48;5;62m [38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m [38;5;55m▄[48;5;55m[38;5;25m▄[48;5;25m [38;5;55m▄[48;5;91m[38;5;61m▄[48;5;61m[38;5;16m▄▄[48;5;16m [38;5;61m▄[48;5;61m[38;5;17m▄[48;5;17m[38;5;24m▄▄[48;5;24m [38;5;233m▄▄[48;5;233m[38;5;16m▄[48;5;16m [48;5;231m▄[48;5;16m[38;5;231m▄[48;5;233m[38;5;232m▄[48;5;25m[38;5;98m▄[38;5;62m▄▄▄ [48;5;55m[38;5;25m▄ [48;5;62m[38;5;55m▄[38;5;61m▄▄▄▄▄[38;5;55m▄[39;49m[38;5;62m▄▄▄▄▄[39;49m
|
||||
[38;5;62m▀[48;5;55m▄[48;5;61m [48;5;25m [38;5;195m▄ [48;5;55m[38;5;61m▄ [48;5;60m [48;5;231m [48;5;16m[38;5;231m▄[48;5;231m[38;5;16m▄[48;5;16m [48;5;61m [48;5;17m [48;5;24m ▄ [48;5;16m [48;5;231m▄▄[48;5;16m [48;5;233m[38;5;234m▄[39;49m[38;5;234m [38;5;62m▀[48;5;25m▄ [48;5;55m[38;5;25m▄[48;5;61m▄▄▄▄[38;5;55m▄ [48;5;55m[38;5;61m▄[48;5;62m [39;49m
|
||||
[38;5;62m▀[48;5;55m▄[48;5;61m[38;5;55m▄ [48;5;25m▄ [38;5;195m▄ [38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m [48;5;55m[38;5;62m▄[39;49m[38;5;61m▀[48;5;16m▄▄[48;5;61m[38;5;18m▄[38;5;24m▄[48;5;17m▄[48;5;24m [38;5;233m▄ [48;5;16m[38;5;24m▄▄[48;5;24m[38;5;233m▄[39;49m[38;5;233m▀ [48;5;62m [48;5;55m[38;5;61m▄▄[48;5;25m [48;5;195m[38;5;25m▄[48;5;25m [48;5;55m▄[48;5;61m [48;5;55m[38;5;61m▄[48;5;62m [39;49m
|
||||
[48;5;62m [48;5;61m [48;5;25m [38;5;55m▄[38;5;61m▄[48;5;55m▄[48;5;61m[38;5;55m▄[38;5;62m▄[48;5;55m▄[39;49m[38;5;62m▀ [48;5;233m [38;5;235m▄▄ [48;5;24m [38;5;233m▄▄▄▄[39;49m[38;5;233m▀[48;5;233m [38;5;235m▄▄[48;5;24m[38;5;233m▄ [48;5;233m [39;49m[38;5;233m [38;5;62m▄[48;5;62m[38;5;55m▄[48;5;61m ▄[48;5;25m [38;5;195m▄ [38;5;55m▄[48;5;61m ▄[48;5;62m [39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m [48;5;25m▄▄[48;5;55m▄[48;5;61m [38;5;55m▄[38;5;62m▄[48;5;55m▄[48;5;62m [39;49m[38;5;62m [48;5;233m [48;5;24m [48;5;233m [39;49m[38;5;62m [48;5;233m [48;5;235m [48;5;233m[38;5;235m▄[48;5;24m[38;5;233m▄ [48;5;233m [39;49m[38;5;233m [48;5;62m [48;5;61m [48;5;25m [38;5;195m▄ [48;5;61m [48;5;62m [39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;61m ▄[38;5;62m▄▄▄[48;5;55m▄[39;49m[38;5;62m▀▀▀▀▀ [48;5;233m [48;5;24m [48;5;233m [39;49m[38;5;62m [48;5;233m [48;5;235m [48;5;233m[38;5;235m▄[48;5;24m[38;5;233m▄ [48;5;233m [39;49m[38;5;233m▄ [48;5;62m [48;5;61m[38;5;55m▄ [48;5;55m[38;5;61m▄[48;5;25m[38;5;55m▄ [48;5;19m[38;5;195m▄[48;5;25m [48;5;61m [48;5;62m [39;49m
|
||||
[48;5;62m [48;5;55m[38;5;61m▄[48;5;61m [38;5;55m▄[48;5;55m[38;5;62m▄[39;49m[38;5;62m▀ [48;5;233m [48;5;24m [48;5;233m [39;49m[38;5;62m [48;5;233m [48;5;235m [48;5;233m [39;49m[38;5;233m▀[48;5;24m▄ [48;5;233m [39;49m[38;5;233m [38;5;62m▀▀▀▀▀▀▀[48;5;55m▄[48;5;61m [48;5;25m [48;5;61m [48;5;62m [39;49m
|
||||
[48;5;62m [48;5;61m[38;5;55m▄ [48;5;62m [39;49m[38;5;55m [48;5;233m [48;5;24m [48;5;233m [39;49m[38;5;55m [48;5;233m [48;5;235m [48;5;233m [39;49m[38;5;55m [38;5;233m▀[48;5;24m▄ [48;5;233m [39;49m[38;5;233m [38;5;62m▄[48;5;62m[38;5;55m▄[48;5;61m▄[48;5;55m[38;5;195m▄[48;5;25m [48;5;55m[38;5;25m▄[48;5;61m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;62m[38;5;55m▄[39;49m[38;5;62m▄[39;49m
|
||||
[38;5;62m▀[48;5;55m▄[48;5;62m [39;49m[38;5;62m▄ [48;5;233m [48;5;24m [48;5;233m [38;5;235m▄[39;49m[38;5;233m▄ [48;5;233m [48;5;235m [48;5;233m [39;49m[38;5;233m ▀[48;5;24m▄ [48;5;233m [39;49m[38;5;233m [38;5;62m▄▄[48;5;62m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m [38;5;25m▄[48;5;25m [48;5;55m▄[48;5;61m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;62m[38;5;55m▄[39;49m[38;5;62m▄[39;49m
|
||||
[48;5;233m [48;5;24m [48;5;233m [38;5;235m▄[39;49m[38;5;233m▄ [48;5;233m [48;5;235m [48;5;233m [39;49m[38;5;233m ▀[48;5;24m▄ [48;5;233m[38;5;24m▄[39;49m[38;5;233m▄ [48;5;62m [48;5;55m [48;5;61m [48;5;25m[38;5;55m▄ [48;5;195m[38;5;25m▄[48;5;25m [48;5;55m▄[48;5;61m [48;5;55m[38;5;61m▄[48;5;62m[38;5;55m▄ [39;49m
|
||||
[48;5;233m[38;5;61m▄[48;5;24m[38;5;17m▄ [48;5;233m [48;5;234m[38;5;104m▄[48;5;233m[38;5;61m▄[39;49m[38;5;61m [48;5;61m[38;5;60m▄[48;5;234m[38;5;61m▄[48;5;235m[38;5;234m▄ [48;5;233m [39;49m[38;5;234m [38;5;233m▀[48;5;24m[38;5;61m▄[38;5;17m▄ [48;5;233m[38;5;24m▄[39;49m[38;5;233m▄ [38;5;62m▀▀▀[48;5;55m▄[48;5;61m [48;5;55m[38;5;61m▄[48;5;25m [38;5;195m▄ ▄ [48;5;61m [48;5;62m [39;49m
|
||||
[38;5;61m▄[48;5;61m[38;5;146m▄▄[48;5;17m▄[48;5;24m[38;5;17m▄[48;5;233m[38;5;232m▄[48;5;104m[38;5;60m▄[39;49m[38;5;60m▀ ▄[48;5;60m[38;5;104m▄[48;5;104m [48;5;234m▄[48;5;233m[38;5;60m▄[39;49m[38;5;60m [48;5;61m [38;5;146m▄[48;5;17m▄[38;5;147m▄[48;5;233m[38;5;232m▄[39;49m[38;5;232m [38;5;62m▀[48;5;55m▄[48;5;61m[38;5;55m▄ [48;5;25m▄ ▄[48;5;55m[38;5;61m▄[48;5;61m[38;5;55m▄[38;5;62m▄[48;5;55m▄[39;49m[38;5;62m▀[39;49m
|
||||
[48;5;61m [48;5;146m[38;5;61m▄▄[48;5;110m▄[48;5;146m▄[39;49m[38;5;61m▀ [38;5;60m▀▀▀▀▀ [48;5;61m [48;5;146m[38;5;61m▄[48;5;110m▄[48;5;146m▄▄[39;49m[38;5;61m▀ [48;5;62m [48;5;61m[38;5;55m▄ [48;5;25m▄ [38;5;61m▄[48;5;55m▄[48;5;61m[38;5;55m▄[48;5;55m[38;5;62m▄[39;49m[38;5;62m▀[39;49m
|
||||
[48;5;62m [48;5;61m [48;5;25m [48;5;195m[38;5;55m▄[48;5;55m[38;5;61m▄[48;5;61m[38;5;55m▄[48;5;62m [39;49m
|
||||
[48;5;62m [48;5;61m [48;5;25m [48;5;61m [48;5;62m [39;49m
|
||||
[38;5;62m▄[48;5;62m[38;5;55m▄[48;5;61m [48;5;55m[38;5;62m▄[39;49m[38;5;62m▀[39;49m
|
||||
[38;5;62m▄▄[48;5;62m[38;5;55m▄▄[48;5;55m[38;5;61m▄[48;5;61m [38;5;55m▄[38;5;62m▄[48;5;55m▄[39;49m[38;5;62m▀[39;49m
|
||||
[38;5;62m▀▀▀▀▀▀▀▀▀▀[39;49m
|
||||
[0m
|
153
truncater.c
153
truncater.c
|
@ -1,153 +0,0 @@
|
|||
/* ponysaytruncater
|
||||
* Output truncater used by ponysay to stop
|
||||
* large ponies from being printed badly.
|
||||
*
|
||||
* 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 */
|
||||
#define STDIN 0
|
||||
|
||||
/* The number of columns on the current line */
|
||||
static int col = 0;
|
||||
|
||||
/* Escape sequence state */
|
||||
static int esc = 0;
|
||||
|
||||
/* Last bytes as written */
|
||||
static boolean ok = true;
|
||||
|
||||
void write(char b, int width);
|
||||
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 an argument.
|
||||
*
|
||||
* @param argc The number of startup arguments
|
||||
* @param argv The startup arguments, the first is the file itself
|
||||
*
|
||||
* @author Mattias Andrée, maandree@kth.se
|
||||
*/
|
||||
void main(int argc, String* argv)
|
||||
{
|
||||
int width = 0;
|
||||
if (argc > 1)
|
||||
width = toInt(*(argv + 1));
|
||||
|
||||
char b = 0;
|
||||
|
||||
if (width > 15) /* sanity */
|
||||
while (read(STDIN, &b, 1))
|
||||
write(b, width);
|
||||
else
|
||||
while (read(STDIN, &b, 1))
|
||||
printf("%c", b);
|
||||
}
|
||||
|
||||
/* 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
|
||||
*/
|
||||
void write(char b, int width)
|
||||
{
|
||||
int i;
|
||||
char tabstop;
|
||||
|
||||
if (esc == 0)
|
||||
{
|
||||
if (b == '\n')
|
||||
{
|
||||
if (col >= width)
|
||||
{
|
||||
/* Reset background colour */
|
||||
write('\e', width);
|
||||
write('[', width);
|
||||
write('4', width);
|
||||
write('9', width);
|
||||
write('m', width);
|
||||
}
|
||||
col = -1;
|
||||
}
|
||||
else if (b == '\t')
|
||||
{
|
||||
/* Tab to next pos ≡₈ 0 */
|
||||
tabstop = 8 - (col & 7);
|
||||
for (i = 0; i < tabstop; i++)
|
||||
write(' ', width);
|
||||
return; /* (!) */
|
||||
}
|
||||
else if (b == '\e')
|
||||
esc = 1;
|
||||
}
|
||||
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 palette editing in Linux VT */
|
||||
else esc = 10; /* Nothing to see here, move along */
|
||||
}
|
||||
else if (esc == 2)
|
||||
{
|
||||
if ((('a' <= b) && (b <= 'z')) || (('A' <= b) && (b <= 'Z')))
|
||||
esc = 10;
|
||||
}
|
||||
else if ((esc == 3) && (b == 'P'))
|
||||
{
|
||||
esc = ~0;
|
||||
}
|
||||
else if (esc < 0)
|
||||
{
|
||||
esc--;
|
||||
if (esc == ~7)
|
||||
esc = 10;
|
||||
}
|
||||
else
|
||||
esc = 10;
|
||||
|
||||
if (
|
||||
/* Can be printed:
|
||||
within bounds ∨
|
||||
∨ escape sequence ∨
|
||||
∨ last with printed ∧ not first byte in character */
|
||||
(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 */
|
||||
col++; /* the byte is not the first byte in the character */
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
ok = false;
|
||||
|
||||
if (esc == 10)
|
||||
esc = 0;
|
||||
}
|
||||
|
||||
/* Converts a string to an integer
|
||||
*
|
||||
* @param string The string to convert
|
||||
* @return The integer represented by the string
|
||||
*/
|
||||
int toInt(String string)
|
||||
{
|
||||
int rc = 0;
|
||||
String str = string;
|
||||
char c = 0;
|
||||
|
||||
while ((c = *str++) != 0)
|
||||
rc = (rc << 1) + (rc << 3) - (c & 15);
|
||||
|
||||
return -rc;
|
||||
}
|
Loading…
Reference in a new issue