K3 (and hopefully K4/K5) single (per line) hexdump titty.
Spoiler:
Code:
#!/bin/sh
#=============================
# titty - tiny tty (v1.2)
# display tiny text on eink
# requirements: titty.png.
# usage:
# "titty" cat self
# "ls -al|titty -" cat STDIN
# "titty /etc/shadow" PWN! :D
# hint: This runs at TTY speed.
#------------------------------
# Copyright (C) 2012 geekmaster
# MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# WARNING: If you don't stop using titty, you will go blind! :D
#===========================
# initvar - init global vars
#---------------------------
initvar() {
eips -c; eips -f; eips -g "$0.png" # char map image
DN=/dev/null DF=/dev/fb0 # devices
set $(eips -i|grep res:); FW=$2 FH=$4 # fb0 width, height
set $(eips -i|grep line); FS=$4 # fb0 stride
CW=$((4*FS/FW)) CH=6 LH=7 # char width, height, line height
LM=2 TM=12 # left, top margin px
MX=$((FW*FS/FW-CW)) ML=$((FH/LH)); MS=$((ML+FS)) # max X, line, stride
CX=$LM CY=$TM # cursor coords
DD="dd if=$DF of=$DF bs=1 count=$CW" # ddblit
Q=false # quit flag
JFS=$IFS # normal field separator
}
#=================
# titty - tiny tty
# displays STDIN
#-----------------
titty() {
until $Q ;do IFS='\n'; read L || Q=true; IFS=$JFS
for A in $(echo -n "$L" | hexdump -ve '/1 "%d\n"'); do
if [[ $A -ne 32 ]];then
RO=$(((A-32)*CW)) FO=$((CY*FS+CX))
for y in $(seq 1 1 $CH);do
$DD skip=$RO seek=$FO 2>$DN; RO=$((RO+FS)) FO=$((FO+FS))
done
fi; CX=$((CX+CW)); [[ $((CX%64)) -eq $LM ]]&& eips ''
if [[ $CX -gt $MX ]];then CX=$LM CY=$((CY+LH))
[[ $CY -gt $MS ]]&& CY=$TM CX=$LM; fi
done; eips ''
CX=$LM CY=$((CY+LH)); [[ $CY -gt $MS ]]&& break
done
}
# Do stuff! :-)
initvar
if [[ "$1" == "-" ]];then titty
elif [[ "$1" == "" ]];then cat "$0"|titty
else cat "$1"|titty
fi