#! /bin/sh
tmp=/tmp/lq.$$
trap "rm -rf $tmp" 0 1 2 3 15

mkdir $tmp
COLS=90; export COLS
lqkwik -p2 -w$COLS -g1 -l32 -r30 ${@+"$@"} > $tmp/Index

Lines=`wc -l $tmp/Index |
    awk '
	{
	    i =$1
	    if (i < 5) i = 5
	    if (i < 45) printf "-size 850 %d", i * 17 # 16pt text...
	}'
    `

{

    echo -n '{\rtf1\ansi\deff0{\fonttbl{\f0\froman LucidaSans-Typewriter;}}{\colortbl\red243\green86\blue86;
\red255\green255\blue255;\red0\green0\blue0;\red175\green175\blue175;
}{\fs30{\cf0{\b List of phrases in context:\par
}}'

    sed -e 's/^\(.*: *\)\([^:][^:]*\)$/\1{\\cf3 \2}\\par/' \
	-e 's/<[^>]*>/{\\cf3 &}/g' \
	-e 's/^[^<]*>/{\\cf3 &}/' \
	-e '/<[^>]*$/s/\(<[^>]*\): {/{\\cf3 \1}: {/' \
	$tmp/Index

    echo '}{\cf0{\fs30{\b End\par
}}}}'

} > $tmp/Index1


$OPENWINHOME/demo/jed -scale extra_large -label Index $Lines $tmp/Index1 # 2>/dev/null
/bin/rm -rf $tmp core

# lqkwik:
# -g n    -- set gap between text and matched phrase to n [2]
# -l n    -- display n characters to the left of each phrase [23]
# -r n    -- display r chars to the right of each phrase's start [23]
# -w n    -- truncate the line after n characters [default: 65]
