1 /* Cursor motion calculation definitions for GNU Emacs
2 Copyright (C) 1985, 1989 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Holds the minimum and maximum costs for the parametrized capabilities. */
27 /* This structure holds everything needed to do cursor motion except the pad
28 character (PC) and the output speed of the terminal (ospeed), which
29 termcap wants in global variables. */
33 /* Cursor position. -1 in *both* variables means the cursor
34 position is unknown, in order to force absolute cursor motion. */
36 int cm_curY
; /* Current row */
37 int cm_curX
; /* Current column */
39 /* Capabilities from termcap */
40 char *cm_up
; /* up (up) */
41 char *cm_down
; /* down (do) */
42 char *cm_left
; /* left (le) */
43 char *cm_right
; /* right (nd) */
44 char *cm_home
; /* home (ho) */
45 char *cm_cr
; /* carriage return (cr) */
46 char *cm_ll
; /* last line (ll) */
47 char *cm_tab
; /* tab (ta) */
48 char *cm_backtab
; /* backtab (bt) */
49 char *cm_abs
; /* absolute (cm) */
50 char *cm_habs
; /* horizontal absolute (ch) */
51 char *cm_vabs
; /* vertical absolute (cv) */
53 char *cm_ds
; /* "don't send" string (ds) */
55 char *cm_multiup
; /* multiple up (UP) */
56 char *cm_multidown
; /* multiple down (DO) */
57 char *cm_multileft
; /* multiple left (LE) */
58 char *cm_multiright
; /* multiple right (RI) */
59 int cm_cols
; /* number of cols on screen (co) */
60 int cm_rows
; /* number of rows on screen (li) */
61 int cm_tabwidth
; /* tab width (it) */
62 unsigned int cm_autowrap
:1; /* autowrap flag (am) */
63 unsigned int cm_magicwrap
:1; /* VT-100: cursor stays in last col but
64 will cm_wrap if next char is
66 unsigned int cm_usetabs
:1; /* if set, use tabs */
67 unsigned int cm_losewrap
:1; /* if reach right margin, forget cursor
69 unsigned int cm_autolf
:1; /* \r performs a \r\n (rn) */
71 /* Parametrized capabilities. This needs to be a struct since
72 the costs are accessed through pointers. */
75 struct parmcap cc_abs
; /* absolute (cm) */
76 struct parmcap cc_habs
; /* horizontal absolute (ch) */
77 struct parmcap cc_vabs
; /* vertical absolute (cv) */
78 struct parmcap cc_multiup
; /* multiple up (UP) */
79 struct parmcap cc_multidown
; /* multiple down (DO) */
80 struct parmcap cc_multileft
; /* multiple left (LE) */
81 struct parmcap cc_multiright
; /* multiple right (RI) */
84 /* Costs for the non-parametrized capabilities */
85 int cc_up
; /* cost for up */
86 int cc_down
; /* etc. */
94 /* These are temporary, until the code is installed to use the
95 struct parmcap fields above. */
101 extern struct cm Wcm
; /* Terminal capabilities */
102 extern char PC
; /* Pad character */
104 #if defined (HAVE_TERMIOS_H) || defined (LINUX)
106 /* HJL's version of libc is said to need this on the Alpha.
107 On the other hand, DEC OSF1 on the Alpha needs ospeed to be a short. */
108 extern speed_t ospeed
;
110 extern short ospeed
; /* Output speed (from sg_ospeed) */
114 #ifndef NoCMShortHand
115 #define curY Wcm.cm_curY
116 #define curX Wcm.cm_curX
118 #define Down Wcm.cm_down
119 #define Left Wcm.cm_left
120 #define Right Wcm.cm_right
121 #define Tab Wcm.cm_tab
122 #define BackTab Wcm.cm_backtab
123 #define TabWidth Wcm.cm_tabwidth
125 #define Home Wcm.cm_home
126 #define LastLine Wcm.cm_ll
127 #define AbsPosition Wcm.cm_abs
128 #define ColPosition Wcm.cm_habs
129 #define RowPosition Wcm.cm_vabs
130 #define MultiUp Wcm.cm_multiup
131 #define MultiDown Wcm.cm_multidown
132 #define MultiLeft Wcm.cm_multileft
133 #define MultiRight Wcm.cm_multiright
134 #define AutoWrap Wcm.cm_autowrap
135 #define MagicWrap Wcm.cm_magicwrap
136 #define UseTabs Wcm.cm_usetabs
137 #define FrameRows Wcm.cm_rows
138 #define FrameCols Wcm.cm_cols
140 #define UpCost Wcm.cc_up
141 #define DownCost Wcm.cc_down
142 #define LeftCost Wcm.cc_left
143 #define RightCost Wcm.cc_right
144 #define HomeCost Wcm.cc_home
145 #define CRCost Wcm.cc_cr
146 #define LastLineCost Wcm.cc_ll
147 #define TabCost Wcm.cc_tab
148 #define BackTabCost Wcm.cc_backtab
149 #define AbsPositionCost Wcm.cc_abs
150 #define ColPositionCost Wcm.cc_habs
151 #define RowPositionCost Wcm.cc_vabs
152 #define MultiUpCost Wcm.cc_multiup
153 #define MultiDownCost Wcm.cc_multidown
154 #define MultiLeftCost Wcm.cc_multileft
155 #define MultiRightCost Wcm.cc_multiright
158 #define cmat(row,col) (curY = (row), curX = (col))
161 if ((curX += (n)) >= FrameCols && !MagicWrap) \
163 if (Wcm.cm_losewrap) losecursor (); \
164 else if (AutoWrap) curX = 0, curY++; \
169 #define losecursor() (curX = -1, curY = -1)
172 extern int evalcost ();
174 extern void cmcheckmagic ();
175 extern int cmputc ();
176 extern int cmcostinit ();
177 extern int cmgoto ();
178 extern int Wcm_clear ();
179 extern int Wcm_init ();