#!/bin/sh
#
# SVGATextMode mode selection script
# needs "dialog", which is used for e.g. Slackware installation
#
# "Hacked together in 5 mins." by Stephen Lee (sl14@crux3.cit.cornell.edu)
#
# only works properly when the text mode strings (e.g. "80x25") are 
# enclosed in double quotes!
#
# Slightly improved by Koen Gadeyne. Couldn't resist, again...
#
# This could be improved. It should take the monitor limits into account,
# and show only those modes your monitor can handle.
#



DATABASE=/etc/TextConfig

reset

awk < $DATABASE '
$1 ~ /^\".*\"/ {
  COUNT=1;
  while (($COUNT != "font") && (COUNT < NF)) COUNT++;
  if (COUNT < NF) FONTSIZE=$(COUNT+1); else FONTSIZE="8x16"
  printf "%s %s\n", $1, FONTSIZE;
}' | sed 's/\"//g' > /tmp/.svgatm

dialog --title "SVGATextMode" --menu "Select mode:" 22 74 14 `cat /tmp/.svgatm` 2> /tmp/.svgamodeset

if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/.svgatm /tmp/.svgamodeset
  reset
  exit
fi

SVGATextMode `cat /tmp/.svgamodeset`

rm -f /tmp/.svgatm /tmp/.svgamodeset
