annotate src/cm.c @ 158:558dfa75ffb3

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