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 /*
|
|
18 * Write a message into the message line. Keep track of the physical cursor
|
|
19 * position. A small class of printf like format items is handled.
|
|
20 * This routine is probably one of the lease portable.
|
|
21 * Assumes all arguments (with the possible exception of the first) are passed
|
|
22 * in the order expected on a downward growing stack without addtional
|
|
23 * padding; this assumption is made by the "++" in the
|
|
24 * argument scan loop. It works for the two or less argument case
|
|
25 * on OSK despite the fact the first two arguments are passed in registers.
|
|
26 * Set the "message line" flag TRUE.
|
|
27 */
|
|
28 mlwrite(fmt, arg)
|
|
29 char *fmt;
|
|
30 {
|
|
31 register int c;
|
|
32 register char *ap;
|
|
33
|
|
34 movecursor(term.t_nrow, 0);
|
|
35 ap = (char *) &arg;
|
|
36 while ((c = *fmt++) != 0) {
|
|
37 if (c != '%') {
|
|
38 (*term.t_putchar)(c);
|
|
39 ++ttcol;
|
|
40 }
|
|
41 else
|
|
42 {
|
|
43 c = *fmt++;
|
|
44 switch (c) {
|
|
45 case 'd':
|
|
46 mlputi(*(int *)ap, 10);
|
|
47 ap += sizeof(int);
|
|
48 break;
|
|
49
|
|
50 case 'o':
|
|
51 mlputi(*(int *)ap, 8);
|
|
52 ap += sizeof(int);
|
|
53 break;
|
|
54
|
|
55 case 'x':
|
|
56 mlputi(*(int *)ap, 16);
|
|
57 ap += sizeof(int);
|
|
58 break;
|
|
59
|
|
60 case 'D': /* this is %ld on many printf impleminations */
|
|
61 mlputli(*(long *)ap, 10);
|
|
62 ap += sizeof(long);
|
|
63 break;
|
|
64
|
|
65 case 's':
|
|
66 mlputs(*(char **)ap);
|
|
67 ap += sizeof(char *);
|
|
68 break;
|
|
69
|
|
70 default:
|
|
71 (*term.t_putchar)(c);
|
|
72 ++ttcol;
|
|
73 }
|
|
74 }
|
|
75 }
|
|
76 (*term.t_eeol)();
|
|
77 (*term.t_flush)();
|
|
78 mpresf = TRUE;
|
|
79 }
|
|
80
|
|
81 /*
|
|
82 * Write out a string. Update the physical cursor position. This assumes that
|
|
83 * the characters in the string all have width "1"; if this is not the case
|
|
84 * things will get screwed up a little.
|
|
85 */
|
|
86 mlputs(s)
|
|
87 char *s;
|
|
88 {
|
|
89 register int c;
|
|
90
|
|
91 while ((c = *s++) != 0)
|
|
92 {
|
|
93 (*term.t_putchar)(c);
|
|
94 ++ttcol;
|
|
95 }
|
|
96 }
|
|
97
|
|
98 /*
|
|
99 * Write out an integer, in the specified radix. Update the physical cursor
|
|
100 * position. This will not handle any negative numbers; maybe it should.
|
|
101 */
|
|
102 mlputi(i, r)
|
|
103 {
|
|
104 register int q;
|
|
105 static char hexdigits[] = "0123456789ABCDEF";
|
|
106
|
|
107 if (i < 0)
|
|
108 {
|
|
109 i = -i;
|
|
110 (*term.t_putchar)('-');
|
|
111 }
|
|
112
|
|
113 q = i/r;
|
|
114
|
|
115 if (q != 0)
|
|
116 mlputi(q, r);
|
|
117
|
|
118 (*term.t_putchar)(hexdigits[i%r]);
|
|
119 ++ttcol;
|
|
120 }
|
|
121
|
|
122 /*
|
|
123 * do the same except as a long integer.
|
|
124 */
|
|
125 mlputli(l, r)
|
|
126 long l;
|
|
127 {
|
|
128 register long q;
|
|
129
|
|
130 if (l < 0)
|
|
131 {
|
|
132 l = -l;
|
|
133 (*term.t_putchar)('-');
|
|
134 }
|
|
135
|
|
136 q = l/r;
|
|
137
|
|
138 if (q != 0)
|
|
139 mlputli(q, r);
|
|
140
|
|
141 (*term.t_putchar)((int)(l%r)+'0');
|
|
142 ++ttcol;
|
|
143 }
|
|
144
|
|
145 #ifdef RAINBOW
|
|
146
|
|
147 putline(row, col, buf)
|
|
148 int row, col;
|
|
149 char buf[];
|
|
150 {
|
|
151 int n;
|
|
152
|
|
153 n = strlen(buf);
|
|
154 if (col + n - 1 > term.t_ncol)
|
|
155 n = term.t_ncol - col + 1;
|
|
156 Put_Data(row, col, n, buf);
|
|
157 }
|
|
158 #endif
|
|
159
|
|
160
|