Convert some prototypes to standard C.
[bpt/emacs.git] / src / cm.h
CommitLineData
9889c728 1/* Cursor motion calculation definitions for GNU Emacs
429ab54e 2 Copyright (C) 1985, 1989, 2001, 2002, 2003, 2004,
114f9c96 3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
9889c728
JB
4
5This file is part of GNU Emacs.
6
b9b1cc14 7GNU Emacs is free software: you can redistribute it and/or modify
9889c728 8it under the terms of the GNU General Public License as published by
b9b1cc14
GM
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
9889c728
JB
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
b9b1cc14 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
9889c728
JB
19
20/* Holds the minimum and maximum costs for the parametrized capabilities. */
21struct parmcap
22 {
23 int mincost, maxcost;
24 };
25
26/* This structure holds everything needed to do cursor motion except the pad
27 character (PC) and the output speed of the terminal (ospeed), which
28 termcap wants in global variables. */
29
30struct cm
31 {
32 /* Cursor position. -1 in *both* variables means the cursor
33 position is unknown, in order to force absolute cursor motion. */
34
35 int cm_curY; /* Current row */
36 int cm_curX; /* Current column */
37
38 /* Capabilities from termcap */
39 char *cm_up; /* up (up) */
40 char *cm_down; /* down (do) */
41 char *cm_left; /* left (le) */
42 char *cm_right; /* right (nd) */
43 char *cm_home; /* home (ho) */
44 char *cm_cr; /* carriage return (cr) */
45 char *cm_ll; /* last line (ll) */
46 char *cm_tab; /* tab (ta) */
47 char *cm_backtab; /* backtab (bt) */
48 char *cm_abs; /* absolute (cm) */
49 char *cm_habs; /* horizontal absolute (ch) */
50 char *cm_vabs; /* vertical absolute (cv) */
51#if 0
52 char *cm_ds; /* "don't send" string (ds) */
53#endif
54 char *cm_multiup; /* multiple up (UP) */
55 char *cm_multidown; /* multiple down (DO) */
56 char *cm_multileft; /* multiple left (LE) */
57 char *cm_multiright; /* multiple right (RI) */
58 int cm_cols; /* number of cols on screen (co) */
59 int cm_rows; /* number of rows on screen (li) */
60 int cm_tabwidth; /* tab width (it) */
61 unsigned int cm_autowrap:1; /* autowrap flag (am) */
62 unsigned int cm_magicwrap:1; /* VT-100: cursor stays in last col but
63 will cm_wrap if next char is
64 printing (xn) */
65 unsigned int cm_usetabs:1; /* if set, use tabs */
66 unsigned int cm_losewrap:1; /* if reach right margin, forget cursor
67 location */
68 unsigned int cm_autolf:1; /* \r performs a \r\n (rn) */
69
70 /* Parametrized capabilities. This needs to be a struct since
71 the costs are accessed through pointers. */
72
73#if 0
74 struct parmcap cc_abs; /* absolute (cm) */
75 struct parmcap cc_habs; /* horizontal absolute (ch) */
76 struct parmcap cc_vabs; /* vertical absolute (cv) */
77 struct parmcap cc_multiup; /* multiple up (UP) */
78 struct parmcap cc_multidown; /* multiple down (DO) */
79 struct parmcap cc_multileft; /* multiple left (LE) */
80 struct parmcap cc_multiright; /* multiple right (RI) */
81#endif
82
83 /* Costs for the non-parametrized capabilities */
84 int cc_up; /* cost for up */
85 int cc_down; /* etc. */
86 int cc_left;
87 int cc_right;
88 int cc_home;
89 int cc_cr;
90 int cc_ll;
91 int cc_tab;
92 int cc_backtab;
93 /* These are temporary, until the code is installed to use the
94 struct parmcap fields above. */
95 int cc_abs;
96 int cc_habs;
97 int cc_vabs;
98 };
99
9889c728 100extern char PC; /* Pad character */
0dc57298 101
9889c728
JB
102/* Shorthand */
103#ifndef NoCMShortHand
6548cf00
KL
104#define curY(tty) (tty)->Wcm->cm_curY
105#define curX(tty) (tty)->Wcm->cm_curX
106#define Up(tty) (tty)->Wcm->cm_up
107#define Down(tty) (tty)->Wcm->cm_down
108#define Left(tty) (tty)->Wcm->cm_left
109#define Right(tty) (tty)->Wcm->cm_right
110#define Tab(tty) (tty)->Wcm->cm_tab
111#define BackTab(tty) (tty)->Wcm->cm_backtab
112#define TabWidth(tty) (tty)->Wcm->cm_tabwidth
113#define CR(tty) (tty)->Wcm->cm_cr
114#define Home(tty) (tty)->Wcm->cm_home
115#define LastLine(tty) (tty)->Wcm->cm_ll
116#define AbsPosition(tty) (tty)->Wcm->cm_abs
117#define ColPosition(tty) (tty)->Wcm->cm_habs
118#define RowPosition(tty) (tty)->Wcm->cm_vabs
119#define MultiUp(tty) (tty)->Wcm->cm_multiup
120#define MultiDown(tty) (tty)->Wcm->cm_multidown
121#define MultiLeft(tty) (tty)->Wcm->cm_multileft
122#define MultiRight(tty) (tty)->Wcm->cm_multiright
123#define AutoWrap(tty) (tty)->Wcm->cm_autowrap
124#define MagicWrap(tty) (tty)->Wcm->cm_magicwrap
125#define UseTabs(tty) (tty)->Wcm->cm_usetabs
126#define FrameRows(tty) (tty)->Wcm->cm_rows
127#define FrameCols(tty) (tty)->Wcm->cm_cols
128
129#define UpCost(tty) (tty)->Wcm->cc_up
130#define DownCost(tty) (tty)->Wcm->cc_down
131#define LeftCost(tty) (tty)->Wcm->cc_left
132#define RightCost(tty) (tty)->Wcm->cc_right
133#define HomeCost(tty) (tty)->Wcm->cc_home
134#define CRCost(tty) (tty)->Wcm->cc_cr
135#define LastLineCost(tty) (tty)->Wcm->cc_ll
136#define TabCost(tty) (tty)->Wcm->cc_tab
137#define BackTabCost(tty) (tty)->Wcm->cc_backtab
138#define AbsPositionCost(tty) (tty)->Wcm->cc_abs
139#define ColPositionCost(tty) (tty)->Wcm->cc_habs
140#define RowPositionCost(tty) (tty)->Wcm->cc_vabs
141#define MultiUpCost(tty) (tty)->Wcm->cc_multiup
142#define MultiDownCost(tty) (tty)->Wcm->cc_multidown
143#define MultiLeftCost(tty) (tty)->Wcm->cc_multileft
144#define MultiRightCost(tty) (tty)->Wcm->cc_multiright
9889c728
JB
145#endif
146
6548cf00
KL
147#define cmat(tty,row,col) (curY(tty) = (row), curX(tty) = (col))
148#define cmplus(tty,n) \
149 { \
150 if ((curX (tty) += (n)) >= FrameCols (tty) && !MagicWrap (tty)) \
151 { \
152 if ((tty)->Wcm->cm_losewrap) losecursor (tty); \
153 else if (AutoWrap (tty)) curX (tty) = 0, curY (tty)++; \
154 else curX (tty)--; \
155 } \
9889c728
JB
156 }
157
6548cf00 158#define losecursor(tty) (curX(tty) = -1, curY(tty) = -1)
9889c728
JB
159
160extern int cost;
c532d349 161extern int evalcost (char c);
9889c728 162
28d440ab
KL
163#define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc))
164
28d7d09f 165extern struct tty_display_info *current_tty;
383e0970
J
166extern void cmcheckmagic (struct tty_display_info *);
167extern int cmputc (int);
168extern void cmcostinit (struct tty_display_info *);
169extern void cmgoto (struct tty_display_info *, int, int);
170extern void Wcm_clear (struct tty_display_info *);
171extern int Wcm_init (struct tty_display_info *);
ab5796a9
MB
172
173/* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b
174 (do not change this comment) */