#! /bin/sh

# Add Windows registry entries to invoke MinEd from Explorer context menu

# Name of menu entry
name="MinEd (cygwin)"

# Command to invoke
root=`cygpath -w /`
# Note: mintty 0.6 or higher required for -o option
command="$root\\bin\\mintty -oLocale=C -oCharset=UTF-8 -oUseSystemColours=1 -oBoldAsBright=0 -oScrollbar=0 -oWindowShortcuts=0 -oZoomShortcuts=0 -e /bin/mined %1"

# Registry keys to use
rootkey='HKEY_CLASSES_ROOT\SystemFileAssociations\text\shell\'"$name"
userkey='HKEY_CURRENT_USER\Software\Classes\SystemFileAssociations\text\shell\'"$name"

# Make sure 'reg' is available
PATH="$PATH:`cygpath $SYSTEMROOT`/system32"

case "$1" in
-)	# Remove the keys; use the Windows tool for its simpler usage
	reg delete "$rootkey" /f
	reg delete "$userkey" /f
	;;
*)	# Enter the keys; use the Windows tool for its simpler usage
	reg add "$rootkey\\command" /f /ve /d "$command" ||
	reg add "$userkey\\command" /f /ve /d "$command"
	;;
esac

# End
