source: WorldVistAEHR/trunk/r/LIST_MANAGER-VALM/VALM4.m@ 923

Last change on this file since 923 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.3 KB
Line 
1VALM4 ;ALB/MJK - Screen Malipulation Utilities ;02/12/2001 13:45
2 ;;1.0;List Manager;**4,6**;Aug 13, 1993
3NEXT ; -- display next screen (NX)
4 D START
5 N VALMLSTO,I,LN
6 I VALMBG+VALM("LINES")>VALMCNT W $C(7) D FINISH Q
7 S VALMBG=VALMBG+VALM("LINES")
8 S VALMLSTO=VALMLST
9 I VALMCC D LST,SCROLL D
10 . S DY=VALM("BM")-1 D IOXY(0,.DY)
11 . S I=VALMLSTO+1 F LN=1:1:VALM("LINES") D WRITE(I,1,1,.DY) S I=I+1
12 . D PLUS,RESET
13 D PGUPD
14 D FINISH
15 Q
16PREV ; -- display previous screen (BU)
17 D START
18 N I,LN,X,Y,VALMBGO
19 I VALMBG=1 W $C(7) D FINISH Q
20 S Y=VALMBG-VALM("LINES")
21 S VALMBGO=VALMBG,VALMBG=$S(Y<1:1,1:Y)
22 I VALMCC D LST,SCROLL D
23 . S DY=VALM("TM")-1
24 . 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
25 . D PLUS,RESET
26 D PGUPD
27 D FINISH
28 Q
29FIRST ; -- display first screen (FS)
30 D START
31 I VALMBG=1 W $C(7) D FINISH Q
32 S VALMBG=1
33 I VALMCC D LST,PAINT
34 D PGUPD
35 D FINISH
36 Q
37LAST ; -- display last screen (LS)
38 D START
39 N Y,I
40 I VALMCNT'>VALM("LINES") W $C(7) D FINISH Q
41 ; first line of the last screen :=
42 ; (# of full screens less 1 if last screen is also full) x # lines per screen) + 1 line
43 S Y=(((VALMCNT\VALM("LINES"))-'(VALMCNT#VALM("LINES")))*VALM("LINES"))+1
44 I Y=VALMBG W $C(7) D FINISH Q
45 S VALMBG=Y
46 I VALMCC D LST,PAINT
47 D PGUPD
48 D FINISH
49 Q
50START ; -- start action tasks
51 S:VALMMENU VALMDY=""
52 W VALMCOFF
53 Q
54FINISH ; -- finish action tasks
55 S VALMBCK=$S(VALMCC:"",1:"R")
56 W VALMCON
57 Q
58PAINT ;
59 N I,LN,X D SCROLL
60 I $E(IOST,1,4)="C-VT" S DY=VALM("TM")-1 D IOXY(0,.DY) W *27,*91,VALM("LINES"),*77
61 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
62 D PLUS,RESET
63 Q
64IOIL(DX,DY) ; -- position cursor ; insert line ; cr
65 W ! X IOXY W IOIL,$C(13)
66 Q
67IOXY(DX,DY) ; -- position cursor and tell os
68 X IOXY ;,VALMIOXY
69 Q
70RE ; -- re-display current screen (RE)
71 D REFRESH^VALM S VALMBCK=""
72 Q
73RESET ; -- reset scrolling region to bottom of screen
74 I '$D(VALMDY) D IOXY(0,VALM("BM")+1) W IOEDEOP
75 S IOTM=VALM("BM")+2,IOBM=IOSL W IOSC W @IOSTBM W IORC
76 D UND($$HTE^XLFDT($H,1),31+((VALMWD-80)/2),1,21,.IOUON,.IOUOFF,0)
77 I $D(VALMBCK) D IOXY(0,VALM("BM"))
78 Q
79SCROLL ; -- set scrolling region to list area
80 S IOTM=VALM("TM"),IOBM=VALM("BM") W IOSC W @IOSTBM W IORC
81 Q
82LST ; -- compute last line on screen
83 N I
84 S I=VALMBG+VALM("LINES")-1,VALMLST=$S($D(@VALMAR@(I,0)):I,1:VALMCNT)
85 Q
86WRITE(LINE,LF,CTRL,DY) ;
87 N TEXT
88 ;S LINE=+$$GET(LINE)
89 S TEXT=$$EXTRACT($G(@VALMAR@(LINE,0))),DX=VALMWD
90 I TEXT?.E1C.E S TEXT=$$CTRL^XMXUTIL1(TEXT)
91 W:LF !
92 ; -- write text if no formatting needed or allowed
93 I 'CTRL!('$O(^TMP("VALM VIDEO",$J,VALMEVL,LINE,0)))!('VALMCC) W TEXT Q
94 D:VALM("FIXED") FORMAT(.LINE,.TEXT,0,0,1,VALM("FIXED"),.DY)
95 D FORMAT(.LINE,.TEXT,VALM("FIXED"),VALM("FIXED"),VALMLFT,VALMWD,.DY)
96 Q
97FORMAT(LINE,TEXT,FIXED,PREVCOL,TXTLEFT,RMAR,DY) ;
98 N ATR,WIDTH,COL,LASTCOL,FIN,CRTLCOL
99 S COL=0,FIN=0
100 ; -- scan for attributes
101 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
102 . I TXTLEFT>(COL+WIDTH-1) Q
103 . S CTRLCOL=COL-TXTLEFT+FIXED
104 . S:CTRLCOL<(PREVCOL+1) CTRLCOL=PREVCOL
105 . S:CTRLCOL'<RMAR CTRLCOL=RMAR,FIN=1
106 . W $E(TEXT,PREVCOL+1,CTRLCOL) S PREVCOL=CTRLCOL
107 . W $C(13)_ATR_$C(13) D IOXY(.CTRLCOL,.DY)
108 I PREVCOL<RMAR W $E(TEXT,PREVCOL+1,RMAR)
109 W $C(13)_VALMSGR_$C(13) D IOXY(.RMAR,.DY)
110 Q
111EXTRACT(X) ; -- extract string
112 Q $S(X="":X,1:$E($E(X,1,+VALM("FIXED"))_$E(X,VALMLFT,VALMLFT+VALMWD-1-VALM("FIXED"))_$J("",VALMWD),1,VALMWD))
113GET(LNUM) ; -- get actual line number (may be different if indexed)
114 Q $S(VALM(0)["I":$G(@VALMIDX@(LNUM)),1:LNUM)
115PLUS ; -- add plus indicators to screen
116 N UP,DN
117 W $C(13) ; -- needed to prevent extra LF's after FORMAT loops
118 S UP=(VALMBG'=1),DN=$S('$D(VALMLST):0,VALM(0)["I":$O(@VALMIDX@(+VALMLST))>0,1:$O(@VALMAR@(+VALMLST))>0)
119 I UP'=VALMUP S VALMUP=UP D UND($S(UP:"+",1:" "),1,VALM("TM")-1,1,.IOUON,.IOUOFF,0)
120 I DN'=VALMDN S VALMDN=DN D UND($S(DN:"+",1:" "),1,VALM("BM")+1,1,.IORVON,.IORVOFF,0)
121 Q
122PGUPD ; -- update page var and screen
123 N P
124 S P=$$PAGE(VALMBG,VALM("LINES")) Q:P=VALMPGE
125 S VALMPGE=P
126 D:VALMCC UND($J(P,4),VALMWD-12,1,4,.IOUON,.IOUOFF,0)
127 Q
128PAGE(BEG,LINES) ; -- calc page #
129 S BEG=$S($D(@VALMAR@(BEG,0)):BEG,1:0)
130 Q (BEG\LINES)+((BEG#LINES)>0)
131UND(STR,X,Y,LEN,ON,OFF,ERASE) ;
132 W $C(13)_ON_$C(13) D INSTR^VALM1(STR,X,Y,LEN,+$G(ERASE)) W $C(13)_OFF_$C(13)
133 Q
Note: See TracBrowser for help on using the repository browser.