1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef EMACS_CM_H
20 #define EMACS_CM_H
21
22
23 struct parmcap
24 {
25 int mincost, maxcost;
26 };
27
28
29
30
31
32 struct cm
33 {
34
35
36
37 int cm_curY;
38 int cm_curX;
39
40
41 const char *cm_up;
42 const char *cm_down;
43 const char *cm_left;
44 const char *cm_right;
45 const char *cm_home;
46 const char *cm_cr;
47 const char *cm_ll;
48 const char *cm_tab;
49 const char *cm_backtab;
50 char *cm_abs;
51 const char *cm_habs;
52 const char *cm_vabs;
53 #if false
54 const char *cm_ds;
55 #endif
56 const char *cm_multiup;
57 const char *cm_multidown;
58 const char *cm_multileft;
59 const char *cm_multiright;
60 int cm_cols;
61 int cm_rows;
62 int cm_tabwidth;
63 bool_bf cm_autowrap : 1;
64 bool_bf cm_magicwrap : 1;
65
66
67 bool_bf cm_usetabs : 1;
68 bool_bf cm_losewrap : 1;
69
70 bool_bf cm_autolf : 1;
71
72
73
74
75 #if false
76 struct parmcap cc_abs;
77 struct parmcap cc_habs;
78 struct parmcap cc_vabs;
79 struct parmcap cc_multiup;
80 struct parmcap cc_multidown;
81 struct parmcap cc_multileft;
82 struct parmcap cc_multiright;
83 #endif
84
85
86 int cc_up;
87 int cc_down;
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
96
97 int cc_abs;
98 int cc_habs;
99 int cc_vabs;
100 };
101
102
103 #ifndef NoCMShortHand
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
145 #endif
146
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 } \
156 }
157
158 #define losecursor(tty) (curX(tty) = -1, curY(tty) = -1)
159
160 extern int cost;
161 extern int evalcost (int c);
162
163 #define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc))
164
165 extern struct tty_display_info *current_tty;
166 extern void cmcheckmagic (struct tty_display_info *);
167 extern int cmputc (int);
168 extern void cmcostinit (struct tty_display_info *);
169 extern void cmgoto (struct tty_display_info *, int, int);
170 extern void Wcm_clear (struct tty_display_info *);
171 extern int Wcm_init (struct tty_display_info *);
172
173 #endif