995
|
1 /*
|
|
2 * The functions in this file handle redisplay. There are two halves, the
|
|
3 * ones that update the virtual display screen, and the ones that make the
|
|
4 * physical display screen the same as the virtual display screen. These
|
|
5 * functions use hints that are left in the windows by the commands.
|
|
6 *
|
|
7 * REVISION HISTORY:
|
|
8 *
|
|
9 * ? Steve Wilhite, 1-Dec-85
|
|
10 * - massive cleanup on code.
|
|
11 */
|
|
12
|
|
13 #include <stdio.h>
|
|
14 #include "ueed.h"
|
|
15 #include "uedisplay.h"
|
|
16
|
|
17 extern VIDEO **vscreen; /* Virtual screen. */
|
|
18
|
|
19 /*
|
|
20 * Redisplay the mode line for the window pointed to by the "wp". This is the
|
|
21 * only routine that has any idea of how the modeline is formatted. You can
|
|
22 * change the modeline format by hacking at this routine. Called by "update"
|
|
23 * any time there is a dirty window.
|
|
24 */
|
|
25 modeline(wp)
|
|
26 WINDOW *wp;
|
|
27 {
|
|
28 register char *cp;
|
|
29 register int c;
|
|
30 register int n;
|
|
31 register BUFFER *bp;
|
|
32
|
|
33 n = wp->w_toprow+wp->w_ntrows; /* Location. */
|
|
34 vscreen[n]->v_flag |= VFCHG; /* Redraw next time. */
|
|
35 vtmove(n, 0); /* Seek to right line. */
|
|
36 vtputc('-');
|
|
37 bp = wp->w_bufp;
|
|
38
|
|
39 if ((bp->b_flag&BFCHG) != 0) /* "*" if changed. */
|
|
40 vtputc('*');
|
|
41 else
|
|
42 vtputc('-');
|
|
43
|
|
44 n = 2;
|
|
45 cp = " MicroEMACS -"; /* Buffer name. */
|
|
46
|
|
47 while ((c = *cp++) != 0)
|
|
48 {
|
|
49 vtputc(c);
|
|
50 ++n;
|
|
51 }
|
|
52
|
|
53 #ifndef OS9
|
|
54 cp = &bp->b_bname[0];
|
|
55
|
|
56 while ((c = *cp++) != 0)
|
|
57 {
|
|
58 vtputc(c);
|
|
59 ++n;
|
|
60 }
|
|
61
|
|
62 vtputc(' ');
|
|
63 ++n;
|
|
64 #endif
|
|
65
|
|
66 if (bp->b_fname[0] != 0) /* File name. */
|
|
67 {
|
|
68 cp = " File: ";
|
|
69
|
|
70 while ((c = *cp++) != 0)
|
|
71 {
|
|
72 vtputc(c);
|
|
73 ++n;
|
|
74 }
|
|
75
|
|
76 cp = &bp->b_fname[0];
|
|
77
|
|
78 while ((c = *cp++) != 0)
|
|
79 {
|
|
80 vtputc(c);
|
|
81 ++n;
|
|
82 }
|
|
83
|
|
84 vtputc(' ');
|
|
85 ++n;
|
|
86 }
|
|
87
|
|
88 #ifdef WFDEBUG
|
|
89 vtputc('-');
|
|
90 vtputc((wp->w_flag&WFMODE)!=0 ? 'M' : '-');
|
|
91 vtputc((wp->w_flag&WFHARD)!=0 ? 'H' : '-');
|
|
92 vtputc((wp->w_flag&WFEDIT)!=0 ? 'E' : '-');
|
|
93 vtputc((wp->w_flag&WFMOVE)!=0 ? 'V' : '-');
|
|
94 vtputc((wp->w_flag&WFFORCE)!=0 ? 'F' : '-');
|
|
95 n += 6;
|
|
96 #endif
|
|
97
|
|
98 while (n < term.t_ncol) /* Pad to full width. */
|
|
99 {
|
|
100 vtputc('-');
|
|
101 ++n;
|
|
102 }
|
|
103 }
|
|
104
|
|
105 /*
|
|
106 * Send a command to the terminal to move the hardware cursor to row "row"
|
|
107 * and column "col". The row and column arguments are origin 0. Optimize out
|
|
108 * random calls. Update "ttrow" and "ttcol".
|
|
109 */
|
|
110 movecursor(row, col)
|
|
111 {
|
|
112 if (row!=ttrow || col!=ttcol)
|
|
113 {
|
|
114 ttrow = row;
|
|
115 ttcol = col;
|
|
116 (*term.t_move)(row, col);
|
|
117 }
|
|
118 }
|
|
119
|
|
120 /*
|
|
121 * Erase the message line. This is a special routine because the message line
|
|
122 * is not considered to be part of the virtual screen. It always works
|
|
123 * immediately; the terminal buffer is flushed via a call to the flusher.
|
|
124 */
|
|
125 mlerase()
|
|
126 {
|
|
127 movecursor(term.t_nrow, 0);
|
|
128 (*term.t_eeol)();
|
|
129 (*term.t_flush)();
|
|
130 mpresf = FALSE;
|
|
131 }
|
|
132
|
|
133 /*
|
|
134 * Ask a yes or no question in the message line. Return either TRUE, FALSE, or
|
|
135 * ABORT. The ABORT status is returned if the user bumps out of the question
|
|
136 * with a ^G. Used any time a confirmation is required.
|
|
137 */
|
|
138 mlyesno(prompt)
|
|
139 char *prompt;
|
|
140 {
|
|
141 register int s;
|
|
142 char buf[64];
|
|
143
|
|
144 for (;;)
|
|
145 {
|
|
146 strcpy(buf, prompt);
|
|
147 strcat(buf, " [y/n]? ");
|
|
148 s = mlreply(buf, buf, sizeof(buf));
|
|
149
|
|
150 if (s == ABORT)
|
|
151 return (ABORT);
|
|
152
|
|
153 if (s != FALSE)
|
|
154 {
|
|
155 if (buf[0]=='y' || buf[0]=='Y')
|
|
156 return (TRUE);
|
|
157
|
|
158 if (buf[0]=='n' || buf[0]=='N')
|
|
159 return (FALSE);
|
|
160 }
|
|
161 }
|
|
162 }
|
|
163
|
|
164 /*
|
|
165 * Write a prompt into the message line, then read back a response. Keep
|
|
166 * track of the physical position of the cursor. If we are in a keyboard
|
|
167 * macro throw the prompt away, and return the remembered response. This
|
|
168 * lets macros run at full speed. The reply is always terminated by a carriage
|
|
169 * return. Handle erase, kill, and abort keys.
|
|
170 */
|
|
171 mlreply(prompt, buf, nbuf)
|
|
172 char *prompt;
|
|
173 char *buf;
|
|
174 {
|
|
175 register int cpos;
|
|
176 register int i;
|
|
177 register int c;
|
|
178
|
|
179 cpos = 0;
|
|
180
|
|
181 if (kbdmop != NULL)
|
|
182 {
|
|
183 while ((c = *kbdmop++) != '\0')
|
|
184 buf[cpos++] = c;
|
|
185
|
|
186 buf[cpos] = 0;
|
|
187
|
|
188 if (buf[0] == 0)
|
|
189 return (FALSE);
|
|
190
|
|
191 return (TRUE);
|
|
192 }
|
|
193
|
|
194 mlwrite(prompt);
|
|
195
|
|
196 for (;;)
|
|
197 {
|
|
198 c = (*term.t_getchar)();
|
|
199
|
|
200 switch (c)
|
|
201 {
|
|
202 case 0x0D: /* Return, end of line */
|
|
203 buf[cpos++] = 0;
|
|
204
|
|
205 if (kbdmip != NULL)
|
|
206 {
|
|
207 if (kbdmip+cpos > &kbdm[NKBDM-3])
|
|
208 {
|
|
209 ctrlg(FALSE, 0);
|
|
210 (*term.t_flush)();
|
|
211 return (ABORT);
|
|
212 }
|
|
213
|
|
214 for (i=0; i<cpos; ++i)
|
|
215 *kbdmip++ = buf[i];
|
|
216 }
|
|
217
|
|
218 (*term.t_putchar)('\r');
|
|
219 ttcol = 0;
|
|
220 (*term.t_flush)();
|
|
221
|
|
222 if (buf[0] == 0)
|
|
223 return (FALSE);
|
|
224
|
|
225 return (TRUE);
|
|
226
|
|
227 case 0x07: /* Bell, abort */
|
|
228 (*term.t_putchar)('^');
|
|
229 (*term.t_putchar)('G');
|
|
230 ttcol += 2;
|
|
231 ctrlg(FALSE, 0);
|
|
232 (*term.t_flush)();
|
|
233 return (ABORT);
|
|
234
|
|
235 case 0x7F: /* Rubout, erase */
|
|
236 case 0x08: /* Backspace, erase */
|
|
237 if (cpos != 0)
|
|
238 {
|
|
239 (*term.t_putchar)('\b');
|
|
240 (*term.t_putchar)(' ');
|
|
241 (*term.t_putchar)('\b');
|
|
242 --ttcol;
|
|
243
|
|
244 if (buf[--cpos] < 0x20)
|
|
245 {
|
|
246 (*term.t_putchar)('\b');
|
|
247 (*term.t_putchar)(' ');
|
|
248 (*term.t_putchar)('\b');
|
|
249 --ttcol;
|
|
250 }
|
|
251
|
|
252 (*term.t_flush)();
|
|
253 }
|
|
254
|
|
255 break;
|
|
256
|
|
257 case 0x15: /* C-U, kill */
|
|
258 while (cpos != 0)
|
|
259 {
|
|
260 (*term.t_putchar)('\b');
|
|
261 (*term.t_putchar)(' ');
|
|
262 (*term.t_putchar)('\b');
|
|
263 --ttcol;
|
|
264
|
|
265 if (buf[--cpos] < 0x20)
|
|
266 {
|
|
267 (*term.t_putchar)('\b');
|
|
268 (*term.t_putchar)(' ');
|
|
269 (*term.t_putchar)('\b');
|
|
270 --ttcol;
|
|
271 }
|
|
272 }
|
|
273
|
|
274 (*term.t_flush)();
|
|
275 break;
|
|
276
|
|
277 default:
|
|
278 if (cpos < nbuf-1)
|
|
279 {
|
|
280 buf[cpos++] = c;
|
|
281
|
|
282 if (c < ' ')
|
|
283 {
|
|
284 (*term.t_putchar)('^');
|
|
285 ++ttcol;
|
|
286 c ^= 0x40;
|
|
287 }
|
|
288
|
|
289 (*term.t_putchar)(c);
|
|
290 ++ttcol;
|
|
291 (*term.t_flush)();
|
|
292 }
|
|
293 }
|
|
294 }
|
|
295 }
|
|
296
|
|
297
|