"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "vil96w32/pictmode.rc" of archive vile-w32.zip:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 ; $Header: /usr/build/vile/vile/macros/RCS/pictmode.rc,v 1.4 2005/04/19 19:21:59 tom Exp $
2 ; this procedure implements a primitive ascii picture-drawing mode.
3 ; pgf, may '95
4
5 ; motions are accomplished with the usual h, j, k, and l keys
6 ; (the arrow keys do _not_ work here). in addition, the u, i,
7 ; n, and m keys will perform diagonal motions. look at your
8 ; keyboard to see why these were chosen.
9
10 ; normally, entering the motion characters (h, j, k, l, u, i, n, m)
11 ; will draw appropriate box outlines, using the -, |, /, and \ characters.
12
13 ; lines will be drawn instead with a specific character if the 'c' command
14 ; is given -- you will be prompted for a character. this can be
15 ; cancelled, to revert lines to their "natural" rendition, with the
16 ; 'C' command. for example, to draw with a '+' character, you would
17 ; use "c+" and when finished, would cancel with "C".
18
19 ; the ^T command will allow you to enter a string of text. this
20 ; text will accumulate until ESC, CR, or NL is typed.
21
22 ; all other input will be inserted as-is, with no cursor movement. so
23 ; the space bar can be used to "erase" previously drawn stuff.
24
25 ; space for the picture must be pre-allocated, with, for example:
26 ; 80i <ESC>yy24p
27 ;
28 ; start this up with "run pic"
29 ; to bind it to a key instead, change it to a "NN store-macro", and
30 ; then bind "execute-macro NN" to the key you want.
31 store-procedure replc
32 ; never replace a newline
33 ~if &equ $char 0xA
34 ~return
35 ~endif
36
37 ~if &seq %userchar &chr 0
38 replace-character %linechar
39 ~else
40 replace-character %userchar
41 ~endif
42 ~endm
43 store-procedure pic
44 ~local %keywas %linechar %textkey %userchar
45 set-variable %keywas &chr 0
46 set-variable %userchar &chr 0
47 set-variable %linechar &chr 0
48 write-message "entering picture, end with ESC"
49 redraw-display
50 ~while 1
51 set-variable %keywas >k
52
53 ; was it ESC? quit if so.
54 ~if &seq %keywas &chr 0x1b
55 ~break
56 ~endif
57
58 ; Rectangular Lines: h, j, k, l
59 ~if &seq %keywas h
60 ~force backward-character
61 set-variable %linechar -
62 run replc
63 ~goto redraw
64 ~endif
65 ~if &seq %keywas l
66 ~force forward-character
67 set-variable %linechar -
68 run replc
69 ~goto redraw
70 ~endif
71 ~if &seq %keywas j
72 ~force down-line
73 set-variable %linechar |
74 run replc
75 ~goto redraw
76 ~endif
77 ~if &seq %keywas k
78 ~force up-line
79 set-variable %linechar |
80 run replc
81 ~goto redraw
82 ~endif
83
84 ; Diagonal Lines: u, i, n, m
85 ~if &seq %keywas u
86 ~force up-line
87 ~force backward-character
88 set-variable %linechar "\\"
89 run replc
90 ~goto redraw
91 ~endif
92 ~if &seq %keywas i
93 ~force up-line
94 ~force forward-character
95 set-variable %linechar /
96 run replc
97 ~goto redraw
98 ~endif
99 ~if &seq %keywas n
100 ~force down-line
101 ~force backward-character
102 set-variable %linechar /
103 run replc
104 ~goto redraw
105 ~endif
106 ~if &seq %keywas m
107 ~force down-line
108 ~force forward-character
109 set-variable %linechar "\\"
110 run replc
111 ~goto redraw
112 ~endif
113
114 ; Rectangular Motions: ^H, ^L, ^J, ^K
115 ; was it ^H
116 ~if &seq %keywas &chr 0x8
117 ~force backward-character
118 ~goto redraw
119 ~endif
120
121 ; was it ^L
122 ~if &seq %keywas &chr 0xC
123 ~force forward-character
124 ~goto redraw
125 ~endif
126
127 ; was it ^J
128 ~if &seq %keywas &chr 0xA
129 ~force down-line
130 ~goto redraw
131 ~endif
132
133 ; was it ^K
134 ~if &seq %keywas &chr 0xB
135 ~force up-line
136 ~goto redraw
137 ~endif
138 ; Diagonal Motions: ^U, ^I, ^N, ^M
139 ; was it ^U
140 ~if &seq %keywas &chr 0x15
141 ~force up-line
142 ~force backward-character
143 ~goto redraw
144 ~endif
145 ; was it ^I
146 ~if &seq %keywas &chr 0x9
147 ~force up-line
148 ~force forward-character
149 ~goto redraw
150 ~endif
151 ; was it ^N
152 ~if &seq %keywas &chr 0xE
153 ~force down-line
154 ~force backward-character
155 ~goto redraw
156 ~endif
157 ; was it ^M
158 ~if &seq %keywas &chr 0xD
159 ~force down-line
160 ~force forward-character
161 ~goto redraw
162 ~endif
163
164 ; Text: ^Ttext to be entered<CR>
165 ; was it ^T
166 ~if &seq %keywas &chr 0x14
167 write-message "entering text, end with CR"
168 redraw-display
169 set-variable %textkey 0
170 ~while 1
171 set-variable %textkey >k
172 ; was it CR (^M)
173 ~if &seq %textkey &chr 0xD
174 ~break
175 ~endif
176 ; was it LF (^J)
177 ~if &seq %textkey &chr 0xA
178 ~break
179 ~endif
180 ; was it ESC (^[)
181 ~if &seq %textkey &chr 0x1B
182 ~break
183 ~endif
184 ; was it BS (^H) or DEL?
185 ~if &or &seq %textkey &chr 0x7f &seq %textkey &chr 0x8
186 ~force backward-character
187 replace-character &chr 0x20
188 ~force backward-character
189 set-variable %textkey &chr $char
190 ~endif
191 replace-character %textkey
192 ~force forward-character
193 redraw-display
194 ~endwhile
195 write-message "text done, drawing lines again"
196 ~goto redraw
197 ~endif
198
199 ; user-selected lines: 'c' to set the linechar, 'C' to cancel
200 ~if &seq %keywas c
201 write-message "enter char to draw with: "
202 set-variable %userchar >k
203 write-message &cat "will draw with: " %userchar
204 ~goto redraw
205 ~endif
206 ~if &seq %keywas C
207 write-message "will draw normal lines again"
208 set-variable %userchar &chr 0
209 ~goto redraw
210 ~endif
211
212
213 ; Everything else is self inserting
214 replace-character %keywas
215
216 *redraw
217
218 redraw-display
219 ~endwhile
220 write-message "picture mode done"
221 ~endm
222