aboutsummaryrefslogtreecommitdiffstats
path: root/src/termhooks.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/termhooks.h')
-rw-r--r--src/termhooks.h489
1 files changed, 330 insertions, 159 deletions
diff --git a/src/termhooks.h b/src/termhooks.h
index 8aef23bc2a7..72e0940cea6 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,7 +1,6 @@
1/* Hooks by which low level terminal operations 1/* Parameters and display hooks for terminal devices.
2 can be made to call other routines. 2 Copyright (C) 1985, 1986, 1993, 1994, 2002, 2003, 2004,
3 Copyright (C) 1985, 1986, 1993, 1994, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007 Free Software Foundation, Inc.
4 2005, 2006, 2007 Free Software Foundation, Inc.
5 4
6This file is part of GNU Emacs. 5This file is part of GNU Emacs.
7 6
@@ -26,40 +25,11 @@ Boston, MA 02110-1301, USA. */
26struct glyph; 25struct glyph;
27struct frame; 26struct frame;
28 27
29/* If nonzero, send all terminal output characters to this stream also. */
30extern FILE *termscript;
31
32/* Only use prototypes when lisp.h has been included. */ 28/* Only use prototypes when lisp.h has been included. */
33#ifndef P_ 29#ifndef P_
34#define P_(X) () 30#define P_(X) ()
35#endif 31#endif
36 32
37/* Text display hooks. */
38
39extern void (*cursor_to_hook) P_ ((int vpos, int hpos));
40extern void (*raw_cursor_to_hook) P_ ((int, int));
41
42extern void (*clear_to_end_hook) P_ ((void));
43extern void (*clear_frame_hook) P_ ((void));
44extern void (*clear_end_of_line_hook) P_ ((int));
45
46extern void (*ins_del_lines_hook) P_ ((int, int));
47
48extern void (*insert_glyphs_hook) P_ ((struct glyph *s, int n));
49extern void (*write_glyphs_hook) P_ ((struct glyph *s, int n));
50extern void (*delete_glyphs_hook) P_ ((int));
51
52extern void (*ring_bell_hook) P_ ((void));
53
54extern void (*reset_terminal_modes_hook) P_ ((void));
55extern void (*set_terminal_modes_hook) P_ ((void));
56extern void (*update_begin_hook) P_ ((struct frame *));
57extern void (*update_end_hook) P_ ((struct frame *));
58extern void (*set_terminal_window_hook) P_ ((int));
59
60
61
62/* Multi-frame and mouse support hooks. */
63 33
64enum scroll_bar_part { 34enum scroll_bar_part {
65 scroll_bar_above_handle, 35 scroll_bar_above_handle,
@@ -73,131 +43,12 @@ enum scroll_bar_part {
73 scroll_bar_move_ratio 43 scroll_bar_move_ratio
74}; 44};
75 45
76/* Return the current position of the mouse.
77
78 Set *f to the frame the mouse is in, or zero if the mouse is in no
79 Emacs frame. If it is set to zero, all the other arguments are
80 garbage.
81
82 If the motion started in a scroll bar, set *bar_window to the
83 scroll bar's window, *part to the part the mouse is currently over,
84 *x to the position of the mouse along the scroll bar, and *y to the
85 overall length of the scroll bar.
86
87 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
88 row of the character cell the mouse is over.
89
90 Set *time to the time the mouse was at the returned position.
91
92 This should clear mouse_moved until the next motion
93 event arrives. */
94extern void (*mouse_position_hook) P_ ((struct frame **f, int,
95 Lisp_Object *bar_window,
96 enum scroll_bar_part *part,
97 Lisp_Object *x,
98 Lisp_Object *y,
99 unsigned long *time));
100
101/* The window system handling code should set this if the mouse has
102 moved since the last call to the mouse_position_hook. Calling that
103 hook should clear this. */
104extern int mouse_moved;
105
106/* When a frame's focus redirection is changed, this hook tells the
107 window system code to re-decide where to put the highlight. Under
108 X, this means that Emacs lies about where the focus is. */
109extern void (*frame_rehighlight_hook) P_ ((struct frame *));
110
111/* If we're displaying frames using a window system that can stack
112 frames on top of each other, this hook allows you to bring a frame
113 to the front, or bury it behind all the other windows. If this
114 hook is zero, that means the device we're displaying on doesn't
115 support overlapping frames, so there's no need to raise or lower
116 anything.
117
118 If RAISE is non-zero, F is brought to the front, before all other
119 windows. If RAISE is zero, F is sent to the back, behind all other
120 windows. */
121extern void (*frame_raise_lower_hook) P_ ((struct frame *f, int raise));
122
123/* If the value of the frame parameter changed, whis hook is called. 46/* If the value of the frame parameter changed, whis hook is called.
124 For example, if going from fullscreen to not fullscreen this hook 47 For example, if going from fullscreen to not fullscreen this hook
125 may do something OS dependent, like extended window manager hints on X11. */ 48 may do something OS dependent, like extended window manager hints on X11. */
126extern void (*fullscreen_hook) P_ ((struct frame *f)); 49extern void (*fullscreen_hook) P_ ((struct frame *f));
127 50
128 51
129/* Scroll bar hooks. */
130
131/* The representation of scroll bars is determined by the code which
132 implements them, except for one thing: they must be represented by
133 lisp objects. This allows us to place references to them in
134 Lisp_Windows without worrying about those references becoming
135 dangling references when the scroll bar is destroyed.
136
137 The window-system-independent portion of Emacs just refers to
138 scroll bars via their windows, and never looks inside the scroll bar
139 representation; it always uses hook functions to do all the
140 scroll bar manipulation it needs.
141
142 The `vertical_scroll_bar' field of a Lisp_Window refers to that
143 window's scroll bar, or is nil if the window doesn't have a
144 scroll bar.
145
146 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
147 are free for use by the scroll bar implementation in any way it sees
148 fit. They are marked by the garbage collector. */
149
150
151/* Set the vertical scroll bar for WINDOW to have its upper left corner
152 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
153 indicate that we are displaying PORTION characters out of a total
154 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet
155 have a scroll bar, create one for it. */
156extern void (*set_vertical_scroll_bar_hook)
157 P_ ((struct window *window,
158 int portion, int whole, int position));
159
160
161/* The following three hooks are used when we're doing a thorough
162 redisplay of the frame. We don't explicitly know which scroll bars
163 are going to be deleted, because keeping track of when windows go
164 away is a real pain - can you say set-window-configuration?
165 Instead, we just assert at the beginning of redisplay that *all*
166 scroll bars are to be removed, and then save scroll bars from the
167 fiery pit when we actually redisplay their window. */
168
169/* Arrange for all scroll bars on FRAME to be removed at the next call
170 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
171 `*redeem_scroll_bar_hook' is applied to its window before the judgement.
172
173 This should be applied to each frame each time its window tree is
174 redisplayed, even if it is not displaying scroll bars at the moment;
175 if the HAS_SCROLL_BARS flag has just been turned off, only calling
176 this and the judge_scroll_bars_hook will get rid of them.
177
178 If non-zero, this hook should be safe to apply to any frame,
179 whether or not it can support scroll bars, and whether or not it is
180 currently displaying them. */
181extern void (*condemn_scroll_bars_hook) P_ ((struct frame *frame));
182
183/* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
184 Note that it's okay to redeem a scroll bar that is not condemned. */
185extern void (*redeem_scroll_bar_hook) P_ ((struct window *window));
186
187/* Remove all scroll bars on FRAME that haven't been saved since the
188 last call to `*condemn_scroll_bars_hook'.
189
190 This should be applied to each frame after each time its window
191 tree is redisplayed, even if it is not displaying scroll bars at the
192 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
193 calling this and condemn_scroll_bars_hook will get rid of them.
194
195 If non-zero, this hook should be safe to apply to any frame,
196 whether or not it can support scroll bars, and whether or not it is
197 currently displaying them. */
198extern void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME));
199
200
201/* Input queue declarations and hooks. */ 52/* Input queue declarations and hooks. */
202 53
203/* Expedient hack: only provide the below definitions to files that 54/* Expedient hack: only provide the below definitions to files that
@@ -390,13 +241,6 @@ struct input_event
390 241
391#define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event)) 242#define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event))
392 243
393/* Called to read input events. */
394extern int (*read_socket_hook) P_ ((int, int, struct input_event *));
395
396/* Called when a frame's display becomes entirely up to date. */
397extern void (*frame_up_to_date_hook) P_ ((struct frame *));
398
399
400/* Bits in the modifiers member of the input_event structure. 244/* Bits in the modifiers member of the input_event structure.
401 Note that reorder_modifiers assumes that the bits are in canonical 245 Note that reorder_modifiers assumes that the bits are in canonical
402 order. 246 order.
@@ -446,7 +290,334 @@ enum {
446 meta_modifier = CHAR_META /* Under X, the XK_Meta_[LR] keysyms. */ 290 meta_modifier = CHAR_META /* Under X, the XK_Meta_[LR] keysyms. */
447}; 291};
448 292
293#endif /* CONSP */
294
295
296/* Terminal-local parameters. */
297struct terminal
298{
299 /* Chain of all terminal devices. */
300 struct terminal *next_terminal;
301
302 /* Unique id for this terminal device. */
303 int id;
304
305 /* The number of frames that are on this terminal. */
306 int reference_count;
307
308 /* Nonzero while deleting this terminal. Used to protect against
309 recursive calls to delete_terminal_hook. */
310 int deleted;
311
312 /* The type of the terminal device. */
313 enum output_method type;
314
315 /* The name of the terminal device. Do not use this to uniquely
316 identify a terminal; the same device may be opened multiple
317 times. */
318 char *name;
319
320#ifdef MULTI_KBOARD
321 /* The terminal's keyboard object. */
322 struct kboard *kboard;
323#endif
324
325 /* Device-type dependent data shared amongst all frames on this terminal. */
326 union display_info
327 {
328 struct tty_display_info *tty; /* termchar.h */
329 struct x_display_info *x; /* xterm.h */
330 } display_info;
331
332
333 /* Coding-system to be used for encoding terminal output. This
334 structure contains information of a coding-system specified by
335 the function `set-terminal-coding-system'. Also see
336 `safe_terminal_coding' in coding.h. */
337 struct coding_system *terminal_coding;
338
339 /* Coding-system of what is sent from terminal keyboard. This
340 structure contains information of a coding-system specified by
341 the function `set-keyboard-coding-system'. */
342 struct coding_system *keyboard_coding;
343
344 /* Parameter alist of this terminal. */
345 Lisp_Object param_alist;
346
347 /* Terminal characteristics. */
348 /* XXX Are these really used on non-termcap displays? */
349
350 int must_write_spaces; /* Nonzero means spaces in the text must
351 actually be output; can't just skip over
352 some columns to leave them blank. */
353 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
354
355 int line_ins_del_ok; /* Terminal can insert and delete lines */
356 int char_ins_del_ok; /* Terminal can insert and delete chars */
357 int scroll_region_ok; /* Terminal supports setting the scroll
358 window */
359 int scroll_region_cost; /* Cost of setting the scroll window,
360 measured in characters. */
361 int memory_below_frame; /* Terminal remembers lines scrolled
362 off bottom */
363
364#if 0 /* These are not used anywhere. */
365 /* EMACS_INT baud_rate; */ /* Output speed in baud */
366 int min_padding_speed; /* Speed below which no padding necessary. */
367 int dont_calculate_costs; /* Nonzero means don't bother computing
368 various cost tables; we won't use them. */
369#endif
370
371
372 /* Window-based redisplay interface for this device (0 for tty
373 devices). */
374 struct redisplay_interface *rif;
375
376 /* Frame-based redisplay interface. */
377
378 /* Text display hooks. */
379
380 void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos));
381 void (*raw_cursor_to_hook) P_ ((struct frame *, int, int));
382
383 void (*clear_to_end_hook) P_ ((struct frame *));
384 void (*clear_frame_hook) P_ ((struct frame *));
385 void (*clear_end_of_line_hook) P_ ((struct frame *, int));
386
387 void (*ins_del_lines_hook) P_ ((struct frame *f, int, int));
388
389 void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
390 void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
391 void (*delete_glyphs_hook) P_ ((struct frame *, int));
392
393 void (*ring_bell_hook) P_ ((struct frame *f));
394
395 void (*reset_terminal_modes_hook) P_ ((struct terminal *));
396 void (*set_terminal_modes_hook) P_ ((struct terminal *));
397
398 void (*update_begin_hook) P_ ((struct frame *));
399 void (*update_end_hook) P_ ((struct frame *));
400 void (*set_terminal_window_hook) P_ ((struct frame *, int));
401
402 /* Multi-frame and mouse support hooks. */
403
404 /* Return the current position of the mouse.
405
406 Set *f to the frame the mouse is in, or zero if the mouse is in no
407 Emacs frame. If it is set to zero, all the other arguments are
408 garbage.
409
410 If the motion started in a scroll bar, set *bar_window to the
411 scroll bar's window, *part to the part the mouse is currently over,
412 *x to the position of the mouse along the scroll bar, and *y to the
413 overall length of the scroll bar.
414
415 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
416 row of the character cell the mouse is over.
417
418 Set *time to the time the mouse was at the returned position.
419
420 This should clear mouse_moved until the next motion
421 event arrives. */
422 void (*mouse_position_hook) P_ ((struct frame **f, int,
423 Lisp_Object *bar_window,
424 enum scroll_bar_part *part,
425 Lisp_Object *x,
426 Lisp_Object *y,
427 unsigned long *time));
428
429 /* The window system handling code should set this if the mouse has
430 moved since the last call to the mouse_position_hook. Calling that
431 hook should clear this. */
432 int mouse_moved;
433
434 /* When a frame's focus redirection is changed, this hook tells the
435 window system code to re-decide where to put the highlight. Under
436 X, this means that Emacs lies about where the focus is. */
437 void (*frame_rehighlight_hook) P_ ((struct frame *));
438
439 /* If we're displaying frames using a window system that can stack
440 frames on top of each other, this hook allows you to bring a frame
441 to the front, or bury it behind all the other windows. If this
442 hook is zero, that means the terminal we're displaying on doesn't
443 support overlapping frames, so there's no need to raise or lower
444 anything.
445
446 If RAISE is non-zero, F is brought to the front, before all other
447 windows. If RAISE is zero, F is sent to the back, behind all other
448 windows. */
449 void (*frame_raise_lower_hook) P_ ((struct frame *f, int raise));
450
451 /* If the value of the frame parameter changed, whis hook is called.
452 For example, if going from fullscreen to not fullscreen this hook
453 may do something OS dependent, like extended window manager hints on X11. */
454 void (*fullscreen_hook) P_ ((struct frame *f));
455
456
457 /* Scroll bar hooks. */
458
459 /* The representation of scroll bars is determined by the code which
460 implements them, except for one thing: they must be represented by
461 lisp objects. This allows us to place references to them in
462 Lisp_Windows without worrying about those references becoming
463 dangling references when the scroll bar is destroyed.
464
465 The window-system-independent portion of Emacs just refers to
466 scroll bars via their windows, and never looks inside the scroll bar
467 representation; it always uses hook functions to do all the
468 scroll bar manipulation it needs.
469
470 The `vertical_scroll_bar' field of a Lisp_Window refers to that
471 window's scroll bar, or is nil if the window doesn't have a
472 scroll bar.
473
474 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
475 are free for use by the scroll bar implementation in any way it sees
476 fit. They are marked by the garbage collector. */
477
478
479 /* Set the vertical scroll bar for WINDOW to have its upper left corner
480 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
481 indicate that we are displaying PORTION characters out of a total
482 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet
483 have a scroll bar, create one for it. */
484 void (*set_vertical_scroll_bar_hook) P_ ((struct window *window,
485 int portion, int whole,
486 int position));
487
488
489 /* The following three hooks are used when we're doing a thorough
490 redisplay of the frame. We don't explicitly know which scroll bars
491 are going to be deleted, because keeping track of when windows go
492 away is a real pain - can you say set-window-configuration?
493 Instead, we just assert at the beginning of redisplay that *all*
494 scroll bars are to be removed, and then save scroll bars from the
495 fiery pit when we actually redisplay their window. */
496
497 /* Arrange for all scroll bars on FRAME to be removed at the next call
498 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
499 `*redeem_scroll_bar_hook' is applied to its window before the judgement.
500
501 This should be applied to each frame each time its window tree is
502 redisplayed, even if it is not displaying scroll bars at the moment;
503 if the HAS_SCROLL_BARS flag has just been turned off, only calling
504 this and the judge_scroll_bars_hook will get rid of them.
505
506 If non-zero, this hook should be safe to apply to any frame,
507 whether or not it can support scroll bars, and whether or not it is
508 currently displaying them. */
509 void (*condemn_scroll_bars_hook) P_ ((struct frame *frame));
510
511 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
512 Note that it's okay to redeem a scroll bar that is not condemned. */
513 void (*redeem_scroll_bar_hook) P_ ((struct window *window));
514
515 /* Remove all scroll bars on FRAME that haven't been saved since the
516 last call to `*condemn_scroll_bars_hook'.
517
518 This should be applied to each frame after each time its window
519 tree is redisplayed, even if it is not displaying scroll bars at the
520 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
521 calling this and condemn_scroll_bars_hook will get rid of them.
522
523 If non-zero, this hook should be safe to apply to any frame,
524 whether or not it can support scroll bars, and whether or not it is
525 currently displaying them. */
526 void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME));
527
528
529 /* Called to read input events.
530
531 TERMINAL indicates which terminal device to read from. Input
532 events should be read into BUF, the size of which is given in
533 SIZE. EXPECTED is non-zero if the caller suspects that new input
534 is available.
535
536 A positive return value indicates that that many input events
537 where read into BUF.
538 Zero means no events were immediately available.
539 A value of -1 means a transient read error, while -2 indicates
540 that the device was closed (hangup), and it should be deleted.
541
542 XXX Please note that a non-zero value of EXPECTED only means that
543 there is available input on at least one of the currently opened
544 terminal devices -- but not necessarily on this device.
545 Therefore, in most cases EXPECTED should be simply ignored.
546
547 XXX This documentation needs to be updated. */
548 int (*read_socket_hook) P_ ((struct terminal *terminal,
549 int expected,
550 struct input_event *hold_quit));
551
552 /* Called when a frame's display becomes entirely up to date. */
553 void (*frame_up_to_date_hook) P_ ((struct frame *));
554
555
556 /* Called to delete the device-specific portions of a frame that is
557 on this terminal device. */
558 void (*delete_frame_hook) P_ ((struct frame *));
559
560 /* Called after the last frame on this terminal is deleted, or when
561 the display device was closed (hangup).
562
563 If this is NULL, then the generic delete_terminal is called
564 instead. Otherwise the hook must call delete_terminal itself.
565
566 The hook must check for and close any live frames that are still
567 on the terminal. Fdelete_frame ensures that there are no live
568 frames on the terminal when it calls this hook, so infinite
569 recursion is prevented. */
570 void (*delete_terminal_hook) P_ ((struct terminal *));
571};
572
573
574/* Chain of all terminal devices currently in use. */
575extern struct terminal *terminal_list;
576
577#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
578#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->terminal->fast_clear_end_of_line)
579#define FRAME_LINE_INS_DEL_OK(f) ((f)->terminal->line_ins_del_ok)
580#define FRAME_CHAR_INS_DEL_OK(f) ((f)->terminal->char_ins_del_ok)
581#define FRAME_SCROLL_REGION_OK(f) ((f)->terminal->scroll_region_ok)
582#define FRAME_SCROLL_REGION_COST(f) ((f)->terminal->scroll_region_cost)
583#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->terminal->memory_below_frame)
584
585#define FRAME_TERMINAL_CODING(f) ((f)->terminal->terminal_coding)
586#define FRAME_KEYBOARD_CODING(f) ((f)->terminal->keyboard_coding)
587
588#define TERMINAL_TERMINAL_CODING(d) ((d)->terminal_coding)
589#define TERMINAL_KEYBOARD_CODING(d) ((d)->keyboard_coding)
590
591#define FRAME_RIF(f) ((f)->terminal->rif)
592
593#define FRAME_TERMINAL(f) ((f)->terminal)
594
595/* FRAME_WINDOW_P tests whether the frame is a window, and is
596 defined to be the predicate for the window system being used. */
597
598#ifdef HAVE_X_WINDOWS
599#define FRAME_WINDOW_P(f) FRAME_X_P (f)
449#endif 600#endif
601#ifdef HAVE_NTGUI
602#define FRAME_WINDOW_P(f) FRAME_W32_P (f)
603#endif
604#ifdef MAC_OS
605#define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
606#endif
607#ifndef FRAME_WINDOW_P
608#define FRAME_WINDOW_P(f) (0)
609#endif
610
611/* Return true if the terminal device is not suspended. */
612#define TERMINAL_ACTIVE_P(d) ((d)->type != output_termcap || (d)->display_info.tty->input)
613
614extern Lisp_Object get_terminal_param P_ ((struct terminal *, Lisp_Object));
615extern struct terminal *get_terminal P_ ((Lisp_Object terminal, int));
616extern struct terminal *create_terminal P_ ((void));
617extern void delete_terminal P_ ((struct terminal *));
618
619/* The initial terminal device, created by initial_term_init. */
620extern struct terminal *initial_terminal;
450 621
451/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d 622/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
452 (do not change this comment) */ 623 (do not change this comment) */