/*************************************************************************** * * * Macro pg_edit.the V0.1 (THE) * * * * Author: Pablo Garcia-Abia (Pablo.Garcia.Abia@cern.ch) * * Date: 27/09/1999 * * * * * * Syntax: pg_edit * * * * * * Description: * * * * Macro to be assigned to a key (mouse or keyboard). When * * issued, the string under the cursor (delimited by the * * characters of 'delim') is taken as a filename and the file, if * * exists, is edited. Otherwise, no action is taken. * * * * This macro works in any file, not only in a directory list * * (like the command 'sos edit' does). * * * * For example, I have defined: * * * * 'define 2LB IN FILEAREA cursor MOUSE#macro pg_edit' * * 'define C-X macro pg_edit' * * * * * * Bugs, comments and/or questions to Pablo.Garcia.Abia@cern.ch * ***************************************************************************/ /**** Modify this list by hand to match your needs ****/ delim = " ,;:'`[]{}()<>|!@%^&?*+=" delim = delim||'"' /* add " to the list */ /******************************************************/ 'EXTRACT /LINE/CURSOR' If cursor.3 <= 0 Then Return 'LOCATE :'cursor.3 'EXTRACT /CURLINE' 'LOCATE :'line.1 /* Make sure cursor is not on one of the delimiters */ Do d=1 To length(delim) char = substr(delim,d,1) If substr(curline.3,cursor.4,1) == char Then Return End /* Search for the beginning of the string */ Do i=cursor.4-1 To 1 By -1 ifo = 0 Do d=1 To length(delim) char = substr(delim,d,1) If substr(curline.3,i,1) == char Then Do ifo=1 Leave End End If ifo == 1 Then Leave End /* Search for the end of the string */ Do j=cursor.4+1 To length(curline.3) ifo = 0 Do d=1 To length(delim) char = substr(delim,d,1) If substr(curline.3,j,1) == char Then Do ifo=1 Leave End End If ifo == 1 Then Leave End /* Edit the file if exists */ file = substr(curline.3,i+1,j-i-1) If length(file) > 0 Then Do If state(file) > 0 Then EMSG "File '"file"' does not exist." Else 'XEDIT' file End Return