Download or view lsim.frink in plain text format
#!/home/eliasen/bin/frink
/** This program is a "graphical" ls program that lists image files as ANSI
graphics. If passed no arguments, this will list all the files in the
current directory.
*/
/* We handle the command-line switches here because fetching the number of
columns in the window using, say, tput, doesn't seem to work right within
a Java process. We instead have an external script at ~/bin/lsim that
sets the -c flag.
The bash file "lsim" that sets the number of columns looks like (adjust
paths for your system):
#!/bin/bash
cols=$(tput cols)
frink /home/eliasen/prog/frink/samples/lsim.frink -c $cols "$@"
*/
recursive = false
cols = 60
len = length[ARGS]
i=0
while i<len
{
if ARGS@i == "-c" // Number of columns
{
ARGS.remove[i]
cols = eval[ARGS@i]
ARGS.remove[i]
len = len - 2
next
}
if ARGS@i == "-r" // recursive
{
ARGS.remove[i]
recursive = true
len = len - 1
next
}
i = i + 1
}
if length[ARGS] == 0
if recursive
urls = fileURLsRecursive["."]
else
urls = fileURLs["."]
else
urls = map["filenameToURL", ARGS]
for f = select[urls, %r/\.(jpg|jpeg|bmp|png|gif|tif|tiff)$/i]
{
print[f]
img = new image[f]
[width, height] = img.getSize[]
println[" ${width}x$height"]
println[img.ANSI[cols]]
}
Download or view lsim.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 13 hours, 53 minutes ago.