VistA-WorldVistAEHR/r/LIST_MANAGER-VALM/VALM40.m

122 lines
4.2 KiB
Mathematica

VALM40 ;ALB/MJK - Screen Malipulation Utilities (cont.) ;01/31/2001 14:45
;;1.0;List Manager;**6**;Aug 13, 1993
FIND ; -- find text in list
N START,BEG,VALMOUT,VALMHIT,X,Y,DIR,DIRUT
S DIR(0)="F^2:50",DIR("A")="Search for" S:$D(VALMFIND) DIR("B")=VALMFIND
S DIR("?")="Enter from two to fifty characters."
D ^DIR I $D(DIRUT) D FINISH^VALM4 Q
S VALMFIND=Y,(BEG,START)=VALMBG,FINISH=VALMCNT
F D SEARCH(START,FINISH) D D:VALMHIT SELECT^VALM10(VALMHIT,0) Q:$D(VALMOUT)
. I 'VALMHIT,BEG=1 D WAIT^VALM1 S VALMOUT="" Q
. I VALMHIT,BEG=1,VALMHIT=VALMCNT D WAIT^VALM1 S VALMOUT="" Q
. I 'VALMHIT!(VALMHIT=VALMCNT),BEG'=1 D Q
. . I '$$BEG S VALMOUT="" Q
. . S FINISH=BEG-1,(BEG,START)=1
. N DIR,X,Y,DIRUT
. W ! S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Find Next '"_VALMFIND_"'"
. D ^DIR I 'Y S VALMOUT="" Q
. S START=VALMHIT+1
D FINISH^VALM4
Q
BEG() ; -- ask if ok to start from top
W !!,"<<< End of list >>>"
N DIR,X,Y,DIRUT
S DIR(0)="Y",DIR("A")="Do you want to start at the beginning of the list",DIR("B")="Yes"
D ^DIR
Q Y
SEARCH(START,FINISH) ; -- search to end or first hit
; input: START := line to start search on
; FINISH := line to end search on
N Y,X,L,CNT
S VALMHIT="",CNT=0
S VALMBCK="" D:VALMCC RESET^VALM4 W !,"...searching for '"_VALMFIND_"'"
F I=START:1:FINISH S CNT=CNT+1 W:'(CNT#100) "." I $$UP^XLFSTR(@VALMAR@(I,0))[$$UP^XLFSTR(VALMFIND) S VALMHIT=I Q
I 'VALMHIT W $C(7),!!,"Text not found." Q
I VALMCC D
. I VALMHIT<VALMBG!(VALMHIT>VALMLST) S VALMBG=VALMHIT D LST^VALM4,PAINT^VALM4
. D UPD(VALMHIT,VALMFIND)
D PGUPD^VALM4
I 'VALMCC S VALMBG=VALMHIT D REFRESH^VALM
Q
UPD(LINE,TEXT) ; -- set/unset video attribute on text
; input: LINE := number of line
; TEXT := chars to set attribute on
N LEN,POS,FIRST
D SELECT^VALM10(.LINE,1)
I 'VALMCC Q
S Y=@VALMAR@(LINE,0),LEN=$L(TEXT),POS=0,FIRST=""
F S POS=$F($$UP^XLFSTR(Y),$$UP^XLFSTR(TEXT),POS) Q:'POS D
. S:'FIRST FIRST=POS-LEN
. D CNTRL^VALM10(.LINE,POS-LEN,.LEN,.IORVON,IORVOFF_IOINHI)
I FIRST D
. I FIRST'>VALM("FIXED") Q
. I FIRST<VALMLFT D LEFT("^^^="_(VALMLFT-FIRST)) Q
. I FIRST'>((VALMWD-VALM("FIXED"))+VALMLFT) Q
. D RIGHT("^^^="_(FIRST-VALMLFT))
D WRITE^VALM10(.LINE)
Q
UP ; -- display last screen (UP)
D START^VALM4
N Y S Y=VALMBG-1 I Y<1 W $C(7) D FINISH^VALM4 Q
S VALMBG=Y D LST^VALM4
I VALMCC S DY=VALM("TM")-1 D SCROLL^VALM4,IOIL^VALM4(0,.DY),WRITE^VALM4(VALMBG,0,1,.DY),PLUS^VALM4,RESET^VALM4
D PGUPD^VALM4
D FINISH^VALM4
Q
DOWN ; -- display next line (DN)
D START^VALM4
N Y S Y=VALMLST+1 I Y>VALMCNT W $C(7) D FINISH^VALM4 Q
S VALMBG=VALMBG+1,VALMLST=Y
I VALMCC S DY=VALM("BM")-1 D SCROLL^VALM4,IOXY^VALM4(0,.DY),WRITE^VALM4(VALMLST,1,1,.DY),PLUS^VALM4,RESET^VALM4
D PGUPD^VALM4
D FINISH^VALM4
Q
RIGHT(VALMNOD) ; -- move view to right
D START^VALM4
N MOVE,RM
S MOVE=$P($P(VALMNOD,U,4),"=",3),RM=VALM("RM")-VALMWD+VALM("FIXED")
I VALMLFT=RM W $C(7) D FINISH^VALM4 Q
I MOVE?1">".E D
. S VALMLFT=RM
E D
. S MOVE=$S(MOVE:+MOVE,1:VALMWD-VALM("FIXED"))
. I (VALMLFT+MOVE)>RM S VALMLFT=RM Q
. S VALMLFT=VALMLFT+MOVE
I VALMCC S:VALMWD'<$L($G(VALMHDR(VALM("TM")-3))) VALMBCK="P" D REFRESH^VALM
D FINISH^VALM4
Q
LEFT(VALMNOD) ; -- move view to left
D START^VALM4
N MOVE,LM
S MOVE=$P($P(VALMNOD,U,4),"=",3),LM=VALM("FIXED")+1
I VALMLFT=LM W $C(7) D FINISH^VALM4 Q
I MOVE?1"<".E D
. S VALMLFT=LM
E D
. S MOVE=$S(MOVE:+MOVE,1:VALMWD-VALM("FIXED"))
. S:(VALMLFT-MOVE)<LM MOVE=VALMLFT-VALM("FIXED")-1
. S VALMLFT=VALMLFT-MOVE
I VALMCC S:VALMWD'<$L($G(VALMHDR(VALM("TM")-3))) VALMBCK="P" D REFRESH^VALM
D FINISH^VALM4
Q
GOTO ; -- go to page #
N Y,PAGE,LINE
S PAGE=$$PAGE^VALM4(VALMCNT,VALM("LINES"))
I PAGE=1 S VALMSG="This list only contains 1 page." G GOTOQ
S Y=+$P($P(XQORNOD(0),U,4),"=",3)
I Y D I $G(VALMSG)]"" G GOTOQ
. I Y>PAGE S VALMSG="Too large. Page #"_Y_" does not exist." Q
. I Y<1 S VALMSG="Negative page numbers do not exist." Q
. S PAGE=Y
I 'Y D
. N DIR,X,Y,DIRUT
. S DIR(0)="NA^1:"_PAGE,DIR("A")="Go to Page (1-"_PAGE_"): "
. W ! D ^DIR S PAGE=+Y
I PAGE D
. S LINE=((PAGE-1)*VALM("LINES"))+1
. I LINE=VALMBG S VALMSG="Your selection is the current screen." Q
. I LINE'=VALMBG S VALMBG=LINE D:VALMCC LST^VALM4,PAINT^VALM4 D PGUPD^VALM4
GOTOQ I $G(VALMSG)]"" S VALMSG=$C(7)_VALMSG
D FINISH^VALM4
Q