annotate src/cm.c @ 185:3d6bfa290dbd r20-3b19

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