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