#/bin/sh

VIM=$1
echo "Testing " $1 " to see if it is useable with the kpart"

ok="ok"

echo "Testing -gf option"
msg="Unable to use Vim with -gf option. Enable gui support when compiling vim"
$VIM -gf -c ':q!'  2>/dev/null || result="bad"
if [ "X$result" == "Xbad" ]; then echo $msg; ok="bad";  fi



echo "Testing --servername option"
msg="Unable to use Vim with --servername option. Enable this option when compiling vim"
$VIM -gf --servername HOP0 -c ':q!'  2>/dev/null || result="bad"
if [ "X$result" == "Xbad" ]; then echo $msg;  ok="bad"; fi

echo "Testing --remote-send option"
msg="Unable to use Vim with --remote-send option. Enable client/server option when compiling vim"
$VIM -g --servername HOP 2>/dev/null &
sleep 2
$VIM -gf --servername HOP --remote-send ':q!
' 2>/dev/null  || result="bad"
if [ "X$result" == "Xbad" ]; then echo $msg; ok="bad"; fi

echo "Testing --echo-wid option"
msg="Unable to use Vim with --echo-wid option. You need to patch your vim with the kpart patch, available from phil.freehackers.org/kvim."
$VIM -gf --echo-wid -c ':q!'  2>/dev/null || result="bad"
if [ "X$result" == "Xbad" ]; then echo $msg;  ok="bad"; fi


if [ $ok == "bad" ];
then
	rm -f goodVim
	exit 1
fi

echo "You can use your vim with the vim KPart!"
echo "Run make to update the vim executable setting"
echo $VIM > goodVim
