* frame.h (struct frame): New fields `can_have_scrollbars' and
[bpt/emacs.git] / src / termhooks.h
1 /* Hooks by which low level terminal operations
2 can be made to call other routines.
3 Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22 extern int (*cursor_to_hook) ();
23 extern int (*raw_cursor_to_hook) ();
24
25 extern int (*clear_to_end_hook) ();
26 extern int (*clear_frame_hook) ();
27 extern int (*clear_end_of_line_hook) ();
28
29 extern int (*ins_del_lines_hook) ();
30
31 extern int (*change_line_highlight_hook) ();
32 extern int (*reassert_line_highlight_hook) ();
33
34 extern int (*insert_glyphs_hook) ();
35 extern int (*write_glyphs_hook) ();
36 extern int (*delete_glyphs_hook) ();
37
38 extern int (*ring_bell_hook) ();
39
40 extern int (*reset_terminal_modes_hook) ();
41 extern int (*set_terminal_modes_hook) ();
42 extern int (*update_begin_hook) ();
43 extern int (*update_end_hook) ();
44 extern int (*set_terminal_window_hook) ();
45
46 extern int (*read_socket_hook) ();
47
48 enum scrollbar_part {
49 scrollbar_above_handle,
50 scrollbar_handle,
51 scrollbar_below_handle
52 };
53
54 /* Return the current position of the mouse.
55 Set `bar' to point to the scrollbar if the mouse movement started
56 in a scrollbar, or zero if it started elsewhere in the frame.
57 This should clear mouse_moved until the next motion event arrives. */
58 extern void (*mouse_position_hook) ( /* FRAME_PTR *f,
59 struct scrollbar **bar,
60 enum scrollbar_part *part,
61 Lisp_Object *x,
62 Lisp_Object *y,
63 unsigned long *time */ );
64
65 /* The window system handling code should set this if the mouse has
66 moved since the last call to the mouse_position_hook. Calling that
67 hook should clear this. */
68 extern int mouse_moved;
69
70 /* When a frame's focus redirection is changed, this hook tells the
71 window system code to re-decide where to put the highlight. Under
72 X, this means that Emacs lies about where the focus is. */
73 extern void (*frame_rehighlight_hook) ( /* void */ );
74
75 /* Set vertical scollbar BAR to have its upper left corner at (TOP,
76 LEFT), and be LENGTH rows high. Set its handle to indicate that we
77 are displaying PORTION characters out of a total of WHOLE
78 characters, starting at POSITION. Return BAR. If BAR is zero,
79 create a new scrollbar and return a pointer to it. */
80 extern struct scrollbar *(*set_vertical_scrollbar_hook)
81 ( /* struct scrollbar *BAR,
82 struct window *window,
83 int portion, int whole, int position */ );
84
85
86 /* The following three hooks are used when we're doing a thorough
87 redisplay of the frame. We don't explicitly know which scrollbars
88 are going to be deleted, because keeping track of when windows go
89 away is a real pain - can you say set-window-configuration?
90 Instead, we just assert at the beginning of redisplay that *all*
91 scrollbars are to be removed, and then save scrollbars from the
92 firey pit when we actually redisplay their window. */
93
94 /* Arrange for all scrollbars on FRAME to be removed at the next call
95 to `*judge_scrollbars_hook'. A scrollbar may be spared if
96 `*redeem_scrollbar_hook' is applied to it before the judgement. */
97 extern void (*condemn_scrollbars_hook)( /* FRAME_PTR *FRAME */ );
98
99 /* Unmark BAR for deletion in this judgement cycle. */
100 extern void (*redeem_scrollbar_hook)( /* struct scrollbar *BAR */ );
101
102 /* Remove all scrollbars on FRAME that haven't been saved since the
103 last call to `*condemn_scrollbars_hook'. */
104 extern void (*judge_scrollbars_hook)( /* FRAME_PTR *FRAME */ );
105
106
107
108 /* If nonzero, send all terminal output characters to this stream also. */
109 extern FILE *termscript;
110
111 /* Expedient hack: only provide the below definitions to files that
112 are prepared to handle lispy things. XINT is defined iff lisp.h
113 has been included before this file. */
114 #ifdef XINT
115
116 /* The keyboard input buffer is an array of these structures. Each one
117 represents some sort of input event - a keystroke, a mouse click, or
118 a window system event. These get turned into their lispy forms when
119 they are removed from the event queue. */
120
121 struct input_event {
122
123 /* What kind of event was this? */
124 enum {
125 no_event, /* nothing happened. This should never
126 actually appear in the event queue. */
127 ascii_keystroke, /* The ASCII code is in .code.
128 .frame is the frame in which the key
129 was typed.
130 Note that this includes meta-keys, and
131 the modifiers field of the event
132 is unused.
133 .timestamp gives a timestamp (in
134 milliseconds) for the keystroke. */
135 non_ascii_keystroke, /* .code is a number identifying the
136 function key. A code N represents
137 a key whose name is
138 function_key_names[N]; function_key_names
139 is a table in keyboard.c to which you
140 should feel free to add missing keys.
141 .modifiers holds the state of the
142 modifier keys.
143 .frame is the frame in which the key
144 was typed.
145 .timestamp gives a timestamp (in
146 milliseconds) for the keystroke. */
147 mouse_click, /* The button number is in .code; it must
148 be >= 0 and < NUM_MOUSE_BUTTONS, defined
149 below.
150 .modifiers holds the state of the
151 modifier keys.
152 .x and .y give the mouse position,
153 in characters, within the window.
154 .frame gives the frame the mouse
155 click occurred in.
156 .timestamp gives a timestamp (in
157 milliseconds) for the click. */
158
159 scrollbar_click, /* .code gives the number of the mouse button
160 that was clicked.
161 .modifiers holds the state of the modifier
162 keys.
163 .part is a lisp symbol indicating which
164 part of the scrollbar got clicked.
165 .scrollbar is a pointer to the scrollbar
166 clicked on. Since redisplay may delete
167 scrollbars at any time, you may not assume
168 that this scrollbar still exists when you
169 dequeue this event. You have to traverse
170 the window tree to make it's in a valid
171 window.
172 .x gives the distance from the start of the
173 scroll bar of the click; .y gives the total
174 length of the scroll bar.
175 .frame gives the frame the click should
176 apply to.
177 .timestamp gives a timestamp (in
178 milliseconds) for the click. */
179 } kind;
180
181 Lisp_Object code;
182 enum scrollbar_part part;
183 struct scrollbar *scrollbar;
184
185 /* This is obviously wrong, but I'm not sure what else I should do.
186 Obviously, this should be a FRAME_PTR. But that would require that
187 every file which #includes this one should also #include "frame.h",
188 which would mean that files like cm.c and other innocents would be
189 dragged into the set of frame.h users. Maybe the definition of this
190 structure should be elsewhere? In its own file? */
191 #ifdef MULTI_FRAME
192 struct frame *frame;
193 #else
194 int frame;
195 #endif
196 int modifiers; /* See enum below for interpretation. */
197
198 Lisp_Object x, y;
199 unsigned long timestamp;
200 };
201
202 /* This is used in keyboard.c, to tell how many buttons we will need
203 to track the positions of. */
204 #define NUM_MOUSE_BUTTONS (5)
205
206 /* Bits in the modifiers member of the input_event structure.
207 Note that reorder_modifiers assumes that the bits are in canonical
208 order.
209
210 The modifiers applied to mouse clicks are rather ornate. The
211 window-system-specific code should store mouse clicks with
212 up_modifier or down_modifier set. Having an explicit down modifier
213 simplifies some of window-system-independent code; without it, the
214 code would have to recognize down events by checking if the event
215 is a mouse click lacking the click and drag modifiers.
216
217 The window-system independent code turns all up_modifier events
218 bits into either drag_modifier or click_modifier events. The
219 click_modifier has no written representation in the names of the
220 symbols used as event heads, but it does appear in the
221 Qevent_symbol_components property of the event heads. */
222 enum {
223 up_modifier = 1, /* Only used on mouse buttons - always
224 turned into a click or a drag modifier
225 before lisp code sees the event. */
226 alt_modifier = 2, /* Under X, the XK_Alt_[LR] keysyms. */
227 ctrl_modifier = 4,
228 hyper_modifier= 8, /* Under X, the XK_Hyper_[LR] keysyms. */
229 meta_modifier = 16, /* Under X, the XK_Meta_[LR] keysyms. */
230 shift_modifier= 32,
231 super_modifier= 64, /* Under X, the XK_Super_[LR] keysyms. */
232 down_modifier = 128, /* Only used on mouse buttons. */
233 drag_modifier = 256, /* This is never used in the event
234 queue; it's only used internally by
235 the window-system-independent code. */
236 click_modifier= 512, /* See drag_modifier. */
237 last_modifier /* This should always be one more than the
238 highest modifier bit defined. */
239 };
240
241 #endif