annotate src/cm.c @ 314:341dac730539 r21-0b55

Import from CVS: tag r21-0b55
author cvs
date Mon, 13 Aug 2007 10:44:22 +0200
parents c5d627a313b1
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Cursor motion subroutines for XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 loosely based primarily on public domain code written by Chris Torek
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: FSF 19.30. Substantially different from FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* #### This file is extremely junky and needs major fixup. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "console-tty.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "lstream.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #define EXPENSIVE 2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
36 #ifdef __cplusplus
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
37 extern "C" {
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
38 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 extern char *tgoto (CONST char *cm, int hpos, int vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 extern void tputs (CONST char *, int, void (*)(int));
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
41 #ifdef __cplusplus
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
42 }
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
43 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 static void cmgoto_for_real (struct console *c, int row, int col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 static int cm_cost_counter; /* sums up costs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
49 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 evalcost (int c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 cm_cost_counter++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 /* Ugh -- cmputc() can't take a console argument, so we pass it in a global */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 struct console *cmputc_console;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 send_string_to_tty_console (struct console *c, unsigned char *str, int len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* #### Ben sez: don't some terminals need nulls outputted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 for proper timing? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Lstream *lstr = XLSTREAM (CONSOLE_TTY_DATA (c)->outstream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 if (CONSOLE_TTY_REAL_CURSOR_X (c) != CONSOLE_TTY_CURSOR_X (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 || CONSOLE_TTY_REAL_CURSOR_Y (c) != CONSOLE_TTY_CURSOR_Y (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 int row = CONSOLE_TTY_CURSOR_Y (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 int col = CONSOLE_TTY_CURSOR_X (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 cmgoto_for_real (c, row, col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 if (len == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Lstream_putc (lstr, *str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 else if (len > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Lstream_write (lstr, str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 cmputc (int c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 unsigned char ch = (unsigned char) c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 if (termscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 fputc (c, termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 send_string_to_tty_console (cmputc_console, &ch, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 * Terminals with magicwrap (xn) don't all behave identically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 * The VT100 leaves the cursor in the last column but will wrap before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 * printing the next character. I hear that the Concept terminal does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 * the wrap immediately but ignores the next newline it sees. And some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 * terminals just have buggy firmware, and think that the cursor is still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 * in limbo if we use direct cursor addressing from the phantom column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 * The only guaranteed safe thing to do is to emit a CRLF immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 * after we reach the last column; this takes us to a known state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 cmcheckmagic (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 if (curX == FrameCols)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (!MagicWrap || curY >= FrameRows - 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 if (termscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 putc ('\r', termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 putchar ('\r');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 if (termscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 putc ('\n', termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 putchar ('\n');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 curX = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 curY++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 * (Re)Initialize the cost factors, given the output speed of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 * terminal in DEVICE_TTY_DATA (dev)->ospeed. (Note: this holds B300,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 * B9600, etc -- ie stuff out of <sgtty.h>.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 cm_cost_init (struct console *c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 char *tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 cm_cost_counter = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 #define COST(x,e) (x \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ? (cm_cost_counter = 0, tputs (x, 1, e), cm_cost_counter) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 : EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #define MINCOST(x,e) ((x == 0) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ? EXPENSIVE \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 : (tmp = tgoto(x, 0, 0), COST(tmp,e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 TTY_COST (c).cm_up = COST (TTY_CM (c).up, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 TTY_COST (c).cm_down = COST (TTY_CM (c).down, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 TTY_COST (c).cm_left = COST (TTY_CM (c).left, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 TTY_COST (c).cm_right = COST (TTY_CM (c).right, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 TTY_COST (c).cm_home = COST (TTY_CM (c).home, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 TTY_COST (c).cm_low_left = COST (TTY_CM (c).low_left, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 TTY_COST (c).cm_car_return = COST (TTY_CM (c).car_return, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 * These last three are actually minimum costs. When (if) they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 * candidates for the least-cost motion, the real cost is computed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 * (Note that "0" is the assumed to generate the minimum cost.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 * While this is not necessarily true, I have yet to see a terminal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 * for which is not; all the terminals that have variable-cost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 * cursor motion seem to take straight numeric values. --ACT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 TTY_COST (c).cm_abs = MINCOST (TTY_CM (c).abs, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 TTY_COST (c).cm_hor_abs = MINCOST (TTY_CM (c).hor_abs, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 TTY_COST (c).cm_ver_abs = MINCOST (TTY_CM (c).ver_abs, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 #undef MINCOST
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 #undef COST
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 * Calculate the cost to move from (srcy, srcx) to (dsty, dstx) using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 * up and down, and left and right, and motions. If doit is set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 * actually perform the motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 #ifdef NOT_YET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 calccost (struct frame *f, int srcy, int srcx, int dsty, int dstx, int doit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 struct console *c = XCONSOLE (FRAME_CONSOLE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 int totalcost = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 int deltay, deltax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 char *motion;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 int motion_cost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 int ntabs, n2tabs, tabx, tab2x, tabcost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 cmputc_console = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 /* If have just wrapped on a terminal with xn,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 don't believe the cursor position: give up here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 and force use of absolute positioning. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 if (curX == Wcm.cm_cols)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 goto fail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 deltay = dsty - srcy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 if (!deltay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 goto calculate_x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 if (deltay < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 motion = TTY_CM (c).up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 motion_cost = TTY_COST (c).cm_up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 deltay = -deltay;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 motion = TTY_CM (c).down;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 motion_cost = TTY_COST (c).cm_down;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 if (motion_cost == EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 /* if (doit) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 /* #### printing OOF is not acceptable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 return motion_cost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 totalcost = motion_cost * deltay;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 if (doit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 while (--deltay >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 tputs (motion, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
223 calculate_x:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 deltax = dstx - srcx;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 if (!deltax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 goto done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 if (deltax < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 motion = TTY_CM (c).left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 motion_cost = TTY_COST (c).cm_left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 deltax = -deltax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 motion = TTY_CM (c).right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 motion_cost = TTY_COST (c).cm_right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 if (motion_cost == EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 /* if (doit) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 /* #### printing OOF is not acceptable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 return motion_cost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 totalcost += motion_cost * deltax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (doit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 while (--deltax >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 tputs (motion, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
254 done:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 return totalcost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 #endif /* NOT_YET */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 #define USEREL 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 #define USEHOME 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 #define USELL 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 #define USECR 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 #if OLD_CURSOR_MOTION_SHIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 cmgoto (struct frame *f, int row, int col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 struct console *c = XCONSOLE (FRAME_CONSOLE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 char *motion;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 int frame_x = FRAME_CURSOR_X(f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 int frame_y = FRAME_CURSOR_Y(f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 int relcost, directcost, llcost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 int homecost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 int use;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 char *dcm;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 cmputc_console = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 /* First the degenerate case */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 if (row == frame_y && col == frame_x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 /* #### something is fucked with the non-absolute cases */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 motion = tgoto (TTY_CM (c).abs, col, row);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 tputs (motion, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 CONSOLE_TTY_DATA (c)->cursor_x = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 CONSOLE_TTY_DATA (c)->cursor_y = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 if (frame_y >= 0 && frame_x >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
297 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 * Pick least-cost motions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 relcost = calccost (f, frame_y, frame_x, row, col, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 use = USEREL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 homecost = TTY_COST (c).cm_home;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 if (homecost < EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 homecost += calccost (f, 0, 0, row, col, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 if (homecost < relcost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 relcost = homecost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 use = USEHOME;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 llcost = TTY_COST (c).cm_low_left;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 if (llcost < EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 llcost += calccost (f, frame_y - 1, 0, row, col, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 if (llcost < relcost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 relcost = llcost;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 use = USELL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 if ((crcost = Wcm.cc_cr) < BIG) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 if (Wcm.cm_autolf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 if (curY + 1 >= Wcm.cm_rows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 crcost = BIG;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 crcost += calccost (curY + 1, 0, row, col, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 crcost += calccost (curY, 0, row, col, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 if (crcost < relcost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 relcost = crcost, use = USECR;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 directcost = TTY_COST (c).cm_abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 dcm = TTY_CM (c).abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 if (row == frame_y && TTY_COST (c).cm_hor_abs < EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 directcost = TTY_COST (c).cm_hor_abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 dcm = TTY_CM (c).hor_abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 else if (col == frame_x && TTY_COST (c).cm_ver_abs < EXPENSIVE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 directcost = TTY_COST (c).cm_ver_abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 dcm = TTY_CM (c).ver_abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 directcost = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 relcost = 100000;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 dcm = TTY_CM (c).abs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
359 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 * In the following comparison, the = in <= is because when the costs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 * are the same, it looks nicer (I think) to move directly there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 if (directcost <= relcost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 /* compute REAL direct cost */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 cm_cost_counter = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 motion = (dcm == TTY_CM (c).hor_abs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ? tgoto (dcm, row, col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 : tgoto (dcm, col, row));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 tputs (motion, 1, evalcost);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 if (cm_cost_counter <= relcost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 { /* really is cheaper */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 tputs (motion, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 FRAME_CURSOR_Y (f) = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 FRAME_CURSOR_X (f) = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 switch (use)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
382 case USEHOME:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 tputs (TTY_CM (c).home, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 FRAME_CURSOR_X (f) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 FRAME_CURSOR_Y (f) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
388 case USELL:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 tputs (TTY_CM (c).low_left, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 FRAME_CURSOR_Y (f) = FRAME_HEIGHT (f) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 FRAME_CURSOR_X (f) = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 #if 0
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
395 case USECR:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 tputs (Wcm.cm_cr, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 if (Wcm.cm_autolf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 curY++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 curX = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 0
diff changeset
404 calccost (f, FRAME_CURSOR_Y (f), FRAME_CURSOR_X (f), row, col, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 FRAME_CURSOR_Y (f) = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 FRAME_CURSOR_X (f) = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 #endif /* OLD_CURSOR_MOTION_SHIT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 cmgoto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 This function is responsible for getting the cursor from its current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 location to the passed location in the most efficient manner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 cmgoto_for_real (struct console *c, int row, int col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 char *motion;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 cmputc_console = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 /* First make sure that we actually have to do any work at all. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 if (CONSOLE_TTY_REAL_CURSOR_X (c) == col
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 && CONSOLE_TTY_REAL_CURSOR_Y (c) == row)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 CONSOLE_TTY_REAL_CURSOR_X (c) = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 CONSOLE_TTY_REAL_CURSOR_Y (c) = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 /* #### Need to reimplement cost analysis and potential relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 movement. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 /* If all else fails, use absolute movement. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 motion = tgoto (TTY_CM (c).abs, col, row);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 tputs (motion, 1, cmputc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 CONSOLE_TTY_CURSOR_X (c) = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 CONSOLE_TTY_CURSOR_Y (c) = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 cmgoto (struct frame *f, int row, int col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 /* We delay cursor motion until we do something other than cursor motion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 to optimize the case where cmgoto() is called twice in a row. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 struct console *c = XCONSOLE (FRAME_CONSOLE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 CONSOLE_TTY_CURSOR_X (c) = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 CONSOLE_TTY_CURSOR_Y (c) = row;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 /* Clear out all terminal info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 Used before copying into it the info on the actual terminal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 Wcm_clear (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
461 xzero (Wcm);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 UP = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 BC = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 * Initialized stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 * Return 0 if can do CM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 * Return -1 if cannot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 * Return -2 if size not specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 Wcm_init (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 if (Wcm.cm_abs && !Wcm.cm_ds)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 if (Wcm.cm_abs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 /* Require up and left, and, if no absolute, down and right */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 if (!Wcm.cm_up || !Wcm.cm_left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 return - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 if (!Wcm.cm_abs && (!Wcm.cm_down || !Wcm.cm_right))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 return - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 /* Check that we know the size of the frame.... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 if (Wcm.cm_rows <= 0 || Wcm.cm_cols <= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 return - 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 #endif