Mercurial > emacs
comparison src/cm.c @ 91041:bdb3fe0ba9fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Oct 2007 16:22:07 +0000 |
parents | f55f9811f5d7 65663fcd2caa |
children | 606f2d163a64 |
comparison
equal
deleted
inserted
replaced
91040:14c4a6aac623 | 91041:bdb3fe0ba9fa |
---|---|
21 Boston, MA 02110-1301, USA. */ | 21 Boston, MA 02110-1301, USA. */ |
22 | 22 |
23 | 23 |
24 #include <config.h> | 24 #include <config.h> |
25 #include <stdio.h> | 25 #include <stdio.h> |
26 | |
27 #include "lisp.h" | |
28 #include "frame.h" | |
26 #include "cm.h" | 29 #include "cm.h" |
27 #include "termhooks.h" | 30 #include "termhooks.h" |
31 #include "termchar.h" | |
32 | |
28 | 33 |
29 /* For now, don't try to include termcap.h. On some systems, | 34 /* For now, don't try to include termcap.h. On some systems, |
30 configure finds a non-standard termcap.h that the main build | 35 configure finds a non-standard termcap.h that the main build |
31 won't find. */ | 36 won't find. */ |
32 | 37 |
51 { | 56 { |
52 cost++; | 57 cost++; |
53 return c; | 58 return c; |
54 } | 59 } |
55 | 60 |
61 /* The terminal to use for low-level output. */ | |
62 struct tty_display_info *current_tty; | |
63 | |
56 int | 64 int |
57 cmputc (c) | 65 cmputc (c) |
58 char c; | 66 char c; |
59 { | 67 { |
60 if (termscript) | 68 if (current_tty->termscript) |
61 fputc (c & 0177, termscript); | 69 putc (c & 0177, current_tty->termscript); |
62 putchar (c & 0177); | 70 putc (c & 0177, current_tty->output); |
63 return c; | 71 return c; |
64 } | 72 } |
65 | 73 |
66 /* NEXT TWO ARE DONE WITH MACROS */ | 74 /* NEXT TWO ARE DONE WITH MACROS */ |
67 #if 0 | 75 #if 0 |
70 * clearing the screen, when the cursor is at (0, 0), but what the heck, | 78 * clearing the screen, when the cursor is at (0, 0), but what the heck, |
71 * let's let the guy put it anywhere. | 79 * let's let the guy put it anywhere. |
72 */ | 80 */ |
73 | 81 |
74 static | 82 static |
75 at (row, col) { | 83 at (tty, row, col) { |
76 curY = row; | 84 curY (tty) = row; |
77 curX = col; | 85 curX (tty) = col; |
78 } | 86 } |
79 | 87 |
80 /* | 88 /* |
81 * Add n columns to the current cursor position. | 89 * Add n columns to the current cursor position. |
82 */ | 90 */ |
83 | 91 |
84 static | 92 static |
85 addcol (n) { | 93 addcol (tty, n) { |
86 curX += n; | 94 curX (tty) += n; |
87 | 95 |
88 /* | 96 /* |
89 * If cursor hit edge of screen, what happened? | 97 * If cursor hit edge of screen, what happened? |
90 * N.B.: DO NOT!! write past edge of screen. If you do, you | 98 * N.B.: DO NOT!! write past edge of screen. If you do, you |
91 * deserve what you get. Furthermore, on terminals with | 99 * deserve what you get. Furthermore, on terminals with |
92 * autowrap (but not magicwrap), don't write in the last column | 100 * autowrap (but not magicwrap), don't write in the last column |
93 * of the last line. | 101 * of the last line. |
94 */ | 102 */ |
95 | 103 |
96 if (curX == Wcm.cm_cols) { | 104 if (curX (tty) == tty->Wcm->cm_cols) { |
97 /* | 105 /* |
98 * Well, if magicwrap, still there, past the edge of the | 106 * Well, if magicwrap, still there, past the edge of the |
99 * screen (!). If autowrap, on the col 0 of the next line. | 107 * screen (!). If autowrap, on the col 0 of the next line. |
100 * Otherwise on last column. | 108 * Otherwise on last column. |
101 */ | 109 */ |
102 | 110 |
103 if (Wcm.cm_magicwrap) | 111 if (tty->Wcm->cm_magicwrap) |
104 ; /* "limbo" */ | 112 ; /* "limbo" */ |
105 else if (Wcm.cm_autowrap) { | 113 else if (tty->Wcm->cm_autowrap) { |
106 curX = 0; | 114 curX (tty) = 0; |
107 curY++; /* Beware end of screen! */ | 115 curY (tty) ++; /* Beware end of screen! */ |
108 } | 116 } |
109 else | 117 else |
110 curX--; | 118 curX (tty)--; |
111 } | 119 } |
112 } | 120 } |
113 #endif | 121 #endif |
114 | 122 |
115 /* | 123 /* |
121 * in limbo if we use direct cursor addressing from the phantom column. | 129 * in limbo if we use direct cursor addressing from the phantom column. |
122 * The only guaranteed safe thing to do is to emit a CRLF immediately | 130 * The only guaranteed safe thing to do is to emit a CRLF immediately |
123 * after we reach the last column; this takes us to a known state. | 131 * after we reach the last column; this takes us to a known state. |
124 */ | 132 */ |
125 void | 133 void |
126 cmcheckmagic () | 134 cmcheckmagic (struct tty_display_info *tty) |
127 { | 135 { |
128 if (curX == FrameCols) | 136 if (curX (tty) == FrameCols (tty)) |
129 { | 137 { |
130 if (!MagicWrap || curY >= FrameRows - 1) | 138 if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1) |
131 abort (); | 139 abort (); |
132 if (termscript) | 140 if (tty->termscript) |
133 putc ('\r', termscript); | 141 putc ('\r', tty->termscript); |
134 putchar ('\r'); | 142 putc ('\r', tty->output); |
135 if (termscript) | 143 if (tty->termscript) |
136 putc ('\n', termscript); | 144 putc ('\n', tty->termscript); |
137 putchar ('\n'); | 145 putc ('\n', tty->output); |
138 curX = 0; | 146 curX (tty) = 0; |
139 curY++; | 147 curY (tty)++; |
140 } | 148 } |
141 } | 149 } |
142 | 150 |
143 | 151 |
144 /* | 152 /* |
146 * in the variable ospeed. (Note: this holds B300, B9600, etc -- ie stuff | 154 * in the variable ospeed. (Note: this holds B300, B9600, etc -- ie stuff |
147 * out of <sgtty.h>.) | 155 * out of <sgtty.h>.) |
148 */ | 156 */ |
149 | 157 |
150 void | 158 void |
151 cmcostinit () | 159 cmcostinit (struct tty_display_info *tty) |
152 { | 160 { |
153 char *p; | 161 char *p; |
154 | 162 |
155 #define COST(x,e) (x ? (cost = 0, tputs (x, 1, e), cost) : BIG) | 163 #define COST(x,e) (x ? (cost = 0, tputs (x, 1, e), cost) : BIG) |
156 #define CMCOST(x,e) ((x == 0) ? BIG : (p = tgoto(x, 0, 0), COST(p ,e))) | 164 #define CMCOST(x,e) ((x == 0) ? BIG : (p = tgoto(x, 0, 0), COST(p ,e))) |
157 | 165 |
158 Wcm.cc_up = COST (Wcm.cm_up, evalcost); | 166 tty->Wcm->cc_up = COST (tty->Wcm->cm_up, evalcost); |
159 Wcm.cc_down = COST (Wcm.cm_down, evalcost); | 167 tty->Wcm->cc_down = COST (tty->Wcm->cm_down, evalcost); |
160 Wcm.cc_left = COST (Wcm.cm_left, evalcost); | 168 tty->Wcm->cc_left = COST (tty->Wcm->cm_left, evalcost); |
161 Wcm.cc_right = COST (Wcm.cm_right, evalcost); | 169 tty->Wcm->cc_right = COST (tty->Wcm->cm_right, evalcost); |
162 Wcm.cc_home = COST (Wcm.cm_home, evalcost); | 170 tty->Wcm->cc_home = COST (tty->Wcm->cm_home, evalcost); |
163 Wcm.cc_cr = COST (Wcm.cm_cr, evalcost); | 171 tty->Wcm->cc_cr = COST (tty->Wcm->cm_cr, evalcost); |
164 Wcm.cc_ll = COST (Wcm.cm_ll, evalcost); | 172 tty->Wcm->cc_ll = COST (tty->Wcm->cm_ll, evalcost); |
165 Wcm.cc_tab = Wcm.cm_tabwidth ? COST (Wcm.cm_tab, evalcost) : BIG; | 173 tty->Wcm->cc_tab = tty->Wcm->cm_tabwidth ? COST (tty->Wcm->cm_tab, evalcost) : BIG; |
166 | 174 |
167 /* | 175 /* |
168 * These last three are actually minimum costs. When (if) they are | 176 * These last three are actually minimum costs. When (if) they are |
169 * candidates for the least-cost motion, the real cost is computed. | 177 * candidates for the least-cost motion, the real cost is computed. |
170 * (Note that "0" is the assumed to generate the minimum cost. | 178 * (Note that "0" is the assumed to generate the minimum cost. |
171 * While this is not necessarily true, I have yet to see a terminal | 179 * While this is not necessarily true, I have yet to see a terminal |
172 * for which is not; all the terminals that have variable-cost | 180 * for which is not; all the terminals that have variable-cost |
173 * cursor motion seem to take straight numeric values. --ACT) | 181 * cursor motion seem to take straight numeric values. --ACT) |
174 */ | 182 */ |
175 | 183 |
176 Wcm.cc_abs = CMCOST (Wcm.cm_abs, evalcost); | 184 tty->Wcm->cc_abs = CMCOST (tty->Wcm->cm_abs, evalcost); |
177 Wcm.cc_habs = CMCOST (Wcm.cm_habs, evalcost); | 185 tty->Wcm->cc_habs = CMCOST (tty->Wcm->cm_habs, evalcost); |
178 Wcm.cc_vabs = CMCOST (Wcm.cm_vabs, evalcost); | 186 tty->Wcm->cc_vabs = CMCOST (tty->Wcm->cm_vabs, evalcost); |
179 | 187 |
180 #undef CMCOST | 188 #undef CMCOST |
181 #undef COST | 189 #undef COST |
182 } | 190 } |
183 | 191 |
186 * up and down, and left and right, motions, and tabs. If doit is set | 194 * up and down, and left and right, motions, and tabs. If doit is set |
187 * actually perform the motion. | 195 * actually perform the motion. |
188 */ | 196 */ |
189 | 197 |
190 static int | 198 static int |
191 calccost (srcy, srcx, dsty, dstx, doit) | 199 calccost (struct tty_display_info *tty, |
192 int srcy, srcx, dsty, dstx, doit; | 200 int srcy, int srcx, int dsty, int dstx, int doit) |
193 { | 201 { |
194 register int deltay, | 202 register int deltay, |
195 deltax, | 203 deltax, |
196 c, | 204 c, |
197 totalcost; | 205 totalcost; |
204 | 212 |
205 /* If have just wrapped on a terminal with xn, | 213 /* If have just wrapped on a terminal with xn, |
206 don't believe the cursor position: give up here | 214 don't believe the cursor position: give up here |
207 and force use of absolute positioning. */ | 215 and force use of absolute positioning. */ |
208 | 216 |
209 if (curX == Wcm.cm_cols) | 217 if (curX (tty) == tty->Wcm->cm_cols) |
210 goto fail; | 218 goto fail; |
211 | 219 |
212 totalcost = 0; | 220 totalcost = 0; |
213 if ((deltay = dsty - srcy) == 0) | 221 if ((deltay = dsty - srcy) == 0) |
214 goto x; | 222 goto x; |
215 if (deltay < 0) | 223 if (deltay < 0) |
216 p = Wcm.cm_up, c = Wcm.cc_up, deltay = -deltay; | 224 p = tty->Wcm->cm_up, c = tty->Wcm->cc_up, deltay = -deltay; |
217 else | 225 else |
218 p = Wcm.cm_down, c = Wcm.cc_down; | 226 p = tty->Wcm->cm_down, c = tty->Wcm->cc_down; |
219 if (c == BIG) { /* caint get thar from here */ | 227 if (c == BIG) { /* caint get thar from here */ |
220 if (doit) | 228 if (doit) |
221 printf ("OOPS"); | 229 printf ("OOPS"); |
222 return c; | 230 return c; |
223 } | 231 } |
224 totalcost = c * deltay; | 232 totalcost = c * deltay; |
225 if (doit) | 233 if (doit) |
226 while (--deltay >= 0) | 234 while (--deltay >= 0) |
227 tputs (p, 1, cmputc); | 235 emacs_tputs (tty, p, 1, cmputc); |
228 x: | 236 x: |
229 if ((deltax = dstx - srcx) == 0) | 237 if ((deltax = dstx - srcx) == 0) |
230 goto done; | 238 goto done; |
231 if (deltax < 0) { | 239 if (deltax < 0) { |
232 p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; | 240 p = tty->Wcm->cm_left, c = tty->Wcm->cc_left, deltax = -deltax; |
233 goto dodelta; /* skip all the tab junk */ | 241 goto dodelta; /* skip all the tab junk */ |
234 } | 242 } |
235 /* Tabs (the toughie) */ | 243 /* Tabs (the toughie) */ |
236 if (Wcm.cc_tab >= BIG || !Wcm.cm_usetabs) | 244 if (tty->Wcm->cc_tab >= BIG || !tty->Wcm->cm_usetabs) |
237 goto olddelta; /* forget it! */ | 245 goto olddelta; /* forget it! */ |
238 | 246 |
239 /* | 247 /* |
240 * ntabs is # tabs towards but not past dstx; n2tabs is one more | 248 * ntabs is # tabs towards but not past dstx; n2tabs is one more |
241 * (ie past dstx), but this is only valid if that is not past the | 249 * (ie past dstx), but this is only valid if that is not past the |
242 * right edge of the screen. We can check that at the same time | 250 * right edge of the screen. We can check that at the same time |
243 * as we figure out where we would be if we use the tabs (which | 251 * as we figure out where we would be if we use the tabs (which |
244 * we will put into tabx (for ntabs) and tab2x (for n2tabs)). | 252 * we will put into tabx (for ntabs) and tab2x (for n2tabs)). |
245 */ | 253 */ |
246 | 254 |
247 ntabs = (deltax + srcx % Wcm.cm_tabwidth) / Wcm.cm_tabwidth; | 255 ntabs = (deltax + srcx % tty->Wcm->cm_tabwidth) / tty->Wcm->cm_tabwidth; |
248 n2tabs = ntabs + 1; | 256 n2tabs = ntabs + 1; |
249 tabx = (srcx / Wcm.cm_tabwidth + ntabs) * Wcm.cm_tabwidth; | 257 tabx = (srcx / tty->Wcm->cm_tabwidth + ntabs) * tty->Wcm->cm_tabwidth; |
250 tab2x = tabx + Wcm.cm_tabwidth; | 258 tab2x = tabx + tty->Wcm->cm_tabwidth; |
251 | 259 |
252 if (tab2x >= Wcm.cm_cols) /* too far (past edge) */ | 260 if (tab2x >= tty->Wcm->cm_cols) /* too far (past edge) */ |
253 n2tabs = 0; | 261 n2tabs = 0; |
254 | 262 |
255 /* | 263 /* |
256 * Now set tabcost to the cost for using ntabs, and c to the cost | 264 * Now set tabcost to the cost for using ntabs, and c to the cost |
257 * for using n2tabs, then pick the minimum. | 265 * for using n2tabs, then pick the minimum. |
258 */ | 266 */ |
259 | 267 |
260 /* cost for ntabs + cost for right motion */ | 268 /* cost for ntabs + cost for right motion */ |
261 tabcost = ntabs ? ntabs * Wcm.cc_tab + (dstx - tabx) * Wcm.cc_right | 269 tabcost = ntabs ? ntabs * tty->Wcm->cc_tab + (dstx - tabx) * tty->Wcm->cc_right |
262 : BIG; | 270 : BIG; |
263 | 271 |
264 /* cost for n2tabs + cost for left motion */ | 272 /* cost for n2tabs + cost for left motion */ |
265 c = n2tabs ? n2tabs * Wcm.cc_tab + (tab2x - dstx) * Wcm.cc_left | 273 c = n2tabs ? n2tabs * tty->Wcm->cc_tab + (tab2x - dstx) * tty->Wcm->cc_left |
266 : BIG; | 274 : BIG; |
267 | 275 |
268 if (c < tabcost) /* then cheaper to overshoot & back up */ | 276 if (c < tabcost) /* then cheaper to overshoot & back up */ |
269 ntabs = n2tabs, tabcost = c, tabx = tab2x; | 277 ntabs = n2tabs, tabcost = c, tabx = tab2x; |
270 | 278 |
273 | 281 |
274 /* | 282 /* |
275 * See if tabcost is less than just moving right | 283 * See if tabcost is less than just moving right |
276 */ | 284 */ |
277 | 285 |
278 if (tabcost < (deltax * Wcm.cc_right)) { | 286 if (tabcost < (deltax * tty->Wcm->cc_right)) { |
279 totalcost += tabcost; /* use the tabs */ | 287 totalcost += tabcost; /* use the tabs */ |
280 if (doit) | 288 if (doit) |
281 while (--ntabs >= 0) | 289 while (--ntabs >= 0) |
282 tputs (Wcm.cm_tab, 1, cmputc); | 290 emacs_tputs (tty, tty->Wcm->cm_tab, 1, cmputc); |
283 srcx = tabx; | 291 srcx = tabx; |
284 } | 292 } |
285 | 293 |
286 /* | 294 /* |
287 * Now might as well just recompute the delta. | 295 * Now might as well just recompute the delta. |
290 newdelta: | 298 newdelta: |
291 if ((deltax = dstx - srcx) == 0) | 299 if ((deltax = dstx - srcx) == 0) |
292 goto done; | 300 goto done; |
293 olddelta: | 301 olddelta: |
294 if (deltax > 0) | 302 if (deltax > 0) |
295 p = Wcm.cm_right, c = Wcm.cc_right; | 303 p = tty->Wcm->cm_right, c = tty->Wcm->cc_right; |
296 else | 304 else |
297 p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; | 305 p = tty->Wcm->cm_left, c = tty->Wcm->cc_left, deltax = -deltax; |
298 | 306 |
299 dodelta: | 307 dodelta: |
300 if (c == BIG) { /* caint get thar from here */ | 308 if (c == BIG) { /* caint get thar from here */ |
301 fail: | 309 fail: |
302 if (doit) | 310 if (doit) |
304 return BIG; | 312 return BIG; |
305 } | 313 } |
306 totalcost += c * deltax; | 314 totalcost += c * deltax; |
307 if (doit) | 315 if (doit) |
308 while (--deltax >= 0) | 316 while (--deltax >= 0) |
309 tputs (p, 1, cmputc); | 317 emacs_tputs (tty, p, 1, cmputc); |
310 done: | 318 done: |
311 return totalcost; | 319 return totalcost; |
312 } | 320 } |
313 | 321 |
314 #if 0 | 322 #if 0 |
322 #define USEHOME 1 | 330 #define USEHOME 1 |
323 #define USELL 2 | 331 #define USELL 2 |
324 #define USECR 3 | 332 #define USECR 3 |
325 | 333 |
326 void | 334 void |
327 cmgoto (row, col) | 335 cmgoto (tty, row, col) |
336 struct tty_display_info *tty; | |
328 int row, col; | 337 int row, col; |
329 { | 338 { |
330 int homecost, | 339 int homecost, |
331 crcost, | 340 crcost, |
332 llcost, | 341 llcost, |
335 int use; | 344 int use; |
336 char *p, | 345 char *p, |
337 *dcm; | 346 *dcm; |
338 | 347 |
339 /* First the degenerate case */ | 348 /* First the degenerate case */ |
340 if (row == curY && col == curX) /* already there */ | 349 if (row == curY (tty) && col == curX (tty)) /* already there */ |
341 return; | 350 return; |
342 | 351 |
343 if (curY >= 0 && curX >= 0) | 352 if (curY (tty) >= 0 && curX (tty) >= 0) |
344 { | 353 { |
345 /* We may have quick ways to go to the upper-left, bottom-left, | 354 /* We may have quick ways to go to the upper-left, bottom-left, |
346 * start-of-line, or start-of-next-line. Or it might be best to | 355 * start-of-line, or start-of-next-line. Or it might be best to |
347 * start where we are. Examine the options, and pick the cheapest. | 356 * start where we are. Examine the options, and pick the cheapest. |
348 */ | 357 */ |
349 | 358 |
350 relcost = calccost (curY, curX, row, col, 0); | 359 relcost = calccost (tty, curY (tty), curX (tty), row, col, 0); |
351 use = USEREL; | 360 use = USEREL; |
352 if ((homecost = Wcm.cc_home) < BIG) | 361 if ((homecost = tty->Wcm->cc_home) < BIG) |
353 homecost += calccost (0, 0, row, col, 0); | 362 homecost += calccost (tty, 0, 0, row, col, 0); |
354 if (homecost < relcost) | 363 if (homecost < relcost) |
355 relcost = homecost, use = USEHOME; | 364 relcost = homecost, use = USEHOME; |
356 if ((llcost = Wcm.cc_ll) < BIG) | 365 if ((llcost = tty->Wcm->cc_ll) < BIG) |
357 llcost += calccost (Wcm.cm_rows - 1, 0, row, col, 0); | 366 llcost += calccost (tty, tty->Wcm->cm_rows - 1, 0, row, col, 0); |
358 if (llcost < relcost) | 367 if (llcost < relcost) |
359 relcost = llcost, use = USELL; | 368 relcost = llcost, use = USELL; |
360 if ((crcost = Wcm.cc_cr) < BIG) { | 369 if ((crcost = tty->Wcm->cc_cr) < BIG) { |
361 if (Wcm.cm_autolf) | 370 if (tty->Wcm->cm_autolf) |
362 if (curY + 1 >= Wcm.cm_rows) | 371 if (curY (tty) + 1 >= tty->Wcm->cm_rows) |
363 crcost = BIG; | 372 crcost = BIG; |
364 else | 373 else |
365 crcost += calccost (curY + 1, 0, row, col, 0); | 374 crcost += calccost (tty, curY (tty) + 1, 0, row, col, 0); |
366 else | 375 else |
367 crcost += calccost (curY, 0, row, col, 0); | 376 crcost += calccost (tty, curY (tty), 0, row, col, 0); |
368 } | 377 } |
369 if (crcost < relcost) | 378 if (crcost < relcost) |
370 relcost = crcost, use = USECR; | 379 relcost = crcost, use = USECR; |
371 directcost = Wcm.cc_abs, dcm = Wcm.cm_abs; | 380 directcost = tty->Wcm->cc_abs, dcm = tty->Wcm->cm_abs; |
372 if (row == curY && Wcm.cc_habs < BIG) | 381 if (row == curY (tty) && tty->Wcm->cc_habs < BIG) |
373 directcost = Wcm.cc_habs, dcm = Wcm.cm_habs; | 382 directcost = tty->Wcm->cc_habs, dcm = tty->Wcm->cm_habs; |
374 else if (col == curX && Wcm.cc_vabs < BIG) | 383 else if (col == curX (tty) && tty->Wcm->cc_vabs < BIG) |
375 directcost = Wcm.cc_vabs, dcm = Wcm.cm_vabs; | 384 directcost = tty->Wcm->cc_vabs, dcm = tty->Wcm->cm_vabs; |
376 } | 385 } |
377 else | 386 else |
378 { | 387 { |
379 directcost = 0, relcost = 100000; | 388 directcost = 0, relcost = 100000; |
380 dcm = Wcm.cm_abs; | 389 dcm = tty->Wcm->cm_abs; |
381 } | 390 } |
382 | 391 |
383 /* | 392 /* |
384 * In the following comparison, the = in <= is because when the costs | 393 * In the following comparison, the = in <= is because when the costs |
385 * are the same, it looks nicer (I think) to move directly there. | 394 * are the same, it looks nicer (I think) to move directly there. |
386 */ | 395 */ |
387 if (directcost <= relcost) | 396 if (directcost <= relcost) |
388 { | 397 { |
389 /* compute REAL direct cost */ | 398 /* compute REAL direct cost */ |
390 cost = 0; | 399 cost = 0; |
391 p = dcm == Wcm.cm_habs ? tgoto (dcm, row, col) : | 400 p = (dcm == tty->Wcm->cm_habs |
392 tgoto (dcm, col, row); | 401 ? tgoto (dcm, row, col) |
393 tputs (p, 1, evalcost); | 402 : tgoto (dcm, col, row)); |
403 emacs_tputs (tty, p, 1, evalcost); | |
394 if (cost <= relcost) | 404 if (cost <= relcost) |
395 { /* really is cheaper */ | 405 { /* really is cheaper */ |
396 tputs (p, 1, cmputc); | 406 emacs_tputs (tty, p, 1, cmputc); |
397 curY = row, curX = col; | 407 curY (tty) = row, curX (tty) = col; |
398 return; | 408 return; |
399 } | 409 } |
400 } | 410 } |
401 | 411 |
402 switch (use) | 412 switch (use) |
403 { | 413 { |
404 case USEHOME: | 414 case USEHOME: |
405 tputs (Wcm.cm_home, 1, cmputc); | 415 emacs_tputs (tty, tty->Wcm->cm_home, 1, cmputc); |
406 curY = 0, curX = 0; | 416 curY (tty) = 0, curX (tty) = 0; |
407 break; | 417 break; |
408 | 418 |
409 case USELL: | 419 case USELL: |
410 tputs (Wcm.cm_ll, 1, cmputc); | 420 emacs_tputs (tty, tty->Wcm->cm_ll, 1, cmputc); |
411 curY = Wcm.cm_rows - 1, curX = 0; | 421 curY (tty) = tty->Wcm->cm_rows - 1, curX (tty) = 0; |
412 break; | 422 break; |
413 | 423 |
414 case USECR: | 424 case USECR: |
415 tputs (Wcm.cm_cr, 1, cmputc); | 425 emacs_tputs (tty, tty->Wcm->cm_cr, 1, cmputc); |
416 if (Wcm.cm_autolf) | 426 if (tty->Wcm->cm_autolf) |
417 curY++; | 427 curY (tty)++; |
418 curX = 0; | 428 curX (tty) = 0; |
419 break; | 429 break; |
420 } | 430 } |
421 | 431 |
422 (void) calccost (curY, curX, row, col, 1); | 432 (void) calccost (tty, curY (tty), curX (tty), row, col, 1); |
423 curY = row, curX = col; | 433 curY (tty) = row, curX (tty) = col; |
424 } | 434 } |
425 | 435 |
426 /* Clear out all terminal info. | 436 /* Clear out all terminal info. |
427 Used before copying into it the info on the actual terminal. | 437 Used before copying into it the info on the actual terminal. |
428 */ | 438 */ |
429 | 439 |
430 void | 440 void |
431 Wcm_clear () | 441 Wcm_clear (struct tty_display_info *tty) |
432 { | 442 { |
433 bzero (&Wcm, sizeof Wcm); | 443 bzero (tty->Wcm, sizeof (struct cm)); |
434 UP = 0; | 444 UP = 0; |
435 BC = 0; | 445 BC = 0; |
436 } | 446 } |
437 | 447 |
438 /* | 448 /* |
441 * Return -1 if cannot. | 451 * Return -1 if cannot. |
442 * Return -2 if size not specified. | 452 * Return -2 if size not specified. |
443 */ | 453 */ |
444 | 454 |
445 int | 455 int |
446 Wcm_init () | 456 Wcm_init (struct tty_display_info *tty) |
447 { | 457 { |
448 #if 0 | 458 #if 0 |
449 if (Wcm.cm_abs && !Wcm.cm_ds) | 459 if (tty->Wcm->cm_abs && !tty->Wcm->cm_ds) |
450 return 0; | 460 return 0; |
451 #endif | 461 #endif |
452 if (Wcm.cm_abs) | 462 if (tty->Wcm->cm_abs) |
453 return 0; | 463 return 0; |
454 /* Require up and left, and, if no absolute, down and right */ | 464 /* Require up and left, and, if no absolute, down and right */ |
455 if (!Wcm.cm_up || !Wcm.cm_left) | 465 if (!tty->Wcm->cm_up || !tty->Wcm->cm_left) |
456 return - 1; | 466 return - 1; |
457 if (!Wcm.cm_abs && (!Wcm.cm_down || !Wcm.cm_right)) | 467 if (!tty->Wcm->cm_abs && (!tty->Wcm->cm_down || !tty->Wcm->cm_right)) |
458 return - 1; | 468 return - 1; |
459 /* Check that we know the size of the screen.... */ | 469 /* Check that we know the size of the screen.... */ |
460 if (Wcm.cm_rows <= 0 || Wcm.cm_cols <= 0) | 470 if (tty->Wcm->cm_rows <= 0 || tty->Wcm->cm_cols <= 0) |
461 return - 2; | 471 return - 2; |
462 return 0; | 472 return 0; |
463 } | 473 } |
464 | 474 |
465 /* arch-tag: bcf64c02-00f6-44ef-94b6-c56eab5b3dc4 | 475 /* arch-tag: bcf64c02-00f6-44ef-94b6-c56eab5b3dc4 |