Mercurial > emacs
annotate src/term.c @ 1819:df06a60f3362
* disass.el (disassemble): Add autoload cookie for this.
* bytecomp.el (byte-decompile-bytecode): Add an autoload for this.
compiled-function-p has been renamed to byte-code-function-p.
* subr.el: Define compiled-function-p as an alias for it.
* bytecomp.el: Register compiled-function-p as obsolete.
* bytecomp.el, byte-opt.el, disass.el, help.el, map-ynp.el: Change
uses.
unread-command-event has been replaced by unread-command-events.
* simple.el (prefix-arg-internal): Use this to push back all
key sequences for processing by the main command loop, instead of
trying to simulate its behavior ourselves.
* bytecomp.el: Document unread-command-event as an obsolete
variable, although nothing but the GNU Emacs 19 sources use it.
Adjust obsolescence message for unread-command-char.
* comint.el (comint-dynamic-list-completions): Change uses of
unread-command-event to work with unread-command-events.
* ebuff-menu.el (electric-buffer-list, Electric-buffer-menu-exit):
Same.
* edebug.el (edebug-outside-excursion): Same.
* ehelp.el (electric-help-command-loop): Same.
* electric.el (Electric-command-loop): Same.
* emerge.el (emerge-show-file-name): Same.
* fortran.el (fortran-abbrev-start,
fortran-window-create-momentarily): Same.
* gnus.el (gnus-Subject-next-article): Same.
* info.el (Info-summary): Same.
* isearch-mode.el (isearch-update, isearch-unread): Same.
* map-ynp.el (map-y-or-n-p): Same.
* mlsupport.el (push-back-character): Same.
* replace.el (perform-replace): Same.
* simula.el (simula-electric-label): Same.
* subr.el (read-quoted-char, momentary-string-display): Same.
* sun-mouse.el (mouse-second-hit): Same.
* terminal.el (te-escape-extended-command-unread): Same.
* vip.el (vip-escape-to-emacs, vip-prefix-arg-value,
vip-prefix-arg-com): Same.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 26 Jan 1993 01:36:02 +0000 |
parents | 3f161f6701b1 |
children | 04fb1d3d6992 |
rev | line source |
---|---|
253 | 1 /* terminal control module for terminals described by TERMCAP |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc. |
253 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
621 | 8 the Free Software Foundation; either version 2, or (at your option) |
253 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include <stdio.h> | |
22 #include <ctype.h> | |
23 #include "config.h" | |
24 #include "termchar.h" | |
25 #include "termopts.h" | |
26 #include "cm.h" | |
27 #undef NULL | |
28 #include "lisp.h" | |
765 | 29 #include "frame.h" |
253 | 30 #include "disptab.h" |
31 #include "termhooks.h" | |
533 | 32 #include "keyboard.h" |
253 | 33 |
34 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
35 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
36 | |
765 | 37 #define OUTPUT(a) tputs (a, FRAME_HEIGHT (selected_frame) - curY, cmputc) |
253 | 38 #define OUTPUT1(a) tputs (a, 1, cmputc) |
39 #define OUTPUTL(a, lines) tputs (a, lines, cmputc) | |
765 | 40 #define OUTPUT_IF(a) { if (a) tputs (a, FRAME_HEIGHT (selected_frame) - curY, cmputc); } |
253 | 41 #define OUTPUT1_IF(a) { if (a) tputs (a, 1, cmputc); } |
42 | |
43 /* Terminal charateristics that higher levels want to look at. | |
44 These are all extern'd in termchar.h */ | |
45 | |
46 int must_write_spaces; /* Nonzero means spaces in the text | |
47 must actually be output; can't just skip | |
48 over some columns to leave them blank. */ | |
49 int min_padding_speed; /* Speed below which no padding necessary */ | |
50 | |
51 int line_ins_del_ok; /* Terminal can insert and delete lines */ | |
52 int char_ins_del_ok; /* Terminal can insert and delete chars */ | |
53 int scroll_region_ok; /* Terminal supports setting the | |
54 scroll window */ | |
765 | 55 int memory_below_frame; /* Terminal remembers lines |
253 | 56 scrolled off bottom */ |
57 int fast_clear_end_of_line; /* Terminal has a `ce' string */ | |
58 | |
59 int dont_calculate_costs; /* Nonzero means don't bother computing */ | |
60 /* various cost tables; we won't use them. */ | |
61 | |
765 | 62 /* Nonzero means no need to redraw the entire frame on resuming |
253 | 63 a suspended Emacs. This is useful on terminals with multiple pages, |
64 where one page is used for Emacs and another for all else. */ | |
65 int no_redraw_on_reenter; | |
66 | |
67 /* Hook functions that you can set to snap out the functions in this file. | |
68 These are all extern'd in termhooks.h */ | |
69 | |
70 int (*cursor_to_hook) (); | |
71 int (*raw_cursor_to_hook) (); | |
72 | |
73 int (*clear_to_end_hook) (); | |
765 | 74 int (*clear_frame_hook) (); |
253 | 75 int (*clear_end_of_line_hook) (); |
76 | |
77 int (*ins_del_lines_hook) (); | |
78 | |
79 int (*change_line_highlight_hook) (); | |
80 int (*reassert_line_highlight_hook) (); | |
81 | |
82 int (*insert_glyphs_hook) (); | |
83 int (*write_glyphs_hook) (); | |
84 int (*delete_glyphs_hook) (); | |
85 | |
86 int (*ring_bell_hook) (); | |
87 | |
88 int (*reset_terminal_modes_hook) (); | |
89 int (*set_terminal_modes_hook) (); | |
90 int (*update_begin_hook) (); | |
91 int (*update_end_hook) (); | |
92 int (*set_terminal_window_hook) (); | |
93 | |
94 int (*read_socket_hook) (); | |
95 | |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
96 /* Return the current position of the mouse. |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
97 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
98 Set *f to the frame the mouse is in, or zero if the mouse is in no |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
99 Emacs frame. If it is set to zero, all the other arguments are |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
100 garbage. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
101 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
102 If the motion started in a scrollbar, set *bar_window to the |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
103 scrollbar's window, *part to the part the mouse is currently over, |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
104 *x to the position of the mouse along the scrollbar, and *y to the |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
105 overall length of the scrollbar. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
106 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
107 Otherwise, set *bar_window to Qnil, and *x and *y to the column and |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
108 row of the character cell the mouse is over. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
109 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
110 Set *time to the time the mouse was at the returned position. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
111 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
112 This should clear mouse_moved until the next motion |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
113 event arrives. */ |
765 | 114 void (*mouse_position_hook) ( /* FRAME_PTR *f, |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
115 Lisp_Object *bar_window, |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
116 enum scrollbar_part *part, |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
117 Lisp_Object *x, |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
118 Lisp_Object *y, |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
119 unsigned long *time */ ); |
253 | 120 |
765 | 121 /* When reading from a minibuffer in a different frame, Emacs wants |
122 to shift the highlight from the selected frame to the minibuffer's | |
123 frame; under X, this means it lies about where the focus is. | |
339 | 124 This hook tells the window system code to re-decide where to put |
125 the highlight. */ | |
765 | 126 void (*frame_rehighlight_hook) ( /* FRAME_PTR f */ ); |
339 | 127 |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
128 /* Set the vertical scrollbar for WINDOW to have its upper left corner |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
129 at (TOP, LEFT), and be LENGTH rows high. Set its handle to |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
130 indicate that we are displaying PORTION characters out of a total |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
131 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
132 have a scrollbar, create one for it. */ |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
133 void (*set_vertical_scrollbar_hook) |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
134 ( /* struct window *window, |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
135 int portion, int whole, int position */ ); |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
136 |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
137 |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
138 /* The following three hooks are used when we're doing a thorough |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
139 redisplay of the frame. We don't explicitly know which scrollbars |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
140 are going to be deleted, because keeping track of when windows go |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
141 away is a real pain - can you say set-window-configuration? |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
142 Instead, we just assert at the beginning of redisplay that *all* |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
143 scrollbars are to be removed, and then save scrollbars from the |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
144 firey pit when we actually redisplay their window. */ |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
145 |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
146 /* Arrange for all scrollbars on FRAME to be removed at the next call |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
147 to `*judge_scrollbars_hook'. A scrollbar may be spared if |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
148 `*redeem_scrollbar_hook' is applied to its window before the judgement. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
149 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
150 This should be applied to each frame each time its window tree is |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
151 redisplayed, even if it is not displaying scrollbars at the moment; |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
152 if the HAS_SCROLLBARS flag has just been turned off, only calling |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
153 this and the judge_scrollbars_hook will get rid of them. |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
154 |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
155 If non-zero, this hook should be safe to apply to any frame, |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
156 whether or not it can support scrollbars, and whether or not it is |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
157 currently displaying them. */ |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
158 void (*condemn_scrollbars_hook)( /* FRAME_PTR *frame */ ); |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
159 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
160 /* Unmark WINDOW's scrollbar for deletion in this judgement cycle. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
161 Note that it's okay to redeem a scrollbar that is not condemned. */ |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
162 void (*redeem_scrollbar_hook)( /* struct window *window */ ); |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
163 |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
164 /* Remove all scrollbars on FRAME that haven't been saved since the |
1781
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
165 last call to `*condemn_scrollbars_hook'. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
166 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
167 This should be applied to each frame after each time its window |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
168 tree is redisplayed, even if it is not displaying scrollbars at the |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
169 moment; if the HAS_SCROLLBARS flag has just been turned off, only |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
170 calling this and condemn_scrollbars_hook will get rid of them. |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
171 |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
172 If non-zero, this hook should be safe to apply to any frame, |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
173 whether or not it can support scrollbars, and whether or not it is |
3f161f6701b1
* term.c (set_vertical_scrollbar_hook, condemn_scrollbars_hook,
Jim Blandy <jimb@redhat.com>
parents:
1717
diff
changeset
|
174 currently displaying them. */ |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
175 void (*judge_scrollbars_hook)( /* FRAME_PTR *FRAME */ ); |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
176 |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
177 |
253 | 178 /* Strings, numbers and flags taken from the termcap entry. */ |
179 | |
180 char *TS_ins_line; /* termcap "al" */ | |
181 char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ | |
182 char *TS_bell; /* "bl" */ | |
183 char *TS_clr_to_bottom; /* "cd" */ | |
184 char *TS_clr_line; /* "ce", clear to end of line */ | |
765 | 185 char *TS_clr_frame; /* "cl" */ |
253 | 186 char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ |
187 char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, | |
188 lines above scroll region, lines below it, | |
189 total lines again) */ | |
190 char *TS_del_char; /* "dc" */ | |
191 char *TS_del_multi_chars; /* "DC" (one parameter, # chars to delete) */ | |
192 char *TS_del_line; /* "dl" */ | |
193 char *TS_del_multi_lines; /* "DL" (one parameter, # lines to delete) */ | |
194 char *TS_delete_mode; /* "dm", enter character-delete mode */ | |
195 char *TS_end_delete_mode; /* "ed", leave character-delete mode */ | |
196 char *TS_end_insert_mode; /* "ei", leave character-insert mode */ | |
197 char *TS_ins_char; /* "ic" */ | |
198 char *TS_ins_multi_chars; /* "IC" (one parameter, # chars to insert) */ | |
199 char *TS_insert_mode; /* "im", enter character-insert mode */ | |
200 char *TS_pad_inserted_char; /* "ip". Just padding, no commands. */ | |
201 char *TS_end_keypad_mode; /* "ke" */ | |
202 char *TS_keypad_mode; /* "ks" */ | |
203 char *TS_pad_char; /* "pc", char to use as padding */ | |
204 char *TS_repeat; /* "rp" (2 params, # times to repeat | |
205 and character to be repeated) */ | |
206 char *TS_end_standout_mode; /* "se" */ | |
207 char *TS_fwd_scroll; /* "sf" */ | |
208 char *TS_standout_mode; /* "so" */ | |
209 char *TS_rev_scroll; /* "sr" */ | |
210 char *TS_end_termcap_modes; /* "te" */ | |
211 char *TS_termcap_modes; /* "ti" */ | |
212 char *TS_visible_bell; /* "vb" */ | |
213 char *TS_end_visual_mode; /* "ve" */ | |
214 char *TS_visual_mode; /* "vi" */ | |
215 char *TS_set_window; /* "wi" (4 params, start and end of window, | |
216 each as vpos and hpos) */ | |
217 | |
218 int TF_hazeltine; /* termcap hz flag. */ | |
219 int TF_insmode_motion; /* termcap mi flag: can move while in insert mode. */ | |
220 int TF_standout_motion; /* termcap mi flag: can move while in standout mode. */ | |
221 int TF_underscore; /* termcap ul flag: _ underlines if overstruck on | |
222 nonblank position. Must clear before writing _. */ | |
223 int TF_teleray; /* termcap xt flag: many weird consequences. | |
224 For t1061. */ | |
225 | |
226 int TF_xs; /* Nonzero for "xs". If set together with | |
227 TN_standout_width == 0, it means don't bother | |
228 to write any end-standout cookies. */ | |
229 | |
230 int TN_standout_width; /* termcap sg number: width occupied by standout | |
231 markers */ | |
232 | |
233 static int RPov; /* # chars to start a TS_repeat */ | |
234 | |
235 static int delete_in_insert_mode; /* delete mode == insert mode */ | |
236 | |
237 static int se_is_so; /* 1 if same string both enters and leaves | |
238 standout mode */ | |
239 | |
240 /* internal state */ | |
241 | |
242 /* Number of chars of space used for standout marker at beginning of line, | |
243 or'd with 0100. Zero if no standout marker at all. | |
244 | |
245 Used IFF TN_standout_width >= 0. */ | |
246 | |
247 static char *chars_wasted; | |
248 static char *copybuf; | |
249 | |
250 /* nonzero means supposed to write text in standout mode. */ | |
251 int standout_requested; | |
252 | |
253 int insert_mode; /* Nonzero when in insert mode. */ | |
254 int standout_mode; /* Nonzero when in standout mode. */ | |
255 | |
256 /* Size of window specified by higher levels. | |
765 | 257 This is the number of lines, from the top of frame downwards, |
253 | 258 which can participate in insert-line/delete-line operations. |
259 | |
765 | 260 Effectively it excludes the bottom frame_height - specified_window_size |
253 | 261 lines from those operations. */ |
262 | |
263 int specified_window; | |
264 | |
765 | 265 /* Frame currently being redisplayed; 0 if not currently redisplaying. |
253 | 266 (Direct output does not count). */ |
267 | |
765 | 268 FRAME_PTR updating_frame; |
253 | 269 |
270 char *tparam (); | |
271 | |
272 ring_bell () | |
273 { | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
274 if (! FRAME_TERMCAP_P (selected_frame)) |
253 | 275 { |
276 (*ring_bell_hook) (); | |
277 return; | |
278 } | |
279 OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); | |
280 } | |
281 | |
282 set_terminal_modes () | |
283 { | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
284 if (! FRAME_TERMCAP_P (selected_frame)) |
253 | 285 { |
286 (*set_terminal_modes_hook) (); | |
287 return; | |
288 } | |
289 OUTPUT_IF (TS_termcap_modes); | |
290 OUTPUT_IF (TS_visual_mode); | |
291 OUTPUT_IF (TS_keypad_mode); | |
292 losecursor (); | |
293 } | |
294 | |
295 reset_terminal_modes () | |
296 { | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
297 if (! FRAME_TERMCAP_P (selected_frame)) |
253 | 298 { |
299 (*reset_terminal_modes_hook) (); | |
300 return; | |
301 } | |
302 if (TN_standout_width < 0) | |
303 turn_off_highlight (); | |
304 turn_off_insert (); | |
305 OUTPUT_IF (TS_end_keypad_mode); | |
306 OUTPUT_IF (TS_end_visual_mode); | |
307 OUTPUT_IF (TS_end_termcap_modes); | |
308 /* Output raw CR so kernel can track the cursor hpos. */ | |
309 /* But on magic-cookie terminals this can erase an end-standout marker and | |
765 | 310 cause the rest of the frame to be in standout, so move down first. */ |
253 | 311 if (TN_standout_width >= 0) |
312 cmputc ('\n'); | |
313 cmputc ('\r'); | |
314 } | |
315 | |
765 | 316 update_begin (f) |
317 FRAME_PTR f; | |
253 | 318 { |
765 | 319 updating_frame = f; |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
320 if (! FRAME_TERMCAP_P (updating_frame)) |
765 | 321 (*update_begin_hook) (f); |
253 | 322 } |
323 | |
765 | 324 update_end (f) |
325 FRAME_PTR f; | |
253 | 326 { |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
327 if (! FRAME_TERMCAP_P (updating_frame)) |
253 | 328 { |
765 | 329 (*update_end_hook) (f); |
330 updating_frame = 0; | |
253 | 331 return; |
332 } | |
333 turn_off_insert (); | |
334 background_highlight (); | |
335 standout_requested = 0; | |
765 | 336 updating_frame = 0; |
253 | 337 } |
338 | |
339 set_terminal_window (size) | |
340 int size; | |
341 { | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
342 if (! FRAME_TERMCAP_P (updating_frame)) |
253 | 343 { |
344 (*set_terminal_window_hook) (size); | |
345 return; | |
346 } | |
765 | 347 specified_window = size ? size : FRAME_HEIGHT (selected_frame); |
253 | 348 if (!scroll_region_ok) |
349 return; | |
350 set_scroll_region (0, specified_window); | |
351 } | |
352 | |
353 set_scroll_region (start, stop) | |
354 int start, stop; | |
355 { | |
356 char *buf; | |
357 if (TS_set_scroll_region) | |
358 { | |
359 buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1); | |
360 } | |
361 else if (TS_set_scroll_region_1) | |
362 { | |
363 buf = tparam (TS_set_scroll_region_1, 0, 0, | |
765 | 364 FRAME_HEIGHT (selected_frame), start, |
365 FRAME_HEIGHT (selected_frame) - stop, | |
366 FRAME_HEIGHT (selected_frame)); | |
253 | 367 } |
368 else | |
369 { | |
765 | 370 buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (selected_frame)); |
253 | 371 } |
372 OUTPUT (buf); | |
373 free (buf); | |
374 losecursor (); | |
375 } | |
376 | |
377 turn_on_insert () | |
378 { | |
379 if (!insert_mode) | |
380 OUTPUT (TS_insert_mode); | |
381 insert_mode = 1; | |
382 } | |
383 | |
384 turn_off_insert () | |
385 { | |
386 if (insert_mode) | |
387 OUTPUT (TS_end_insert_mode); | |
388 insert_mode = 0; | |
389 } | |
390 | |
391 /* Handle highlighting when TN_standout_width (termcap sg) is not specified. | |
392 In these terminals, output is affected by the value of standout | |
393 mode when the output is written. | |
394 | |
395 These functions are called on all terminals, but do nothing | |
396 on terminals whose standout mode does not work that way. */ | |
397 | |
398 turn_off_highlight () | |
399 { | |
400 if (TN_standout_width < 0) | |
401 { | |
402 if (standout_mode) | |
403 OUTPUT_IF (TS_end_standout_mode); | |
404 standout_mode = 0; | |
405 } | |
406 } | |
407 | |
408 turn_on_highlight () | |
409 { | |
410 if (TN_standout_width < 0) | |
411 { | |
412 if (!standout_mode) | |
413 OUTPUT_IF (TS_standout_mode); | |
414 standout_mode = 1; | |
415 } | |
416 } | |
417 | |
418 /* Set standout mode to the state it should be in for | |
419 empty space inside windows. What this is, | |
420 depends on the user option inverse-video. */ | |
421 | |
422 background_highlight () | |
423 { | |
424 if (TN_standout_width >= 0) | |
425 return; | |
426 if (inverse_video) | |
427 turn_on_highlight (); | |
428 else | |
429 turn_off_highlight (); | |
430 } | |
431 | |
432 /* Set standout mode to the mode specified for the text to be output. */ | |
433 | |
434 static | |
435 highlight_if_desired () | |
436 { | |
437 if (TN_standout_width >= 0) | |
438 return; | |
439 if (!inverse_video == !standout_requested) | |
440 turn_off_highlight (); | |
441 else | |
442 turn_on_highlight (); | |
443 } | |
444 | |
445 /* Handle standout mode for terminals in which TN_standout_width >= 0. | |
446 On these terminals, standout is controlled by markers that | |
765 | 447 live inside the terminal's memory. TN_standout_width is the width |
253 | 448 that the marker occupies in memory. Standout runs from the marker |
449 to the end of the line on some terminals, or to the next | |
450 turn-off-standout marker (TS_end_standout_mode) string | |
451 on other terminals. */ | |
452 | |
453 /* Write a standout marker or end-standout marker at the front of the line | |
454 at vertical position vpos. */ | |
455 | |
456 write_standout_marker (flag, vpos) | |
457 int flag, vpos; | |
458 { | |
459 if (flag || (TS_end_standout_mode && !TF_teleray && !se_is_so | |
460 && !(TF_xs && TN_standout_width == 0))) | |
461 { | |
462 cmgoto (vpos, 0); | |
463 cmplus (TN_standout_width); | |
464 OUTPUT (flag ? TS_standout_mode : TS_end_standout_mode); | |
465 chars_wasted[curY] = TN_standout_width | 0100; | |
466 } | |
467 } | |
468 | |
469 /* External interface to control of standout mode. | |
470 Call this when about to modify line at position VPOS | |
471 and not change whether it is highlighted. */ | |
472 | |
473 reassert_line_highlight (highlight, vpos) | |
474 int highlight; | |
475 int vpos; | |
476 { | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
477 if (! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame))) |
253 | 478 { |
479 (*reassert_line_highlight_hook) (highlight, vpos); | |
480 return; | |
481 } | |
482 if (TN_standout_width < 0) | |
483 /* Handle terminals where standout takes affect at output time */ | |
484 standout_requested = highlight; | |
485 else if (chars_wasted[vpos] == 0) | |
486 /* For terminals with standout markers, write one on this line | |
487 if there isn't one already. */ | |
488 write_standout_marker (highlight, vpos); | |
489 } | |
490 | |
491 /* Call this when about to modify line at position VPOS | |
492 and change whether it is highlighted. */ | |
493 | |
494 change_line_highlight (new_highlight, vpos, first_unused_hpos) | |
495 int new_highlight, vpos, first_unused_hpos; | |
496 { | |
497 standout_requested = new_highlight; | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
498 if (! FRAME_TERMCAP_P (updating_frame)) |
253 | 499 { |
500 (*change_line_highlight_hook) (new_highlight, vpos, first_unused_hpos); | |
501 return; | |
502 } | |
503 | |
504 cursor_to (vpos, 0); | |
505 | |
506 if (TN_standout_width < 0) | |
507 background_highlight (); | |
508 /* If line starts with a marker, delete the marker */ | |
509 else if (TS_clr_line && chars_wasted[curY]) | |
510 { | |
511 turn_off_insert (); | |
512 /* On Teleray, make sure to erase the SO marker. */ | |
513 if (TF_teleray) | |
514 { | |
765 | 515 cmgoto (curY - 1, FRAME_WIDTH (selected_frame) - 4); |
253 | 516 OUTPUT ("\033S"); |
517 curY++; /* ESC S moves to next line where the TS_standout_mode was */ | |
518 curX = 0; | |
519 } | |
520 else | |
521 cmgoto (curY, 0); /* reposition to kill standout marker */ | |
522 } | |
523 clear_end_of_line_raw (first_unused_hpos); | |
524 reassert_line_highlight (new_highlight, curY); | |
525 } | |
526 | |
527 | |
528 /* Move to absolute position, specified origin 0 */ | |
529 | |
530 cursor_to (row, col) | |
621 | 531 int row, col; |
253 | 532 { |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
533 if (! FRAME_TERMCAP_P ((updating_frame |
765 | 534 ? updating_frame |
535 : selected_frame)) | |
253 | 536 && cursor_to_hook) |
537 { | |
538 (*cursor_to_hook) (row, col); | |
539 return; | |
540 } | |
541 | |
542 col += chars_wasted[row] & 077; | |
543 if (curY == row && curX == col) | |
544 return; | |
545 if (!TF_standout_motion) | |
546 background_highlight (); | |
547 if (!TF_insmode_motion) | |
548 turn_off_insert (); | |
549 cmgoto (row, col); | |
550 } | |
551 | |
552 /* Similar but don't take any account of the wasted characters. */ | |
553 | |
554 raw_cursor_to (row, col) | |
621 | 555 int row, col; |
253 | 556 { |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
557 if (! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame))) |
253 | 558 { |
559 (*raw_cursor_to_hook) (row, col); | |
560 return; | |
561 } | |
562 if (curY == row && curX == col) | |
563 return; | |
564 if (!TF_standout_motion) | |
565 background_highlight (); | |
566 if (!TF_insmode_motion) | |
567 turn_off_insert (); | |
568 cmgoto (row, col); | |
569 } | |
570 | |
571 /* Erase operations */ | |
572 | |
765 | 573 /* clear from cursor to end of frame */ |
253 | 574 clear_to_end () |
575 { | |
576 register int i; | |
577 | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
578 if (clear_to_end_hook && FRAME_TERMCAP_P (updating_frame)) |
253 | 579 { |
580 (*clear_to_end_hook) (); | |
581 return; | |
582 } | |
583 if (TS_clr_to_bottom) | |
584 { | |
585 background_highlight (); | |
586 OUTPUT (TS_clr_to_bottom); | |
765 | 587 bzero (chars_wasted + curY, FRAME_HEIGHT (selected_frame) - curY); |
253 | 588 } |
589 else | |
590 { | |
765 | 591 for (i = curY; i < FRAME_HEIGHT (selected_frame); i++) |
253 | 592 { |
593 cursor_to (i, 0); | |
765 | 594 clear_end_of_line_raw (FRAME_WIDTH (selected_frame)); |
253 | 595 } |
596 } | |
597 } | |
598 | |
765 | 599 /* Clear entire frame */ |
253 | 600 |
765 | 601 clear_frame () |
253 | 602 { |
765 | 603 if (clear_frame_hook |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
604 && ! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame))) |
253 | 605 { |
765 | 606 (*clear_frame_hook) (); |
253 | 607 return; |
608 } | |
765 | 609 if (TS_clr_frame) |
253 | 610 { |
611 background_highlight (); | |
765 | 612 OUTPUT (TS_clr_frame); |
613 bzero (chars_wasted, FRAME_HEIGHT (selected_frame)); | |
253 | 614 cmat (0, 0); |
615 } | |
616 else | |
617 { | |
618 cursor_to (0, 0); | |
619 clear_to_end (); | |
620 } | |
621 } | |
622 | |
623 /* Clear to end of line, but do not clear any standout marker. | |
624 Assumes that the cursor is positioned at a character of real text, | |
625 which implies it cannot be before a standout marker | |
626 unless the marker has zero width. | |
627 | |
628 Note that the cursor may be moved. */ | |
629 | |
630 clear_end_of_line (first_unused_hpos) | |
631 int first_unused_hpos; | |
632 { | |
1015
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
633 static GLYPH buf = SPACEGLYPH; |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
634 if (FRAME_TERMCAP_P (selected_frame) |
253 | 635 && TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0) |
1015
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
636 write_glyphs (&buf, 1); |
253 | 637 clear_end_of_line_raw (first_unused_hpos); |
638 } | |
639 | |
640 /* Clear from cursor to end of line. | |
641 Assume that the line is already clear starting at column first_unused_hpos. | |
642 If the cursor is at a standout marker, erase the marker. | |
643 | |
644 Note that the cursor may be moved, on terminals lacking a `ce' string. */ | |
645 | |
646 clear_end_of_line_raw (first_unused_hpos) | |
647 int first_unused_hpos; | |
648 { | |
649 register int i; | |
650 | |
651 if (clear_end_of_line_hook | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
652 && ! FRAME_TERMCAP_P ((updating_frame |
765 | 653 ? updating_frame |
654 : selected_frame))) | |
253 | 655 { |
656 (*clear_end_of_line_hook) (first_unused_hpos); | |
657 return; | |
658 } | |
659 | |
660 first_unused_hpos += chars_wasted[curY] & 077; | |
661 if (curX >= first_unused_hpos) | |
662 return; | |
663 /* Notice if we are erasing a magic cookie */ | |
664 if (curX == 0) | |
665 chars_wasted[curY] = 0; | |
666 background_highlight (); | |
667 if (TS_clr_line) | |
668 { | |
669 OUTPUT1 (TS_clr_line); | |
670 } | |
671 else | |
672 { /* have to do it the hard way */ | |
673 turn_off_insert (); | |
674 | |
675 /* Do not write in last row last col with Autowrap on. */ | |
765 | 676 if (AutoWrap && curY == FRAME_HEIGHT (selected_frame) - 1 |
677 && first_unused_hpos == FRAME_WIDTH (selected_frame)) | |
253 | 678 first_unused_hpos--; |
679 | |
680 for (i = curX; i < first_unused_hpos; i++) | |
681 { | |
682 if (termscript) | |
683 fputc (' ', termscript); | |
684 putchar (' '); | |
685 } | |
686 cmplus (first_unused_hpos - curX); | |
687 } | |
688 } | |
689 | |
690 | |
691 write_glyphs (string, len) | |
692 register GLYPH *string; | |
693 register int len; | |
694 { | |
695 register GLYPH g; | |
696 register int tlen = GLYPH_TABLE_LENGTH; | |
697 register Lisp_Object *tbase = GLYPH_TABLE_BASE; | |
698 | |
699 if (write_glyphs_hook | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
700 && ! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame))) |
253 | 701 { |
702 (*write_glyphs_hook) (string, len); | |
703 return; | |
704 } | |
705 | |
706 highlight_if_desired (); | |
707 turn_off_insert (); | |
708 | |
709 /* Don't dare write in last column of bottom line, if AutoWrap, | |
765 | 710 since that would scroll the whole frame on some terminals. */ |
253 | 711 |
712 if (AutoWrap | |
765 | 713 && curY + 1 == FRAME_HEIGHT (selected_frame) |
253 | 714 && (curX + len - (chars_wasted[curY] & 077) |
765 | 715 == FRAME_WIDTH (selected_frame))) |
253 | 716 len --; |
717 | |
718 cmplus (len); | |
719 while (--len >= 0) | |
720 { | |
721 g = *string++; | |
722 /* Check quickly for G beyond length of table. | |
723 That implies it isn't an alias and is simple. */ | |
724 if (g >= tlen) | |
725 { | |
726 simple: | |
727 putc (g & 0xff, stdout); | |
728 if (ferror (stdout)) | |
729 clearerr (stdout); | |
730 if (termscript) | |
731 putc (g & 0xff, termscript); | |
732 } | |
733 else | |
734 { | |
735 /* G has an entry in Vglyph_table, | |
736 so process any alias and then test for simpleness. */ | |
737 while (GLYPH_ALIAS_P (tbase, tlen, g)) | |
738 g = GLYPH_ALIAS (tbase, g); | |
739 if (GLYPH_SIMPLE_P (tbase, tlen, g)) | |
740 goto simple; | |
741 else | |
742 { | |
743 /* Here if G (or its definition as an alias) is not simple. */ | |
744 fwrite (GLYPH_STRING (tbase, g), 1, GLYPH_LENGTH (tbase, g), | |
745 stdout); | |
746 if (ferror (stdout)) | |
747 clearerr (stdout); | |
748 if (termscript) | |
749 fwrite (GLYPH_STRING (tbase, g), 1, GLYPH_LENGTH (tbase, g), | |
750 termscript); | |
751 } | |
752 } | |
753 } | |
754 } | |
755 | |
756 /* If start is zero, insert blanks instead of a string at start */ | |
757 | |
758 insert_glyphs (start, len) | |
759 register GLYPH *start; | |
760 register int len; | |
761 { | |
762 char *buf; | |
763 register GLYPH g; | |
764 register int tlen = GLYPH_TABLE_LENGTH; | |
765 register Lisp_Object *tbase = GLYPH_TABLE_BASE; | |
766 | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
767 if (insert_glyphs_hook && ! FRAME_TERMCAP_P (updating_frame)) |
253 | 768 { |
769 (*insert_glyphs_hook) (start, len); | |
770 return; | |
771 } | |
772 highlight_if_desired (); | |
773 | |
774 if (TS_ins_multi_chars) | |
775 { | |
776 buf = tparam (TS_ins_multi_chars, 0, 0, len); | |
777 OUTPUT1 (buf); | |
778 free (buf); | |
779 if (start) | |
780 write_glyphs (start, len); | |
781 return; | |
782 } | |
783 | |
784 turn_on_insert (); | |
785 cmplus (len); | |
786 while (--len >= 0) | |
787 { | |
788 OUTPUT1_IF (TS_ins_char); | |
789 if (!start) | |
790 g = SPACEGLYPH; | |
791 else | |
792 g = *start++; | |
793 | |
794 if (GLYPH_SIMPLE_P (tbase, tlen, g)) | |
795 { | |
796 putc (g & 0xff, stdout); | |
797 if (ferror (stdout)) | |
798 clearerr (stdout); | |
799 if (termscript) | |
800 putc (g & 0xff, termscript); | |
801 } | |
802 else | |
803 { | |
804 fwrite (GLYPH_STRING (tbase, g), 1, GLYPH_LENGTH (tbase, g), stdout); | |
805 if (ferror (stdout)) | |
806 clearerr (stdout); | |
807 if (termscript) | |
808 fwrite (GLYPH_STRING (tbase, g), 1, GLYPH_LENGTH (tbase, g), | |
809 termscript); | |
810 } | |
811 | |
812 OUTPUT1_IF (TS_pad_inserted_char); | |
813 } | |
814 } | |
815 | |
816 delete_glyphs (n) | |
817 register int n; | |
818 { | |
819 char *buf; | |
820 register int i; | |
821 | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
822 if (delete_glyphs_hook && ! FRAME_TERMCAP_P (updating_frame)) |
253 | 823 { |
824 (*delete_glyphs_hook) (n); | |
825 return; | |
826 } | |
827 | |
828 if (delete_in_insert_mode) | |
829 { | |
830 turn_on_insert (); | |
831 } | |
832 else | |
833 { | |
834 turn_off_insert (); | |
835 OUTPUT_IF (TS_delete_mode); | |
836 } | |
837 | |
838 if (TS_del_multi_chars) | |
839 { | |
840 buf = tparam (TS_del_multi_chars, 0, 0, n); | |
841 OUTPUT1 (buf); | |
842 free (buf); | |
843 } | |
844 else | |
845 for (i = 0; i < n; i++) | |
846 OUTPUT1 (TS_del_char); | |
847 if (!delete_in_insert_mode) | |
848 OUTPUT_IF (TS_end_delete_mode); | |
849 } | |
850 | |
851 /* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */ | |
852 | |
853 ins_del_lines (vpos, n) | |
854 int vpos, n; | |
855 { | |
856 char *multi = n > 0 ? TS_ins_multi_lines : TS_del_multi_lines; | |
857 char *single = n > 0 ? TS_ins_line : TS_del_line; | |
858 char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll; | |
859 | |
860 register int i = n > 0 ? n : -n; | |
861 register char *buf; | |
862 | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
863 if (ins_del_lines_hook && ! FRAME_TERMCAP_P (updating_frame)) |
253 | 864 { |
865 (*ins_del_lines_hook) (vpos, n); | |
866 return; | |
867 } | |
868 | |
869 /* If the lines below the insertion are being pushed | |
870 into the end of the window, this is the same as clearing; | |
871 and we know the lines are already clear, since the matching | |
872 deletion has already been done. So can ignore this. */ | |
873 /* If the lines below the deletion are blank lines coming | |
874 out of the end of the window, don't bother, | |
875 as there will be a matching inslines later that will flush them. */ | |
876 if (scroll_region_ok && vpos + i >= specified_window) | |
877 return; | |
765 | 878 if (!memory_below_frame && vpos + i >= FRAME_HEIGHT (selected_frame)) |
253 | 879 return; |
880 | |
881 if (multi) | |
882 { | |
883 raw_cursor_to (vpos, 0); | |
884 background_highlight (); | |
885 buf = tparam (multi, 0, 0, i); | |
886 OUTPUT (buf); | |
887 free (buf); | |
888 } | |
889 else if (single) | |
890 { | |
891 raw_cursor_to (vpos, 0); | |
892 background_highlight (); | |
893 while (--i >= 0) | |
894 OUTPUT (single); | |
895 if (TF_teleray) | |
896 curX = 0; | |
897 } | |
898 else | |
899 { | |
900 set_scroll_region (vpos, specified_window); | |
901 if (n < 0) | |
902 raw_cursor_to (specified_window - 1, 0); | |
903 else | |
904 raw_cursor_to (vpos, 0); | |
905 background_highlight (); | |
906 while (--i >= 0) | |
907 OUTPUTL (scroll, specified_window - vpos); | |
908 set_scroll_region (0, specified_window); | |
909 } | |
910 | |
911 if (TN_standout_width >= 0) | |
912 { | |
913 register lower_limit | |
914 = (scroll_region_ok | |
915 ? specified_window | |
765 | 916 : FRAME_HEIGHT (selected_frame)); |
253 | 917 |
918 if (n < 0) | |
919 { | |
920 bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos], | |
921 lower_limit - vpos + n); | |
922 bzero (&chars_wasted[lower_limit + n], - n); | |
923 } | |
924 else | |
925 { | |
926 bcopy (&chars_wasted[vpos], ©buf[vpos], lower_limit - vpos - n); | |
927 bcopy (©buf[vpos], &chars_wasted[vpos + n], | |
928 lower_limit - vpos - n); | |
929 bzero (&chars_wasted[vpos], n); | |
930 } | |
931 } | |
765 | 932 if (!scroll_region_ok && memory_below_frame && n < 0) |
253 | 933 { |
765 | 934 cursor_to (FRAME_HEIGHT (selected_frame) + n, 0); |
253 | 935 clear_to_end (); |
936 } | |
937 } | |
938 | |
939 /* Compute cost of sending "str", in characters, | |
940 not counting any line-dependent padding. */ | |
941 | |
942 int | |
943 string_cost (str) | |
944 char *str; | |
945 { | |
946 cost = 0; | |
947 if (str) | |
948 tputs (str, 0, evalcost); | |
949 return cost; | |
950 } | |
951 | |
952 /* Compute cost of sending "str", in characters, | |
953 counting any line-dependent padding at one line. */ | |
954 | |
955 static int | |
956 string_cost_one_line (str) | |
957 char *str; | |
958 { | |
959 cost = 0; | |
960 if (str) | |
961 tputs (str, 1, evalcost); | |
962 return cost; | |
963 } | |
964 | |
965 /* Compute per line amount of line-dependent padding, | |
966 in tenths of characters. */ | |
967 | |
968 int | |
969 per_line_cost (str) | |
970 register char *str; | |
971 { | |
972 cost = 0; | |
973 if (str) | |
974 tputs (str, 0, evalcost); | |
975 cost = - cost; | |
976 if (str) | |
977 tputs (str, 10, evalcost); | |
978 return cost; | |
979 } | |
980 | |
981 #ifndef old | |
982 /* char_ins_del_cost[n] is cost of inserting N characters. | |
983 char_ins_del_cost[-n] is cost of deleting N characters. */ | |
984 | |
985 int *char_ins_del_vector; | |
986 | |
765 | 987 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH ((f))]) |
253 | 988 #endif |
989 | |
990 /* ARGSUSED */ | |
991 static void | |
765 | 992 calculate_ins_del_char_costs (frame) |
993 FRAME_PTR frame; | |
253 | 994 { |
995 int ins_startup_cost, del_startup_cost; | |
996 int ins_cost_per_char, del_cost_per_char; | |
997 register int i; | |
998 register int *p; | |
999 | |
1000 if (TS_ins_multi_chars) | |
1001 { | |
1002 ins_cost_per_char = 0; | |
1003 ins_startup_cost = string_cost_one_line (TS_ins_multi_chars); | |
1004 } | |
1005 else if (TS_ins_char || TS_pad_inserted_char | |
1006 || (TS_insert_mode && TS_end_insert_mode)) | |
1007 { | |
1008 ins_startup_cost = (30 * (string_cost (TS_insert_mode) | |
1009 + string_cost (TS_end_insert_mode))) / 100; | |
1010 ins_cost_per_char = (string_cost_one_line (TS_ins_char) | |
1011 + string_cost_one_line (TS_pad_inserted_char)); | |
1012 } | |
1013 else | |
1014 { | |
1015 ins_startup_cost = 9999; | |
1016 ins_cost_per_char = 0; | |
1017 } | |
1018 | |
1019 if (TS_del_multi_chars) | |
1020 { | |
1021 del_cost_per_char = 0; | |
1022 del_startup_cost = string_cost_one_line (TS_del_multi_chars); | |
1023 } | |
1024 else if (TS_del_char) | |
1025 { | |
1026 del_startup_cost = (string_cost (TS_delete_mode) | |
1027 + string_cost (TS_end_delete_mode)); | |
1028 if (delete_in_insert_mode) | |
1029 del_startup_cost /= 2; | |
1030 del_cost_per_char = string_cost_one_line (TS_del_char); | |
1031 } | |
1032 else | |
1033 { | |
1034 del_startup_cost = 9999; | |
1035 del_cost_per_char = 0; | |
1036 } | |
1037 | |
1038 /* Delete costs are at negative offsets */ | |
765 | 1039 p = &char_ins_del_cost (frame)[0]; |
1040 for (i = FRAME_WIDTH (selected_frame); --i >= 0;) | |
253 | 1041 *--p = (del_startup_cost += del_cost_per_char); |
1042 | |
1043 /* Doing nothing is free */ | |
765 | 1044 p = &char_ins_del_cost (frame)[0]; |
253 | 1045 *p++ = 0; |
1046 | |
1047 /* Insert costs are at positive offsets */ | |
765 | 1048 for (i = FRAME_WIDTH (frame); --i >= 0;) |
253 | 1049 *p++ = (ins_startup_cost += ins_cost_per_char); |
1050 } | |
1051 | |
1052 #ifdef HAVE_X_WINDOWS | |
797 | 1053 extern int x_screen_planes; |
253 | 1054 #endif |
1055 | |
765 | 1056 calculate_costs (frame) |
1057 FRAME_PTR frame; | |
253 | 1058 { |
765 | 1059 register char *f = TS_set_scroll_region ? |
253 | 1060 TS_set_scroll_region |
1061 : TS_set_scroll_region_1; | |
1062 | |
1063 if (dont_calculate_costs) | |
1064 return; | |
1065 | |
1066 #ifdef HAVE_X_WINDOWS | |
969
16649ee21625
* term.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
797
diff
changeset
|
1067 if (FRAME_X_P (frame)) |
253 | 1068 { |
765 | 1069 do_line_insertion_deletion_costs (frame, 0, ".5*", 0, ".5*", |
797 | 1070 0, 0, x_screen_planes); |
253 | 1071 return; |
1072 } | |
1073 #endif | |
1074 | |
1075 /* These variables are only used for terminal stuff. They are allocated | |
765 | 1076 once for the terminal frame of X-windows emacs, but not used afterwards. |
253 | 1077 |
1078 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because | |
1079 X turns off char_ins_del_ok. | |
1080 | |
1081 chars_wasted and copybuf are only used here in term.c in cases where | |
1082 the term hook isn't called. */ | |
1083 | |
1084 if (chars_wasted != 0) | |
765 | 1085 chars_wasted = (char *) xrealloc (chars_wasted, FRAME_HEIGHT (frame)); |
253 | 1086 else |
765 | 1087 chars_wasted = (char *) xmalloc (FRAME_HEIGHT (frame)); |
253 | 1088 |
1089 if (copybuf != 0) | |
765 | 1090 copybuf = (char *) xrealloc (copybuf, FRAME_HEIGHT (frame)); |
253 | 1091 else |
765 | 1092 copybuf = (char *) xmalloc (FRAME_HEIGHT (frame)); |
253 | 1093 |
1094 if (char_ins_del_vector != 0) | |
1095 char_ins_del_vector | |
1096 = (int *) xrealloc (char_ins_del_vector, | |
1097 (sizeof (int) | |
765 | 1098 + 2 * FRAME_WIDTH (frame) * sizeof (int))); |
253 | 1099 else |
1100 char_ins_del_vector | |
1101 = (int *) xmalloc (sizeof (int) | |
765 | 1102 + 2 * FRAME_WIDTH (frame) * sizeof (int)); |
253 | 1103 |
765 | 1104 bzero (chars_wasted, FRAME_HEIGHT (frame)); |
1105 bzero (copybuf, FRAME_HEIGHT (frame)); | |
253 | 1106 bzero (char_ins_del_vector, (sizeof (int) |
765 | 1107 + 2 * FRAME_WIDTH (frame) * sizeof (int))); |
253 | 1108 |
765 | 1109 if (f && (!TS_ins_line && !TS_del_line)) |
1110 do_line_insertion_deletion_costs (frame, | |
253 | 1111 TS_rev_scroll, TS_ins_multi_lines, |
1112 TS_fwd_scroll, TS_del_multi_lines, | |
765 | 1113 f, f, 1); |
253 | 1114 else |
765 | 1115 do_line_insertion_deletion_costs (frame, |
253 | 1116 TS_ins_line, TS_ins_multi_lines, |
1117 TS_del_line, TS_del_multi_lines, | |
1118 0, 0, 1); | |
1119 | |
765 | 1120 calculate_ins_del_char_costs (frame); |
253 | 1121 |
1122 /* Don't use TS_repeat if its padding is worse than sending the chars */ | |
1123 if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000) | |
1124 RPov = string_cost (TS_repeat); | |
1125 else | |
765 | 1126 RPov = FRAME_WIDTH (frame) * 2; |
253 | 1127 |
1128 cmcostinit (); /* set up cursor motion costs */ | |
1129 } | |
1130 | |
533 | 1131 /* Find the escape codes sent by the function keys for Vfunction_key_map. |
1132 This function scans the termcap function key sequence entries, and | |
1133 adds entries to Vfunction_key_map for each function key it finds. */ | |
1134 | |
1015
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1135 struct fkey_table { |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1136 char *cap, *name; |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1137 }; |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1138 |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1139 static struct fkey_table keys[] = { |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1140 "kl", "left", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1141 "kr", "right", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1142 "ku", "up", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1143 "kd", "down", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1144 "K2", "center", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1145 "k1", "f1", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1146 "k2", "f2", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1147 "k3", "f3", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1148 "k4", "f4", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1149 "k5", "f5", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1150 "k6", "f6", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1151 "k7", "f7", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1152 "k8", "f8", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1153 "k9", "f9", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1154 "F1", "f11", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1155 "F2", "f12", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1156 "kh", "home", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1157 "kH", "home-down", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1158 "ka", "clear-tabs", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1159 "kt", "clear-tab", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1160 "kT", "set-tab", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1161 "kC", "clear", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1162 "kL", "deleteline", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1163 "kM", "exit-insert", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1164 "kE", "clear-eol", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1165 "kS", "clear-eos", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1166 "kI", "insert", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1167 "kA", "insertline", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1168 "kN", "next", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1169 "kP", "prior", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1170 "kF", "scroll-forward", |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1171 "kR", "scroll-reverse" |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1172 }; |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1173 |
533 | 1174 void |
1175 term_get_fkeys (address) | |
1176 char **address; | |
1177 { | |
1178 extern char *tgetstr (); | |
1179 int i; | |
1180 | |
1181 for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) | |
1182 { | |
1183 char *sequence = tgetstr (keys[i].cap, address); | |
1184 if (sequence) | |
1185 Fdefine_key (Vfunction_key_map, | |
1186 build_string (sequence), | |
1187 Fmake_vector (make_number (1), intern (keys[i].name))); | |
1188 } | |
1015
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1189 |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1190 /* The uses of the "k0" capability are inconsistent; sometimes it |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1191 describes F10, whereas othertimes it describes F0 and "k;" describes F10. |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1192 We will attempt to politely accomodate both systems by testing for |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1193 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1194 */ |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1195 { |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1196 char *k_semi = tgetstr ("k;", address); |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1197 char *k0 = tgetstr ("k0", address); |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1198 char *k0_name = "f10"; |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1199 |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1200 if (k_semi) |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1201 { |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1202 Fdefine_key (Vfunction_key_map, |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1203 build_string (k_semi), |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1204 Fmake_vector (make_number (1), intern ("f10"))); |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1205 k0_name = "f0"; |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1206 } |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1207 |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1208 if (k0) |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1209 Fdefine_key (Vfunction_key_map, |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1210 build_string (k0), |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1211 Fmake_vector (make_number (1), intern (k0_name))); |
58c373be762c
* term.c (term_get_fkeys): Some systems define `static' to be the
Jim Blandy <jimb@redhat.com>
parents:
969
diff
changeset
|
1212 } |
533 | 1213 } |
1214 | |
1215 | |
253 | 1216 term_init (terminal_type) |
1217 char *terminal_type; | |
1218 { | |
1219 char *area; | |
1220 char **address = &area; | |
1221 char buffer[2044]; | |
1222 register char *p; | |
1223 int status; | |
1224 | |
1225 extern char *tgetstr (); | |
1226 | |
1227 Wcm_clear (); | |
1228 dont_calculate_costs = 0; | |
1229 | |
1230 status = tgetent (buffer, terminal_type); | |
1231 if (status < 0) | |
1232 fatal ("Cannot open termcap database file.\n"); | |
1233 if (status == 0) | |
1234 fatal ("Terminal type %s is not defined.\n", terminal_type); | |
1235 | |
1236 #ifdef TERMINFO | |
1237 area = (char *) malloc (2044); | |
1238 #else | |
1239 area = (char *) malloc (strlen (buffer)); | |
1240 #endif /* not TERMINFO */ | |
1241 if (area == 0) | |
1242 abort (); | |
1243 | |
1244 TS_ins_line = tgetstr ("al", address); | |
1245 TS_ins_multi_lines = tgetstr ("AL", address); | |
1246 TS_bell = tgetstr ("bl", address); | |
1247 BackTab = tgetstr ("bt", address); | |
1248 TS_clr_to_bottom = tgetstr ("cd", address); | |
1249 TS_clr_line = tgetstr ("ce", address); | |
765 | 1250 TS_clr_frame = tgetstr ("cl", address); |
253 | 1251 ColPosition = tgetstr ("ch", address); |
1252 AbsPosition = tgetstr ("cm", address); | |
1253 CR = tgetstr ("cr", address); | |
1254 TS_set_scroll_region = tgetstr ("cs", address); | |
1255 TS_set_scroll_region_1 = tgetstr ("cS", address); | |
1256 RowPosition = tgetstr ("cv", address); | |
1257 TS_del_char = tgetstr ("dc", address); | |
1258 TS_del_multi_chars = tgetstr ("DC", address); | |
1259 TS_del_line = tgetstr ("dl", address); | |
1260 TS_del_multi_lines = tgetstr ("DL", address); | |
1261 TS_delete_mode = tgetstr ("dm", address); | |
1262 TS_end_delete_mode = tgetstr ("ed", address); | |
1263 TS_end_insert_mode = tgetstr ("ei", address); | |
1264 Home = tgetstr ("ho", address); | |
1265 TS_ins_char = tgetstr ("ic", address); | |
1266 TS_ins_multi_chars = tgetstr ("IC", address); | |
1267 TS_insert_mode = tgetstr ("im", address); | |
1268 TS_pad_inserted_char = tgetstr ("ip", address); | |
1269 TS_end_keypad_mode = tgetstr ("ke", address); | |
1270 TS_keypad_mode = tgetstr ("ks", address); | |
1271 LastLine = tgetstr ("ll", address); | |
1272 Right = tgetstr ("nd", address); | |
1273 Down = tgetstr ("do", address); | |
1274 if (!Down) | |
1275 Down = tgetstr ("nl", address); /* Obsolete name for "do" */ | |
1276 #ifdef VMS | |
1277 /* VMS puts a carriage return before each linefeed, | |
1278 so it is not safe to use linefeeds. */ | |
1279 if (Down && Down[0] == '\n' && Down[1] == '\0') | |
1280 Down = 0; | |
1281 #endif /* VMS */ | |
1282 if (tgetflag ("bs")) | |
1283 Left = "\b"; /* can't possibly be longer! */ | |
1284 else /* (Actually, "bs" is obsolete...) */ | |
1285 Left = tgetstr ("le", address); | |
1286 if (!Left) | |
1287 Left = tgetstr ("bc", address); /* Obsolete name for "le" */ | |
1288 TS_pad_char = tgetstr ("pc", address); | |
1289 TS_repeat = tgetstr ("rp", address); | |
1290 TS_end_standout_mode = tgetstr ("se", address); | |
1291 TS_fwd_scroll = tgetstr ("sf", address); | |
1292 TS_standout_mode = tgetstr ("so", address); | |
1293 TS_rev_scroll = tgetstr ("sr", address); | |
1294 Wcm.cm_tab = tgetstr ("ta", address); | |
1295 TS_end_termcap_modes = tgetstr ("te", address); | |
1296 TS_termcap_modes = tgetstr ("ti", address); | |
1297 Up = tgetstr ("up", address); | |
1298 TS_visible_bell = tgetstr ("vb", address); | |
1299 TS_end_visual_mode = tgetstr ("ve", address); | |
1300 TS_visual_mode = tgetstr ("vs", address); | |
1301 TS_set_window = tgetstr ("wi", address); | |
1302 MultiUp = tgetstr ("UP", address); | |
1303 MultiDown = tgetstr ("DO", address); | |
1304 MultiLeft = tgetstr ("LE", address); | |
1305 MultiRight = tgetstr ("RI", address); | |
1306 | |
1307 AutoWrap = tgetflag ("am"); | |
765 | 1308 memory_below_frame = tgetflag ("db"); |
253 | 1309 TF_hazeltine = tgetflag ("hz"); |
1310 must_write_spaces = tgetflag ("in"); | |
1311 meta_key = tgetflag ("km") || tgetflag ("MT"); | |
1312 TF_insmode_motion = tgetflag ("mi"); | |
1313 TF_standout_motion = tgetflag ("ms"); | |
1314 TF_underscore = tgetflag ("ul"); | |
1315 MagicWrap = tgetflag ("xn"); | |
1316 TF_xs = tgetflag ("xs"); | |
1317 TF_teleray = tgetflag ("xt"); | |
1318 | |
533 | 1319 term_get_fkeys (address); |
1320 | |
765 | 1321 /* Get frame size from system, or else from termcap. */ |
1322 get_frame_size (&FRAME_WIDTH (selected_frame), | |
1323 &FRAME_HEIGHT (selected_frame)); | |
1324 if (FRAME_WIDTH (selected_frame) <= 0) | |
1325 FRAME_WIDTH (selected_frame) = tgetnum ("co"); | |
1326 if (FRAME_HEIGHT (selected_frame) <= 0) | |
1327 FRAME_HEIGHT (selected_frame) = tgetnum ("li"); | |
253 | 1328 |
1329 min_padding_speed = tgetnum ("pb"); | |
1330 TN_standout_width = tgetnum ("sg"); | |
1331 TabWidth = tgetnum ("tw"); | |
1332 | |
1333 #ifdef VMS | |
1334 /* These capabilities commonly use ^J. | |
1335 I don't know why, but sending them on VMS does not work; | |
1336 it causes following spaces to be lost, sometimes. | |
1337 For now, the simplest fix is to avoid using these capabilities ever. */ | |
1338 if (Down && Down[0] == '\n') | |
1339 Down = 0; | |
1340 #endif /* VMS */ | |
1341 | |
1342 if (!TS_bell) | |
1343 TS_bell = "\07"; | |
1344 | |
1345 if (!TS_fwd_scroll) | |
1346 TS_fwd_scroll = Down; | |
1347 | |
1348 PC = TS_pad_char ? *TS_pad_char : 0; | |
1349 | |
1350 if (TabWidth < 0) | |
1351 TabWidth = 8; | |
1352 | |
1353 /* Turned off since /etc/termcap seems to have :ta= for most terminals | |
1354 and newer termcap doc does not seem to say there is a default. | |
1355 if (!Wcm.cm_tab) | |
1356 Wcm.cm_tab = "\t"; | |
1357 */ | |
1358 | |
1359 if (TS_standout_mode == 0) | |
1360 { | |
1361 TN_standout_width = tgetnum ("ug"); | |
1362 TS_end_standout_mode = tgetstr ("ue", address); | |
1363 TS_standout_mode = tgetstr ("us", address); | |
1364 } | |
1365 | |
1366 if (TF_teleray) | |
1367 { | |
1368 Wcm.cm_tab = 0; | |
1369 /* Teleray: most programs want a space in front of TS_standout_mode, | |
1370 but Emacs can do without it (and give one extra column). */ | |
1371 TS_standout_mode = "\033RD"; | |
1372 TN_standout_width = 1; | |
1373 /* But that means we cannot rely on ^M to go to column zero! */ | |
1374 CR = 0; | |
1375 /* LF can't be trusted either -- can alter hpos */ | |
1376 /* if move at column 0 thru a line with TS_standout_mode */ | |
1377 Down = 0; | |
1378 } | |
1379 | |
1380 /* Special handling for certain terminal types known to need it */ | |
1381 | |
1382 if (!strcmp (terminal_type, "supdup")) | |
1383 { | |
765 | 1384 memory_below_frame = 1; |
253 | 1385 Wcm.cm_losewrap = 1; |
1386 } | |
1387 if (!strncmp (terminal_type, "c10", 3) | |
1388 || !strcmp (terminal_type, "perq")) | |
1389 { | |
1390 /* Supply a makeshift :wi string. | |
1391 This string is not valid in general since it works only | |
1392 for windows starting at the upper left corner; | |
1393 but that is all Emacs uses. | |
1394 | |
765 | 1395 This string works only if the frame is using |
253 | 1396 the top of the video memory, because addressing is memory-relative. |
1397 So first check the :ti string to see if that is true. | |
1398 | |
1399 It would be simpler if the :wi string could go in the termcap | |
1400 entry, but it can't because it is not fully valid. | |
1401 If it were in the termcap entry, it would confuse other programs. */ | |
1402 if (!TS_set_window) | |
1403 { | |
1404 p = TS_termcap_modes; | |
1405 while (*p && strcmp (p, "\033v ")) | |
1406 p++; | |
1407 if (*p) | |
1408 TS_set_window = "\033v%C %C %C %C "; | |
1409 } | |
1410 /* Termcap entry often fails to have :in: flag */ | |
1411 must_write_spaces = 1; | |
1412 /* :ti string typically fails to have \E^G! in it */ | |
1413 /* This limits scope of insert-char to one line. */ | |
1414 strcpy (area, TS_termcap_modes); | |
1415 strcat (area, "\033\007!"); | |
1416 TS_termcap_modes = area; | |
1417 area += strlen (area) + 1; | |
1418 p = AbsPosition; | |
1419 /* Change all %+ parameters to %C, to handle | |
1420 values above 96 correctly for the C100. */ | |
1421 while (*p) | |
1422 { | |
1423 if (p[0] == '%' && p[1] == '+') | |
1424 p[1] = 'C'; | |
1425 p++; | |
1426 } | |
1427 } | |
1428 | |
765 | 1429 FrameRows = FRAME_HEIGHT (selected_frame); |
1430 FrameCols = FRAME_WIDTH (selected_frame); | |
1431 specified_window = FRAME_HEIGHT (selected_frame); | |
253 | 1432 |
1433 if (Wcm_init () == -1) /* can't do cursor motion */ | |
1434 #ifdef VMS | |
1435 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | |
1436 It lacks the ability to position the cursor.\n\ | |
1437 If that is not the actual type of terminal you have, use either the\n\ | |
1438 DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\ | |
1439 or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.\n", | |
1440 terminal_type); | |
1441 #else | |
1442 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | |
1443 It lacks the ability to position the cursor.\n\ | |
1444 If that is not the actual type of terminal you have,\n\ | |
1445 use the C-shell command `setenv TERM ...' to specify the correct type.\n\ | |
1446 It may be necessary to do `unsetenv TERMCAP' as well.\n", | |
1447 terminal_type); | |
1448 #endif | |
765 | 1449 if (FRAME_HEIGHT (selected_frame) <= 0 |
1450 || FRAME_WIDTH (selected_frame) <= 0) | |
1451 fatal ("The frame size has not been specified."); | |
253 | 1452 |
1453 delete_in_insert_mode | |
1454 = TS_delete_mode && TS_insert_mode | |
1455 && !strcmp (TS_delete_mode, TS_insert_mode); | |
1456 | |
1457 se_is_so = (TS_standout_mode | |
1458 && TS_end_standout_mode | |
1459 && !strcmp (TS_standout_mode, TS_end_standout_mode)); | |
1460 | |
1461 /* Remove width of standout marker from usable width of line */ | |
1462 if (TN_standout_width > 0) | |
765 | 1463 FRAME_WIDTH (selected_frame) -= TN_standout_width; |
253 | 1464 |
1465 UseTabs = tabs_safe_p () && TabWidth == 8; | |
1466 | |
1467 scroll_region_ok | |
1468 = (Wcm.cm_abs | |
1469 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1)); | |
1470 | |
1471 line_ins_del_ok = (((TS_ins_line || TS_ins_multi_lines) | |
1472 && (TS_del_line || TS_del_multi_lines)) | |
1473 || (scroll_region_ok && TS_fwd_scroll && TS_rev_scroll)); | |
1474 | |
1475 char_ins_del_ok = ((TS_ins_char || TS_insert_mode | |
1476 || TS_pad_inserted_char || TS_ins_multi_chars) | |
1477 && (TS_del_char || TS_del_multi_chars)); | |
1478 | |
1479 fast_clear_end_of_line = TS_clr_line != 0; | |
1480 | |
1481 init_baud_rate (); | |
1482 if (read_socket_hook) /* Baudrate is somewhat */ | |
1483 /* meaningless in this case */ | |
1484 baud_rate = 9600; | |
1717
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
1485 |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
1486 FRAME_CAN_HAVE_SCROLLBARS (selected_frame) = 0; |
aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents:
1015
diff
changeset
|
1487 FRAME_HAS_VERTICAL_SCROLLBARS (selected_frame) = 0; |
253 | 1488 } |
1489 | |
1490 /* VARARGS 1 */ | |
1491 fatal (str, arg1, arg2) | |
621 | 1492 char *str, *arg1, *arg2; |
253 | 1493 { |
1494 fprintf (stderr, "emacs: "); | |
1495 fprintf (stderr, str, arg1, arg2); | |
1496 fflush (stderr); | |
1497 exit (1); | |
1498 } |