File:  [Coherent Logic Development] / freem / contrib / %ED.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jan 19 02:04:04 2025 UTC (6 months, 1 week ago) by snw
Branches: MAIN, CoherentLogicDevelopment
CVS tags: v0-63-1-rc1, v0-63-0-rc1, v0-63-0, v0-62-3, v0-62-2, v0-62-1, v0-62-0, start, HEAD
FreeM

    1: %ED	; A.Trocha; initialize Editor Global 01/29/1999 03:07/GMT+1
    2: 	; $Source: /home/cvsroot/freem/contrib/%ED.m,v $
    3: 	; $Revision: 1.1.1.1 $ $Date: 2025/01/19 02:04:04 $
    4: 	; after having run this proggy you can invoke the editor by
    5: 	; entering X ^%E
    6: 	;
    7: 	; by default VI is used as editor. If you would like another editor
    8: 	; please set the ^%SYS("EDITOR") Global accordingly
    9: 	;
   10: 	S ^%E="N a,prg,f,exec,e X ^%E(1)"
   11: 	S ^%E(1)="W !!,""EDIT PROGRAM NAME: "" R prg Q:prg=""""  X ^%E(2)"
   12: 	S ^%E(2)="S prg=$TR(prg,""^""),f=$V(4) X ^%E(3)"
   13: 	S ^%E(3)="S:$A(prg)=37 f=$V(8) X ^%E(4)"
   14: 	S ^%E(4)="S:$L(f)>0&($A(f,$L(f))'=47) f=f_$C(47) X ^%E(5)"
   15: 	S ^%E(5)="D rexist^%ED(prg) S e=^%UTILITY($J,""%ED"") X ^%E(5.5)"
   16: 	S ^%E(5.5)="X:e=0 ^%E(6) X:e=1 ^%E(12)"
   17: 	S ^%E(6)="W !,""CREATE A NEW PROGRAM? <Y>: "" X ^%E(7)"
   18: 	S ^%E(7)="R a S a=$TR(a,""y"",""Y"") S:a="""" a=""Y"" X ^%E(8)"
   19: 	S ^%E(8)="Q:a'=""Y""  X ^%E(9)"
   20: 	S ^%E(9)="ZR  X ^%E(10)"
   21: 	S ^%E(10)="ZI prg_"" ; [""_$ZD_""-""_$ZT_""]"" ZS @prg X ^%E(11)"
   22: 	S ^%E(11)="W !,prg_"" created!"",*7 H 1 X ^%E(12)"
   23: 	S ^%E(12)="S exec=""!"_$$ed^%ED()_" ""_f_prg_$V(98) X ^%E(13)"
   24: 	S ^%E(13)="x exec S tmp=$V(1) U 0:(0::::65) X ^%E(14)"
   25: 	S ^%E(14)="V 23:""zl ""_prg_"" zl ""_prg_"" V 1:tmp""_$C(13)"
   26: 	I $G(QUIET)=1 Q
   27: 	;
   28: 	W !,"Full Screen Editor installed."
   29: 	W !,"To use the editor enter:  X ^%E",!!
   30: 	Q
   31: 	;
   32: 	;
   33: rexist(rtn) ;--- check if a given routine exists
   34: 	N exec
   35: 	S $ZT="error^%ED"
   36: 	S exec="ZL "_rtn_" G cont^%ED" X exec
   37: cont	S ^%UTILITY($J,$ZN)=1 Q
   38: error	S ^%UTILITY($J,$ZN)=0 Q
   39: 	;
   40: 	;
   41: ed()	;--- which editor to use  (this is used be ^%E)
   42: 	N ed
   43: 	S ed=$G(^%SYS("EDITOR"))
   44: 	I $TR(ed," ")="" Q "vi"
   45: 	Q ed
   46: 	;
   47: chksum() ;--- chksum... not used yet... wanted to use it to determine if a
   48: 	;---- routine was changed to change to date+time in the header line
   49: 	N sum,i,line
   50: 	S i=0:1 S line=$T(+i) Q:line=""  S sum=$G(sum)+$ZCRC(line)
   51: 	Q sum
   52: 	;
   53: 	;
   54: other	;--- entry-point for %SYSGEN to change default editor
   55: 	N x,erg,QUIET
   56: 	S %ta=+$G(%ta)
   57: other0	W !,?%ta,"Editor: " R x
   58: 	I x="" W !,"Not changed!",! Q
   59: 	W !,?%ta,"Sure? <Y> "
   60: 	S erg=$$ask^%MUTIL("Y")
   61: 	I erg=0 G other0
   62: 	S ^%SYS("EDITOR")=x
   63: 	W !,?%ta,"Changed.",!
   64: 	S QUIET=1 D ^%ED
   65: 	Q
   66: 	;
   67: 	;
   68: current	;--- show the current editor
   69: 	N ed
   70: 	S %ta=+$G(%ta)
   71: 	S ed=$G(^%SYS("EDITOR"))
   72: 	W !!,?%ta,"Current Editor: "
   73: 	W $S(ed'="":ed,1:"vi")
   74: 	Q

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>