XGS ;SFISC/VYD - SCREEN PRIMITIVES ;03/16/95 11:00
;;8.0;KERNEL;;Jul 10, 1995
SAY(R,C,S,A) ;use this for coordinate output instead of WRITE
;output to screen and update virtual screen (XGSCRN)
;params: Row (0-IOSL),Col (0-IOM),string,
;scrn attrib ie. I1R0B1 (optional)
N XGSAVATR,XGESC,XGOUTPUT ;save attribute,escape str,output stream
N %
;set output stream to either XGSCRN (virtual screen) or some window
S XGOUTPUT=$S($G(XGFLAG("PAINT"),21)=21:"XGSCRN",1:$NA(^TMP("XGS",$J,XGW1)))
S XGSAVATR=XGCURATR ;preserve current attribute to restore later
S $X=C+$L(S)
S XGESC=$S($L($G(A)):$$CHG^XGSA(A),1:"")
S $E(@XGOUTPUT@(R,0),(C+1),$X)=S
S $E(@XGOUTPUT@(R,1),(C+1),$X)=$TR($J("",$L(S))," ",XGCURATR)
;S $P(%,XGCURATR,$L(S)+1)="",$E(@XGOUTPUT@(R,1),(C+1),$X)=%
I XGOUTPUT="XGSCRN" D I 1 ;if screen painting is to occur
. ;output string in a proper place in proper attribute and restore attr
. ;W $$IOXY(R,C)_XGESC_S_$S($L($G(A)):$$SET^XGSA(XGSAVATR),1:"")
. W $$IOXY(R,C)_XGESC_S_$S(XGSAVATR'=XGCURATR:$$SET^XGSA(XGSAVATR),1:"")
. S $Y=R,$X=C+$L(S)-1
E S XGCURATR=XGSAVATR
Q
;
;
SAYU(R,C,S,A) ;use this for coordinate output instead of WRITE
;output to screen and update virtual screen (XGSCRN)
;params: Row (0-IOSL),Col (0-IOM),string,
;scrn attrib ie. I1R0B1 (optional)
N XGSAVATR,XGESC,XGOUTPUT ;save attribute,escape str,output stream
N %,%S,P,P1,P2,X ;P1:piece before &, P2:piece from & to the end
N XGATR
;set output stream to either XGSCRN (virtual screen) or some window
S XGOUTPUT=$S($G(XGFLAG("PAINT"),21)=21:"XGSCRN",1:$NA(^TMP("XGS",$J,XGW1)))
S P=$L(S,"&&")
F %=1:1:P S $P(X,$C(1),%)=$P(S,"&&",%) ;replace all && with $C(1)
I X["&",$G(A)'["U1",'$$STAT^XGSA("U")!($G(A)["U0") D I 1
. S XGSAVATR=XGCURATR ;preserve current attribute to restore later
. S XGESC=$S($L($G(A)):$$CHG^XGSA(A),1:"")
. S XGATR=XGCURATR ;get pre-underline attributes
. S $X=C+$L(X)-1 ;adjust for a single &, which is not printable
. ;S $E(XGSCRN(R,0),(C+1),$X)=$TR($TR(X,"&",""),$C(1),"&")
. S $E(@XGOUTPUT@(R,0),(C+1),$X)=$TR($P(X,"&")_$P(X,"&",2,999),$C(1),"&")
. S $E(@XGOUTPUT@(R,1),(C+1),$X)=$TR($J("",$X-C)," ",XGCURATR)
. S P1=$TR($P(X,"&"),$C(1),"&"),P2=$TR($P(X,"&",2,999),$C(1),"&")
. S %S=P1_$$CHG^XGSA("U1")_$E(P2) ;preunderline_underlinechar
. S $E(@XGOUTPUT@(R,1),(C+1+$L(P1)))=XGCURATR ;record underlinechar
. ;S %S=%S_$$CHG^XGSA("U0")_$E(P2,2,999) ;%S_postunderline
. S %S=%S_$$SET^XGSA(XGATR)_$E(P2,2,999) ;%S_postunderline
. I XGOUTPUT="XGSCRN" D I 1
. . ;output string in a proper place in proper attribute and restore attr
. . ;W $$IOXY(R,C)_XGESC_%S_$S($L($G(A)):$$SET^XGSA(XGSAVATR),1:"")
. . W $$IOXY(R,C)_XGESC_%S_$S(XGCURATR'=XGSAVATR:$$SET^XGSA(XGSAVATR),1:"")
. . S $Y=R,$X=C+$L(X)-2
. E S XGCURATR=XGSAVATR
E D SAY(R,C,$TR(S,"&"),A):$D(A),SAY(R,C,$TR(S,"&")):'$D(A)
Q
;
;
IOXY(R,C) ;cursor positioning WRITE argument instead of execute
;Row,Col
Q $C(27,91)_((R+1))_$C(59)_((C+1))_$C(72)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXGS 3042 printed Dec 13, 2024@02:02:22 Page 2
XGS ;SFISC/VYD - SCREEN PRIMITIVES ;03/16/95 11:00
+1 ;;8.0;KERNEL;;Jul 10, 1995
SAY(R,C,S,A) ;use this for coordinate output instead of WRITE
+1 ;output to screen and update virtual screen (XGSCRN)
+2 ;params: Row (0-IOSL),Col (0-IOM),string,
+3 ;scrn attrib ie. I1R0B1 (optional)
+4 ;save attribute,escape str,output stream
NEW XGSAVATR,XGESC,XGOUTPUT
+5 NEW %
+6 ;set output stream to either XGSCRN (virtual screen) or some window
+7 SET XGOUTPUT=$SELECT($GET(XGFLAG("PAINT"),21)=21:"XGSCRN",1:$NAME(^TMP("XGS",$JOB,XGW1)))
+8 ;preserve current attribute to restore later
SET XGSAVATR=XGCURATR
+9 SET $X=C+$LENGTH(S)
+10 SET XGESC=$SELECT($LENGTH($GET(A)):$$CHG^XGSA(A),1:"")
+11 SET $EXTRACT(@XGOUTPUT@(R,0),(C+1),$X)=S
+12 SET $EXTRACT(@XGOUTPUT@(R,1),(C+1),$X)=$TRANSLATE($JUSTIFY("",$LENGTH(S))," ",XGCURATR)
+13 ;S $P(%,XGCURATR,$L(S)+1)="",$E(@XGOUTPUT@(R,1),(C+1),$X)=%
+14 ;if screen painting is to occur
IF XGOUTPUT="XGSCRN"
Begin DoDot:1
+15 ;output string in a proper place in proper attribute and restore attr
+16 ;W $$IOXY(R,C)_XGESC_S_$S($L($G(A)):$$SET^XGSA(XGSAVATR),1:"")
+17 WRITE $$IOXY(R,C)_XGESC_S_$SELECT(XGSAVATR'=XGCURATR:$$SET^XGSA(XGSAVATR),1:"")
+18 SET $Y=R
SET $X=C+$LENGTH(S)-1
End DoDot:1
IF 1
+19 IF '$TEST
SET XGCURATR=XGSAVATR
+20 QUIT
+21 ;
+22 ;
SAYU(R,C,S,A) ;use this for coordinate output instead of WRITE
+1 ;output to screen and update virtual screen (XGSCRN)
+2 ;params: Row (0-IOSL),Col (0-IOM),string,
+3 ;scrn attrib ie. I1R0B1 (optional)
+4 ;save attribute,escape str,output stream
NEW XGSAVATR,XGESC,XGOUTPUT
+5 ;P1:piece before &, P2:piece from & to the end
NEW %,%S,P,P1,P2,X
+6 NEW XGATR
+7 ;set output stream to either XGSCRN (virtual screen) or some window
+8 SET XGOUTPUT=$SELECT($GET(XGFLAG("PAINT"),21)=21:"XGSCRN",1:$NAME(^TMP("XGS",$JOB,XGW1)))
+9 SET P=$LENGTH(S,"&&")
+10 ;replace all && with $C(1)
FOR %=1:1:P
SET $PIECE(X,$CHAR(1),%)=$PIECE(S,"&&",%)
+11 IF X["&"
IF $GET(A)'["U1"
IF '$$STAT^XGSA("U")!($GET(A)["U0")
Begin DoDot:1
+12 ;preserve current attribute to restore later
SET XGSAVATR=XGCURATR
+13 SET XGESC=$SELECT($LENGTH($GET(A)):$$CHG^XGSA(A),1:"")
+14 ;get pre-underline attributes
SET XGATR=XGCURATR
+15 ;adjust for a single &, which is not printable
SET $X=C+$LENGTH(X)-1
+16 ;S $E(XGSCRN(R,0),(C+1),$X)=$TR($TR(X,"&",""),$C(1),"&")
+17 SET $EXTRACT(@XGOUTPUT@(R,0),(C+1),$X)=$TRANSLATE($PIECE(X,"&")_$PIECE(X,"&",2,999),$CHAR(1),"&")
+18 SET $EXTRACT(@XGOUTPUT@(R,1),(C+1),$X)=$TRANSLATE($JUSTIFY("",$X-C)," ",XGCURATR)
+19 SET P1=$TRANSLATE($PIECE(X,"&"),$CHAR(1),"&")
SET P2=$TRANSLATE($PIECE(X,"&",2,999),$CHAR(1),"&")
+20 ;preunderline_underlinechar
SET %S=P1_$$CHG^XGSA("U1")_$EXTRACT(P2)
+21 ;record underlinechar
SET $EXTRACT(@XGOUTPUT@(R,1),(C+1+$LENGTH(P1)))=XGCURATR
+22 ;S %S=%S_$$CHG^XGSA("U0")_$E(P2,2,999) ;%S_postunderline
+23 ;%S_postunderline
SET %S=%S_$$SET^XGSA(XGATR)_$EXTRACT(P2,2,999)
+24 IF XGOUTPUT="XGSCRN"
Begin DoDot:2
+25 ;output string in a proper place in proper attribute and restore attr
+26 ;W $$IOXY(R,C)_XGESC_%S_$S($L($G(A)):$$SET^XGSA(XGSAVATR),1:"")
+27 WRITE $$IOXY(R,C)_XGESC_%S_$SELECT(XGCURATR'=XGSAVATR:$$SET^XGSA(XGSAVATR),1:"")
+28 SET $Y=R
SET $X=C+$LENGTH(X)-2
End DoDot:2
IF 1
+29 IF '$TEST
SET XGCURATR=XGSAVATR
End DoDot:1
IF 1
+30 IF '$TEST
if $DATA(A)
DO SAY(R,C,$TRANSLATE(S,"&"),A)
if '$DATA(A)
DO SAY(R,C,$TRANSLATE(S,"&"))
+31 QUIT
+32 ;
+33 ;
IOXY(R,C) ;cursor positioning WRITE argument instead of execute
+1 ;Row,Col
+2 QUIT $CHAR(27,91)_((R+1))_$CHAR(59)_((C+1))_$CHAR(72)