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