annotate src/cm.c @ 2039:fd0cbe945410

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