annotate src/cm.c @ 5707:5fd1b9a95531

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