VALM4 ;ALB/MJK - Screen Malipulation Utilities ;02/12/2001 13:45
;;1.0;List Manager;**4,6**;Aug 13, 1993
NEXT ; -- display next screen (NX)
D START
N VALMLSTO,I,LN
I VALMBG+VALM("LINES")>VALMCNT W $C(7) D FINISH Q
S VALMBG=VALMBG+VALM("LINES")
S VALMLSTO=VALMLST
I VALMCC D LST,SCROLL D
. S DY=VALM("BM")-1 D IOXY(0,.DY)
. S I=VALMLSTO+1 F LN=1:1:VALM("LINES") D WRITE(I,1,1,.DY) S I=I+1
. D PLUS,RESET
D PGUPD
D FINISH
Q
PREV ; -- display previous screen (BU)
D START
N I,LN,X,Y,VALMBGO
I VALMBG=1 W $C(7) D FINISH Q
S Y=VALMBG-VALM("LINES")
S VALMBGO=VALMBG,VALMBG=$S(Y<1:1,1:Y)
I VALMCC D LST,SCROLL D
. S DY=VALM("TM")-1
. S I=VALMBGO-1 F LN=1:1:VALM("LINES") D IOIL(0,.DY),WRITE(I,0,1,.DY) Q:I=1 S I=I-1
. D PLUS,RESET
D PGUPD
D FINISH
Q
FIRST ; -- display first screen (FS)
D START
I VALMBG=1 W $C(7) D FINISH Q
S VALMBG=1
I VALMCC D LST,PAINT
D PGUPD
D FINISH
Q
LAST ; -- display last screen (LS)
D START
N Y,I
I VALMCNT'>VALM("LINES") W $C(7) D FINISH Q
; first line of the last screen :=
; (# of full screens less 1 if last screen is also full) x # lines per screen) + 1 line
S Y=(((VALMCNT\VALM("LINES"))-'(VALMCNT#VALM("LINES")))*VALM("LINES"))+1
I Y=VALMBG W $C(7) D FINISH Q
S VALMBG=Y
I VALMCC D LST,PAINT
D PGUPD
D FINISH
Q
START ; -- start action tasks
S:VALMMENU VALMDY=""
W VALMCOFF
Q
FINISH ; -- finish action tasks
S VALMBCK=$S(VALMCC:"",1:"R")
W VALMCON
Q
PAINT ;
N I,LN,X D SCROLL
I $E(IOST,1,4)="C-VT" S DY=VALM("TM")-1 D IOXY(0,.DY) W *27,*91,VALM("LINES"),*77
S I=VALMBG F LN=1:1:VALM("LINES") S DY=VALM("TM")+LN-2 D IOIL(0,.DY),WRITE(I,0,1,.DY) S I=I+1
D PLUS,RESET
Q
IOIL(DX,DY) ; -- position cursor ; insert line ; cr
W ! X IOXY W IOIL,$C(13)
Q
IOXY(DX,DY) ; -- position cursor and tell os
X IOXY ;,VALMIOXY
Q
RE ; -- re-display current screen (RE)
D REFRESH^VALM S VALMBCK=""
Q
RESET ; -- reset scrolling region to bottom of screen
I '$D(VALMDY) D IOXY(0,VALM("BM")+1) W IOEDEOP
S IOTM=VALM("BM")+2,IOBM=IOSL W IOSC W @IOSTBM W IORC
D UND($$HTE^XLFDT($H,1),31+((VALMWD-80)/2),1,21,.IOUON,.IOUOFF,0)
I $D(VALMBCK) D IOXY(0,VALM("BM"))
Q
SCROLL ; -- set scrolling region to list area
S IOTM=VALM("TM"),IOBM=VALM("BM") W IOSC W @IOSTBM W IORC
Q
LST ; -- compute last line on screen
N I
S I=VALMBG+VALM("LINES")-1,VALMLST=$S($D(@VALMAR@(I,0)):I,1:VALMCNT)
Q
WRITE(LINE,LF,CTRL,DY) ;
N TEXT
;S LINE=+$$GET(LINE)
S TEXT=$$EXTRACT($G(@VALMAR@(LINE,0))),DX=VALMWD
I TEXT?.E1C.E S TEXT=$$CTRL^XMXUTIL1(TEXT)
W:LF !
; -- write text if no formatting needed or allowed
I 'CTRL!('$O(^TMP("VALM VIDEO",$J,VALMEVL,LINE,0)))!('VALMCC) W TEXT Q
D:VALM("FIXED") FORMAT(.LINE,.TEXT,0,0,1,VALM("FIXED"),.DY)
D FORMAT(.LINE,.TEXT,VALM("FIXED"),VALM("FIXED"),VALMLFT,VALMWD,.DY)
Q
FORMAT(LINE,TEXT,FIXED,PREVCOL,TXTLEFT,RMAR,DY) ;
N ATR,WIDTH,COL,LASTCOL,FIN,CRTLCOL
S COL=0,FIN=0
; -- scan for attributes
F Q:FIN S COL=$O(^TMP("VALM VIDEO",$J,VALMEVL,LINE,COL)) Q:'COL S WIDTH="" F S WIDTH=$O(^TMP("VALM VIDEO",$J,VALMEVL,LINE,COL,WIDTH)) Q:WIDTH="" S ATR=^(WIDTH) D Q:FIN
. I TXTLEFT>(COL+WIDTH-1) Q
. S CTRLCOL=COL-TXTLEFT+FIXED
. S:CTRLCOL<(PREVCOL+1) CTRLCOL=PREVCOL
. S:CTRLCOL'<RMAR CTRLCOL=RMAR,FIN=1
. W $E(TEXT,PREVCOL+1,CTRLCOL) S PREVCOL=CTRLCOL
. W $C(13)_ATR_$C(13) D IOXY(.CTRLCOL,.DY)
I PREVCOL<RMAR W $E(TEXT,PREVCOL+1,RMAR)
W $C(13)_VALMSGR_$C(13) D IOXY(.RMAR,.DY)
Q
Q $S(X="":X,1:$E($E(X,1,+VALM("FIXED"))_$E(X,VALMLFT,VALMLFT+VALMWD-1-VALM("FIXED"))_$J("",VALMWD),1,VALMWD))
GET(LNUM) ; -- get actual line number (may be different if indexed)
Q $S(VALM(0)["I":$G(@VALMIDX@(LNUM)),1:LNUM)
PLUS ; -- add plus indicators to screen
N UP,DN
W $C(13) ; -- needed to prevent extra LF's after FORMAT loops
S UP=(VALMBG'=1),DN=$S('$D(VALMLST):0,VALM(0)["I":$O(@VALMIDX@(+VALMLST))>0,1:$O(@VALMAR@(+VALMLST))>0)
I UP'=VALMUP S VALMUP=UP D UND($S(UP:"+",1:" "),1,VALM("TM")-1,1,.IOUON,.IOUOFF,0)
I DN'=VALMDN S VALMDN=DN D UND($S(DN:"+",1:" "),1,VALM("BM")+1,1,.IORVON,.IORVOFF,0)
Q
PGUPD ; -- update page var and screen
N P
S P=$$PAGE(VALMBG,VALM("LINES")) Q:P=VALMPGE
S VALMPGE=P
D:VALMCC UND($J(P,4),VALMWD-12,1,4,.IOUON,.IOUOFF,0)
Q
PAGE(BEG,LINES) ; -- calc page #
S BEG=$S($D(@VALMAR@(BEG,0)):BEG,1:0)
Q (BEG\LINES)+((BEG#LINES)>0)
UND(STR,X,Y,LEN,ON,OFF,ERASE) ;
W $C(13)_ON_$C(13) D INSTR^VALM1(STR,X,Y,LEN,+$G(ERASE)) W $C(13)_OFF_$C(13)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVALM4 4549 printed Oct 16, 2024@18:10:49 Page 2
VALM4 ;ALB/MJK - Screen Malipulation Utilities ;02/12/2001 13:45
+1 ;;1.0;List Manager;**4,6**;Aug 13, 1993
NEXT ; -- display next screen (NX)
+1 DO START
+2 NEW VALMLSTO,I,LN
+3 IF VALMBG+VALM("LINES")>VALMCNT
WRITE $CHAR(7)
DO FINISH
QUIT
+4 SET VALMBG=VALMBG+VALM("LINES")
+5 SET VALMLSTO=VALMLST
+6 IF VALMCC
DO LST
DO SCROLL
Begin DoDot:1
+7 SET DY=VALM("BM")-1
DO IOXY(0,.DY)
+8 SET I=VALMLSTO+1
FOR LN=1:1:VALM("LINES")
DO WRITE(I,1,1,.DY)
SET I=I+1
+9 DO PLUS
DO RESET
End DoDot:1
+10 DO PGUPD
+11 DO FINISH
+12 QUIT
PREV ; -- display previous screen (BU)
+1 DO START
+2 NEW I,LN,X,Y,VALMBGO
+3 IF VALMBG=1
WRITE $CHAR(7)
DO FINISH
QUIT
+4 SET Y=VALMBG-VALM("LINES")
+5 SET VALMBGO=VALMBG
SET VALMBG=$SELECT(Y<1:1,1:Y)
+6 IF VALMCC
DO LST
DO SCROLL
Begin DoDot:1
+7 SET DY=VALM("TM")-1
+8 SET I=VALMBGO-1
FOR LN=1:1:VALM("LINES")
DO IOIL(0,.DY)
DO WRITE(I,0,1,.DY)
if I=1
QUIT
SET I=I-1
+9 DO PLUS
DO RESET
End DoDot:1
+10 DO PGUPD
+11 DO FINISH
+12 QUIT
FIRST ; -- display first screen (FS)
+1 DO START
+2 IF VALMBG=1
WRITE $CHAR(7)
DO FINISH
QUIT
+3 SET VALMBG=1
+4 IF VALMCC
DO LST
DO PAINT
+5 DO PGUPD
+6 DO FINISH
+7 QUIT
LAST ; -- display last screen (LS)
+1 DO START
+2 NEW Y,I
+3 IF VALMCNT'>VALM("LINES")
WRITE $CHAR(7)
DO FINISH
QUIT
+4 ; first line of the last screen :=
+5 ; (# of full screens less 1 if last screen is also full) x # lines per screen) + 1 line
+6 SET Y=(((VALMCNT\VALM("LINES"))-'(VALMCNT#VALM("LINES")))*VALM("LINES"))+1
+7 IF Y=VALMBG
WRITE $CHAR(7)
DO FINISH
QUIT
+8 SET VALMBG=Y
+9 IF VALMCC
DO LST
DO PAINT
+10 DO PGUPD
+11 DO FINISH
+12 QUIT
START ; -- start action tasks
+1 if VALMMENU
SET VALMDY=""
+2 WRITE VALMCOFF
+3 QUIT
FINISH ; -- finish action tasks
+1 SET VALMBCK=$SELECT(VALMCC:"",1:"R")
+2 WRITE VALMCON
+3 QUIT
PAINT ;
+1 NEW I,LN,X
DO SCROLL
+2 IF $EXTRACT(IOST,1,4)="C-VT"
SET DY=VALM("TM")-1
DO IOXY(0,.DY)
WRITE *27,*91,VALM("LINES"),*77
+3 SET I=VALMBG
FOR LN=1:1:VALM("LINES")
SET DY=VALM("TM")+LN-2
DO IOIL(0,.DY)
DO WRITE(I,0,1,.DY)
SET I=I+1
+4 DO PLUS
DO RESET
+5 QUIT
IOIL(DX,DY) ; -- position cursor ; insert line ; cr
+1 WRITE !
XECUTE IOXY
WRITE IOIL,$CHAR(13)
+2 QUIT
IOXY(DX,DY) ; -- position cursor and tell os
+1 ;,VALMIOXY
XECUTE IOXY
+2 QUIT
RE ; -- re-display current screen (RE)
+1 DO REFRESH^VALM
SET VALMBCK=""
+2 QUIT
RESET ; -- reset scrolling region to bottom of screen
+1 IF '$DATA(VALMDY)
DO IOXY(0,VALM("BM")+1)
WRITE IOEDEOP
+2 SET IOTM=VALM("BM")+2
SET IOBM=IOSL
WRITE IOSC
WRITE @IOSTBM
WRITE IORC
+3 DO UND($$HTE^XLFDT($HOROLOG,1),31+((VALMWD-80)/2),1,21,.IOUON,.IOUOFF,0)
+4 IF $DATA(VALMBCK)
DO IOXY(0,VALM("BM"))
+5 QUIT
SCROLL ; -- set scrolling region to list area
+1 SET IOTM=VALM("TM")
SET IOBM=VALM("BM")
WRITE IOSC
WRITE @IOSTBM
WRITE IORC
+2 QUIT
LST ; -- compute last line on screen
+1 NEW I
+2 SET I=VALMBG+VALM("LINES")-1
SET VALMLST=$SELECT($DATA(@VALMAR@(I,0)):I,1:VALMCNT)
+3 QUIT
WRITE(LINE,LF,CTRL,DY) ;
+1 NEW TEXT
+2 ;S LINE=+$$GET(LINE)
+3 SET TEXT=$$EXTRACT($GET(@VALMAR@(LINE,0)))
SET DX=VALMWD
+4 IF TEXT?.E1C.E
SET TEXT=$$CTRL^XMXUTIL1(TEXT)
+5 if LF
WRITE !
+6 ; -- write text if no formatting needed or allowed
+7 IF 'CTRL!('$ORDER(^TMP("VALM VIDEO",$JOB,VALMEVL,LINE,0)))!('VALMCC)
WRITE TEXT
QUIT
+8 if VALM("FIXED")
DO FORMAT(.LINE,.TEXT,0,0,1,VALM("FIXED"),.DY)
+9 DO FORMAT(.LINE,.TEXT,VALM("FIXED"),VALM("FIXED"),VALMLFT,VALMWD,.DY)
+10 QUIT
FORMAT(LINE,TEXT,FIXED,PREVCOL,TXTLEFT,RMAR,DY) ;
+1 NEW ATR,WIDTH,COL,LASTCOL,FIN,CRTLCOL
+2 SET COL=0
SET FIN=0
+3 ; -- scan for attributes
+4 FOR
if FIN
QUIT
SET COL=$ORDER(^TMP("VALM VIDEO",$JOB,VALMEVL,LINE,COL))
if 'COL
QUIT
SET WIDTH=""
FOR
SET WIDTH=$ORDER(^TMP("VALM VIDEO",$JOB,VALMEVL,LINE,COL,WIDTH))
if WIDTH=""
QUIT
SET ATR=^(WIDTH)
Begin DoDot:1
+5 IF TXTLEFT>(COL+WIDTH-1)
QUIT
+6 SET CTRLCOL=COL-TXTLEFT+FIXED
+7 if CTRLCOL<(PREVCOL+1)
SET CTRLCOL=PREVCOL
+8 if CTRLCOL'<RMAR
SET CTRLCOL=RMAR
SET FIN=1
+9 WRITE $EXTRACT(TEXT,PREVCOL+1,CTRLCOL)
SET PREVCOL=CTRLCOL
+10 WRITE $CHAR(13)_ATR_$CHAR(13)
DO IOXY(.CTRLCOL,.DY)
End DoDot:1
if FIN
QUIT
+11 IF PREVCOL<RMAR
WRITE $EXTRACT(TEXT,PREVCOL+1,RMAR)
+12 WRITE $CHAR(13)_VALMSGR_$CHAR(13)
DO IOXY(.RMAR,.DY)
+13 QUIT
+1 QUIT $SELECT(X="":X,1:$EXTRACT($EXTRACT(X,1,+VALM("FIXED"))_$EXTRACT(X,VALMLFT,VALMLFT+VALMWD-1-VALM("FIXED"))_$JUSTIFY("",VALMWD),1,VALMWD))
GET(LNUM) ; -- get actual line number (may be different if indexed)
+1 QUIT $SELECT(VALM(0)["I":$GET(@VALMIDX@(LNUM)),1:LNUM)
PLUS ; -- add plus indicators to screen
+1 NEW UP,DN
+2 ; -- needed to prevent extra LF's after FORMAT loops
WRITE $CHAR(13)
+3 SET UP=(VALMBG'=1)
SET DN=$SELECT('$DATA(VALMLST):0,VALM(0)["I":$ORDER(@VALMIDX@(+VALMLST))>0,1:$ORDER(@VALMAR@(+VALMLST))>0)
+4 IF UP'=VALMUP
SET VALMUP=UP
DO UND($SELECT(UP:"+",1:" "),1,VALM("TM")-1,1,.IOUON,.IOUOFF,0)
+5 IF DN'=VALMDN
SET VALMDN=DN
DO UND($SELECT(DN:"+",1:" "),1,VALM("BM")+1,1,.IORVON,.IORVOFF,0)
+6 QUIT
PGUPD ; -- update page var and screen
+1 NEW P
+2 SET P=$$PAGE(VALMBG,VALM("LINES"))
if P=VALMPGE
QUIT
+3 SET VALMPGE=P
+4 if VALMCC
DO UND($JUSTIFY(P,4),VALMWD-12,1,4,.IOUON,.IOUOFF,0)
+5 QUIT
PAGE(BEG,LINES) ; -- calc page #
+1 SET BEG=$SELECT($DATA(@VALMAR@(BEG,0)):BEG,1:0)
+2 QUIT (BEG\LINES)+((BEG#LINES)>0)
UND(STR,X,Y,LEN,ON,OFF,ERASE) ;
+1 WRITE $CHAR(13)_ON_$CHAR(13)
DO INSTR^VALM1(STR,X,Y,LEN,+$GET(ERASE))
WRITE $CHAR(13)_OFF_$CHAR(13)
+2 QUIT