# Start the NEdit editor: # Run the script .ned in the current directory if it exists; nc otherwise ACTION ned { TYPE COMMAND # LABEL Run NEdit (server mode) WINDOW_TYPE NO_STDIO ICON nedit LABEL Run NEdit in server mode ARG_CLASS FILE ARG_COUNT >0 EXEC_STRING sh -c \ 'if [ "$#" = 1 ] && [ -d "$1" ]; then \ : a directory was sent to the action - go there ; \ cd "$1"; shift; \ d="$1"; \ elif [ "$#" = 2 ] && [ -d "$1" ] && [ -d "$2" ]; then \ : two directories - find common subdir ; \ a="$1" ; b="$2" \; d="" ; \ z=1 ; \ while [ "`echo $a | sed -e '"'s:/.*::'"'`" = \ "`echo $b | sed -e '"'s:/.*::'"'`" ] && \ [ -n "`echo $a | sed -e '"'s:[^/]::g'"'`" ]; \ do \ d="$d`echo $a | sed -e '"'s:/.*:/:'"'`"; \ a="`echo $a | sed -e '"'s:[^/]*/::'"'`"; \ b="`echo $b | sed -e '"'s:[^/]*/::'"'`"; \ : sanity check - loop no more than 30 times ; \ if [ $z = 30 ] ; then echo 30 iters ; exit; fi; \ z=`expr $z + 1` ; \ done ; \ : now buld macro string ; \ m="if(\\$file_name == \\"Untitled\\" && "; \ m="${m}\\$text_length == 0):a=1:else:{:"; \ m="${m}new():focus_window(\\"last\\")" ; \ m="${m}:}:insert_string(\\"diff -r $a $b\\")" ; \ m=`echo "$m" | tr : \\\\\\n` ; \ set - -do "'"'"'$m'"'"'" ; \ : and change to the common parent directory ; \ cd "$d"; \ elif [ -f "$1" ]; then \ : a file was given - use its directory ; \ d=`dirname "$1"`; \ fi; \ \ : find suitable .ned script; \ if [ -f .ned ] && [ -x .ned ]; then \ : in the current directory ; \ cmd="exec .ned"; \ else \ \ : starting in current directory, look for a .ned ; \ : somewhere higher in the tree ; \ [ -z "$d" ] && d="$PWD"; \ ned=; \ while [ "$d" != "/" ] && \ [ "$d" != "." ] && \ [ -n "$d" ] && [ -z "$ned" ]; do \ if [ -f "$d/.ned" ] && [ -x "$d/.ned" ]; then \ ned="$d/.ned"; \ fi; \ d=`dirname "$d"`; \ done; \ \ : if nothing found, use any .ned in HOME ; \ if [ -z "$ned" ] && \ [ -f "$HOME/.ned" ] && [ -x "$HOME/.ned" ]; then \ ned="$HOME/.ned"; \ fi; \ \ if [ -n "$ned" ]; then \ cmd="exec \"$ned\""; \ else \ : no .ned script - just use plain nc; \ cmd="nc -noask"; \ fi; \ fi; \ \ : invoke the command chosen; \ if [ x"$1" = x"$PWD/.ned" ]; then \ shift; \ $cmd "$@"; \ elif [ x"$1" = x"$PWD" ]; then \ shift; \ $cmd "$@"; \ else \ $cmd "$@"; \ fi' - %Args% DESCRIPTION Runs an unnamed NEdit server (or execute .ned in \ the current directory or one of its ancestors) } ACTION ned { TYPE COMMAND # LABEL Run NEdit (server mode) WINDOW_TYPE NO_STDIO ICON nedit LABEL Run NEdit in server mode ARG_COUNT 0 EXEC_STRING sh -c \ 'cd "$HOME"; \ \ : find suitable .ned script; \ if [ -f .ned ] && [ -x .ned ]; then \ : in the current directory ; \ cmd="exec .ned"; \ else \ \ : starting in current directory, look for a .ned ; \ : somewhere higher in the tree ; \ [ -z "$d" ] && d="$PWD"; \ ned=; \ while [ "$d" != "/" ] && \ [ "$d" != "." ] && \ [ -n "$d" ] && [ -z "$ned" ]; do \ if [ -f "$d/.ned" ] && [ -x "$d/.ned" ]; then \ ned="$d/.ned"; \ fi; \ d=`dirname "$d"`; \ done; \ \ : if nothing found, use any .ned in HOME ; \ if [ -z "$ned" ] && \ [ -f "$HOME/.ned" ] && [ -x "$HOME/.ned" ]; then \ ned="$HOME/.ned"; \ fi; \ \ if [ -n "$ned" ]; then \ cmd="exec \"$ned\""; \ else \ : no .ned script - just use plain nc; \ cmd="nc -noask"; \ fi; \ fi; \ \ : invoke the command chosen; \ $cmd;' DESCRIPTION Runs a NEdit server in the home directory } ACTION nedDir { TYPE COMMAND # LABEL Run NEdit (for directory) WINDOW_TYPE NO_STDIO ICON nedit LABEL Run NEdit for the directory implied by the argument ARG_CLASS FILE ARG_COUNT 1 EXEC_STRING sh -c \ 'if [ "$#" = 1 ] && [ -d "$1" ]; then \ : a directory was sent to the action - go there ; \ cd "$1"; shift; \ d="$1"; \ elif [ -f "$1" ]; then \ : a file was given - use its directory ; \ d=`dirname "$1"`; \ fi; \ \ : find suitable .ned script; \ if [ -f .ned ] && [ -x .ned ]; then \ : in the current directory ; \ cmd="exec .ned"; \ else \ \ : starting in current directory, look for a .ned ; \ : somewhere higher in the tree ; \ [ -z "$d" ] && d="$PWD"; \ ned=; \ while [ "$d" != "/" ] && \ [ "$d" != "." ] && \ [ -n "$d" ] && [ -z "$ned" ]; do \ if [ -f "$d/.ned" ] && [ -x "$d/.ned" ]; then \ ned="$d/.ned"; \ fi; \ d=`dirname "$d"`; \ done; \ \ : if nothing found, use any .ned in HOME ; \ if [ -z "$ned" ] && \ [ -f "$HOME/.ned" ] && [ -x "$HOME/.ned" ]; then \ ned="$HOME/.ned"; \ fi; \ \ if [ -n "$ned" ]; then \ cmd="exec \"$ned\""; \ else \ : no .ned script - just use plain nc; \ cmd="nc -noask"; \ fi; \ fi; \ \ : invoke the command chosen; \ if [ x"$1" = x"$PWD/.ned" ]; then \ shift; \ $cmd; \ elif [ x"$1" = x"$PWD" ]; then \ shift; \ $cmd; \ else \ $cmd; \ fi' - %Args% DESCRIPTION Runs an unnamed NEdit server (or execute .ned in \ the current directory or one of its ancestors) } DATA_ATTRIBUTES NEditRunFile { ICON nedit ACTIONS NEdit,Run DESCRIPTION This file is run automatically as part of the ned \ action: it is intended to start a new NEdit server \ (using a .ned script if found) or connect to an \ existing one. } DATA_CRITERIA NEditRunFile1 { DATA_ATTRIBUTES_NAME NEditRunFile PATH_PATTERN */.ned MODE !d&x } ACTION Run { LABEL Run NEdit (server mode) ARG_TYPE NEditRunFile TYPE MAP MAP_ACTION ned }