diff options
| author | Joakim Verona | 2011-06-16 00:22:07 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-06-16 00:22:07 +0200 |
| commit | a7513ade3bc0fe79430d5541d88c9dcda0932bec (patch) | |
| tree | 4383951ba698a11e9f8933a9d8c72e00aa872a10 /src/term.c | |
| parent | 4bd51ad5c3445b644dfb017d5b57b10a90aa325f (diff) | |
| parent | 4bba86e6210a74326e843a8fdc8409127105e1fe (diff) | |
| download | emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.tar.gz emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.zip | |
merge from upstream
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 176 |
1 files changed, 84 insertions, 92 deletions
diff --git a/src/term.c b/src/term.c index 1aefe02421f..9205719b5f4 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -26,12 +26,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 26 | #include <sys/file.h> | 26 | #include <sys/file.h> |
| 27 | #include <unistd.h> | 27 | #include <unistd.h> |
| 28 | #include <signal.h> | 28 | #include <signal.h> |
| 29 | #include <stdarg.h> | ||
| 30 | #include <setjmp.h> | 29 | #include <setjmp.h> |
| 31 | 30 | ||
| 32 | #include "lisp.h" | 31 | #include "lisp.h" |
| 33 | #include "termchar.h" | 32 | #include "termchar.h" |
| 34 | #include "termopts.h" | 33 | #include "termopts.h" |
| 34 | #include "tparam.h" | ||
| 35 | #include "buffer.h" | 35 | #include "buffer.h" |
| 36 | #include "character.h" | 36 | #include "character.h" |
| 37 | #include "charset.h" | 37 | #include "charset.h" |
| @@ -53,18 +53,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 53 | static int been_here = -1; | 53 | static int been_here = -1; |
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | /* For now, don't try to include termcap.h. On some systems, | ||
| 57 | configure finds a non-standard termcap.h that the main build | ||
| 58 | won't find. */ | ||
| 59 | extern void tputs (const char *, int, int (*)(int)); | ||
| 60 | extern int tgetent (char *, const char *); | ||
| 61 | extern int tgetflag (char *id); | ||
| 62 | extern int tgetnum (char *id); | ||
| 63 | |||
| 64 | char *tparam (char *, char *, int, int, ...); | ||
| 65 | |||
| 66 | extern char *tgetstr (char *, char **); | ||
| 67 | |||
| 68 | #include "cm.h" | 56 | #include "cm.h" |
| 69 | #ifdef HAVE_X_WINDOWS | 57 | #ifdef HAVE_X_WINDOWS |
| 70 | #include "xterm.h" | 58 | #include "xterm.h" |
| @@ -88,16 +76,20 @@ extern char *tgetstr (char *, char **); | |||
| 88 | static void tty_set_scroll_region (struct frame *f, int start, int stop); | 76 | static void tty_set_scroll_region (struct frame *f, int start, int stop); |
| 89 | static void turn_on_face (struct frame *, int face_id); | 77 | static void turn_on_face (struct frame *, int face_id); |
| 90 | static void turn_off_face (struct frame *, int face_id); | 78 | static void turn_off_face (struct frame *, int face_id); |
| 79 | static void tty_turn_off_highlight (struct tty_display_info *); | ||
| 91 | static void tty_show_cursor (struct tty_display_info *); | 80 | static void tty_show_cursor (struct tty_display_info *); |
| 92 | static void tty_hide_cursor (struct tty_display_info *); | 81 | static void tty_hide_cursor (struct tty_display_info *); |
| 93 | static void tty_background_highlight (struct tty_display_info *tty); | 82 | static void tty_background_highlight (struct tty_display_info *tty); |
| 83 | static struct terminal *get_tty_terminal (Lisp_Object, int); | ||
| 94 | static void clear_tty_hooks (struct terminal *terminal); | 84 | static void clear_tty_hooks (struct terminal *terminal); |
| 95 | static void set_tty_hooks (struct terminal *terminal); | 85 | static void set_tty_hooks (struct terminal *terminal); |
| 96 | static void dissociate_if_controlling_tty (int fd); | 86 | static void dissociate_if_controlling_tty (int fd); |
| 97 | static void delete_tty (struct terminal *); | 87 | static void delete_tty (struct terminal *); |
| 98 | static void maybe_fatal (int must_succeed, struct terminal *terminal, | 88 | static void maybe_fatal (int must_succeed, struct terminal *terminal, |
| 99 | const char *str1, const char *str2, ...) NO_RETURN; | 89 | const char *str1, const char *str2, ...) |
| 100 | static void vfatal (const char *str, va_list ap) NO_RETURN; | 90 | NO_RETURN ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); |
| 91 | static void vfatal (const char *str, va_list ap) | ||
| 92 | NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0); | ||
| 101 | 93 | ||
| 102 | 94 | ||
| 103 | #define OUTPUT(tty, a) \ | 95 | #define OUTPUT(tty, a) \ |
| @@ -112,10 +104,7 @@ static void vfatal (const char *str, va_list ap) NO_RETURN; | |||
| 112 | #define OUTPUT_IF(tty, a) \ | 104 | #define OUTPUT_IF(tty, a) \ |
| 113 | do { \ | 105 | do { \ |
| 114 | if (a) \ | 106 | if (a) \ |
| 115 | emacs_tputs ((tty), a, \ | 107 | OUTPUT (tty, a); \ |
| 116 | (int) (FRAME_LINES (XFRAME (selected_frame)) \ | ||
| 117 | - curY (tty) ), \ | ||
| 118 | cmputc); \ | ||
| 119 | } while (0) | 108 | } while (0) |
| 120 | 109 | ||
| 121 | #define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0) | 110 | #define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0) |
| @@ -145,11 +134,11 @@ enum no_color_bit | |||
| 145 | 134 | ||
| 146 | /* The largest frame width in any call to calculate_costs. */ | 135 | /* The largest frame width in any call to calculate_costs. */ |
| 147 | 136 | ||
| 148 | int max_frame_cols; | 137 | static int max_frame_cols; |
| 149 | 138 | ||
| 150 | /* The largest frame height in any call to calculate_costs. */ | 139 | /* The largest frame height in any call to calculate_costs. */ |
| 151 | 140 | ||
| 152 | int max_frame_lines; | 141 | static int max_frame_lines; |
| 153 | 142 | ||
| 154 | /* Non-zero if we have dropped our controlling tty and therefore | 143 | /* Non-zero if we have dropped our controlling tty and therefore |
| 155 | should not open a frame on stdout. */ | 144 | should not open a frame on stdout. */ |
| @@ -185,7 +174,7 @@ tty_ring_bell (struct frame *f) | |||
| 185 | 174 | ||
| 186 | /* Set up termcap modes for Emacs. */ | 175 | /* Set up termcap modes for Emacs. */ |
| 187 | 176 | ||
| 188 | void | 177 | static void |
| 189 | tty_set_terminal_modes (struct terminal *terminal) | 178 | tty_set_terminal_modes (struct terminal *terminal) |
| 190 | { | 179 | { |
| 191 | struct tty_display_info *tty = terminal->display_info.tty; | 180 | struct tty_display_info *tty = terminal->display_info.tty; |
| @@ -213,7 +202,7 @@ tty_set_terminal_modes (struct terminal *terminal) | |||
| 213 | 202 | ||
| 214 | /* Reset termcap modes before exiting Emacs. */ | 203 | /* Reset termcap modes before exiting Emacs. */ |
| 215 | 204 | ||
| 216 | void | 205 | static void |
| 217 | tty_reset_terminal_modes (struct terminal *terminal) | 206 | tty_reset_terminal_modes (struct terminal *terminal) |
| 218 | { | 207 | { |
| 219 | struct tty_display_info *tty = terminal->display_info.tty; | 208 | struct tty_display_info *tty = terminal->display_info.tty; |
| @@ -265,7 +254,7 @@ tty_set_scroll_region (struct frame *f, int start, int stop) | |||
| 265 | struct tty_display_info *tty = FRAME_TTY (f); | 254 | struct tty_display_info *tty = FRAME_TTY (f); |
| 266 | 255 | ||
| 267 | if (tty->TS_set_scroll_region) | 256 | if (tty->TS_set_scroll_region) |
| 268 | buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); | 257 | buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0); |
| 269 | else if (tty->TS_set_scroll_region_1) | 258 | else if (tty->TS_set_scroll_region_1) |
| 270 | buf = tparam (tty->TS_set_scroll_region_1, 0, 0, | 259 | buf = tparam (tty->TS_set_scroll_region_1, 0, 0, |
| 271 | FRAME_LINES (f), start, | 260 | FRAME_LINES (f), start, |
| @@ -298,7 +287,7 @@ tty_turn_off_insert (struct tty_display_info *tty) | |||
| 298 | 287 | ||
| 299 | /* Handle highlighting. */ | 288 | /* Handle highlighting. */ |
| 300 | 289 | ||
| 301 | void | 290 | static void |
| 302 | tty_turn_off_highlight (struct tty_display_info *tty) | 291 | tty_turn_off_highlight (struct tty_display_info *tty) |
| 303 | { | 292 | { |
| 304 | if (tty->standout_mode) | 293 | if (tty->standout_mode) |
| @@ -547,8 +536,8 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 547 | { | 536 | { |
| 548 | if (src->type == COMPOSITE_GLYPH) | 537 | if (src->type == COMPOSITE_GLYPH) |
| 549 | { | 538 | { |
| 550 | struct composition *cmp; | 539 | struct composition *cmp IF_LINT (= NULL); |
| 551 | Lisp_Object gstring; | 540 | Lisp_Object gstring IF_LINT (= Qnil); |
| 552 | int i; | 541 | int i; |
| 553 | 542 | ||
| 554 | nbytes = buf - encode_terminal_src; | 543 | nbytes = buf - encode_terminal_src; |
| @@ -609,7 +598,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 609 | else if (! CHAR_GLYPH_PADDING_P (*src)) | 598 | else if (! CHAR_GLYPH_PADDING_P (*src)) |
| 610 | { | 599 | { |
| 611 | GLYPH g; | 600 | GLYPH g; |
| 612 | int c; | 601 | int c IF_LINT (= 0); |
| 613 | Lisp_Object string; | 602 | Lisp_Object string; |
| 614 | 603 | ||
| 615 | string = Qnil; | 604 | string = Qnil; |
| @@ -667,8 +656,6 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 667 | } | 656 | } |
| 668 | else | 657 | else |
| 669 | { | 658 | { |
| 670 | unsigned char *p = SDATA (string); | ||
| 671 | |||
| 672 | if (! STRING_MULTIBYTE (string)) | 659 | if (! STRING_MULTIBYTE (string)) |
| 673 | string = string_to_multibyte (string); | 660 | string = string_to_multibyte (string); |
| 674 | nbytes = buf - encode_terminal_src; | 661 | nbytes = buf - encode_terminal_src; |
| @@ -723,6 +710,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 723 | { | 710 | { |
| 724 | unsigned char *conversion_buffer; | 711 | unsigned char *conversion_buffer; |
| 725 | struct coding_system *coding; | 712 | struct coding_system *coding; |
| 713 | size_t n, stringlen; | ||
| 726 | 714 | ||
| 727 | struct tty_display_info *tty = FRAME_TTY (f); | 715 | struct tty_display_info *tty = FRAME_TTY (f); |
| 728 | 716 | ||
| @@ -750,13 +738,12 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 750 | the tail. */ | 738 | the tail. */ |
| 751 | coding->mode &= ~CODING_MODE_LAST_BLOCK; | 739 | coding->mode &= ~CODING_MODE_LAST_BLOCK; |
| 752 | 740 | ||
| 753 | while (len > 0) | 741 | for (stringlen = len; stringlen != 0; stringlen -= n) |
| 754 | { | 742 | { |
| 755 | /* Identify a run of glyphs with the same face. */ | 743 | /* Identify a run of glyphs with the same face. */ |
| 756 | int face_id = string->face_id; | 744 | int face_id = string->face_id; |
| 757 | int n; | ||
| 758 | 745 | ||
| 759 | for (n = 1; n < len; ++n) | 746 | for (n = 1; n < stringlen; ++n) |
| 760 | if (string[n].face_id != face_id) | 747 | if (string[n].face_id != face_id) |
| 761 | break; | 748 | break; |
| 762 | 749 | ||
| @@ -764,7 +751,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 764 | tty_highlight_if_desired (tty); | 751 | tty_highlight_if_desired (tty); |
| 765 | turn_on_face (f, face_id); | 752 | turn_on_face (f, face_id); |
| 766 | 753 | ||
| 767 | if (n == len) | 754 | if (n == stringlen) |
| 768 | /* This is the last run. */ | 755 | /* This is the last run. */ |
| 769 | coding->mode |= CODING_MODE_LAST_BLOCK; | 756 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 770 | conversion_buffer = encode_terminal_code (string, n, coding); | 757 | conversion_buffer = encode_terminal_code (string, n, coding); |
| @@ -778,7 +765,6 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 778 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); | 765 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); |
| 779 | UNBLOCK_INPUT; | 766 | UNBLOCK_INPUT; |
| 780 | } | 767 | } |
| 781 | len -= n; | ||
| 782 | string += n; | 768 | string += n; |
| 783 | 769 | ||
| 784 | /* Turn appearance modes off. */ | 770 | /* Turn appearance modes off. */ |
| @@ -864,7 +850,7 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len) | |||
| 864 | 850 | ||
| 865 | if (tty->TS_ins_multi_chars) | 851 | if (tty->TS_ins_multi_chars) |
| 866 | { | 852 | { |
| 867 | buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); | 853 | buf = tparam (tty->TS_ins_multi_chars, 0, 0, len, 0, 0, 0); |
| 868 | OUTPUT1 (tty, buf); | 854 | OUTPUT1 (tty, buf); |
| 869 | xfree (buf); | 855 | xfree (buf); |
| 870 | if (start) | 856 | if (start) |
| @@ -960,7 +946,7 @@ tty_delete_glyphs (struct frame *f, int n) | |||
| 960 | 946 | ||
| 961 | if (tty->TS_del_multi_chars) | 947 | if (tty->TS_del_multi_chars) |
| 962 | { | 948 | { |
| 963 | buf = tparam (tty->TS_del_multi_chars, 0, 0, n); | 949 | buf = tparam (tty->TS_del_multi_chars, 0, 0, n, 0, 0, 0); |
| 964 | OUTPUT1 (tty, buf); | 950 | OUTPUT1 (tty, buf); |
| 965 | xfree (buf); | 951 | xfree (buf); |
| 966 | } | 952 | } |
| @@ -977,9 +963,10 @@ static void | |||
| 977 | tty_ins_del_lines (struct frame *f, int vpos, int n) | 963 | tty_ins_del_lines (struct frame *f, int vpos, int n) |
| 978 | { | 964 | { |
| 979 | struct tty_display_info *tty = FRAME_TTY (f); | 965 | struct tty_display_info *tty = FRAME_TTY (f); |
| 980 | char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; | 966 | const char *multi = |
| 981 | char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; | 967 | n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; |
| 982 | char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; | 968 | const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; |
| 969 | const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; | ||
| 983 | 970 | ||
| 984 | register int i = n > 0 ? n : -n; | 971 | register int i = n > 0 ? n : -n; |
| 985 | register char *buf; | 972 | register char *buf; |
| @@ -1002,7 +989,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n) | |||
| 1002 | { | 989 | { |
| 1003 | raw_cursor_to (f, vpos, 0); | 990 | raw_cursor_to (f, vpos, 0); |
| 1004 | tty_background_highlight (tty); | 991 | tty_background_highlight (tty); |
| 1005 | buf = tparam (multi, 0, 0, i); | 992 | buf = tparam (multi, 0, 0, i, 0, 0, 0); |
| 1006 | OUTPUT (tty, buf); | 993 | OUTPUT (tty, buf); |
| 1007 | xfree (buf); | 994 | xfree (buf); |
| 1008 | } | 995 | } |
| @@ -1154,9 +1141,9 @@ calculate_costs (struct frame *frame) | |||
| 1154 | if (FRAME_TERMCAP_P (frame)) | 1141 | if (FRAME_TERMCAP_P (frame)) |
| 1155 | { | 1142 | { |
| 1156 | struct tty_display_info *tty = FRAME_TTY (frame); | 1143 | struct tty_display_info *tty = FRAME_TTY (frame); |
| 1157 | register char *f = (tty->TS_set_scroll_region | 1144 | register const char *f = (tty->TS_set_scroll_region |
| 1158 | ? tty->TS_set_scroll_region | 1145 | ? tty->TS_set_scroll_region |
| 1159 | : tty->TS_set_scroll_region_1); | 1146 | : tty->TS_set_scroll_region_1); |
| 1160 | 1147 | ||
| 1161 | FRAME_SCROLL_REGION_COST (frame) = string_cost (f); | 1148 | FRAME_SCROLL_REGION_COST (frame) = string_cost (f); |
| 1162 | 1149 | ||
| @@ -1210,7 +1197,7 @@ calculate_costs (struct frame *frame) | |||
| 1210 | } | 1197 | } |
| 1211 | 1198 | ||
| 1212 | struct fkey_table { | 1199 | struct fkey_table { |
| 1213 | char *cap, *name; | 1200 | const char *cap, *name; |
| 1214 | }; | 1201 | }; |
| 1215 | 1202 | ||
| 1216 | /* Termcap capability names that correspond directly to X keysyms. | 1203 | /* Termcap capability names that correspond directly to X keysyms. |
| @@ -1350,14 +1337,14 @@ term_get_fkeys_1 (void) | |||
| 1350 | KBOARD *kboard = term_get_fkeys_kboard; | 1337 | KBOARD *kboard = term_get_fkeys_kboard; |
| 1351 | 1338 | ||
| 1352 | /* This can happen if CANNOT_DUMP or with strange options. */ | 1339 | /* This can happen if CANNOT_DUMP or with strange options. */ |
| 1353 | if (!KEYMAPP (kboard->Vinput_decode_map)) | 1340 | if (!KEYMAPP (KVAR (kboard, Vinput_decode_map))) |
| 1354 | kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil); | 1341 | KVAR (kboard, Vinput_decode_map) = Fmake_sparse_keymap (Qnil); |
| 1355 | 1342 | ||
| 1356 | for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) | 1343 | for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) |
| 1357 | { | 1344 | { |
| 1358 | char *sequence = tgetstr (keys[i].cap, address); | 1345 | char *sequence = tgetstr (keys[i].cap, address); |
| 1359 | if (sequence) | 1346 | if (sequence) |
| 1360 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), | 1347 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (sequence), |
| 1361 | Fmake_vector (make_number (1), | 1348 | Fmake_vector (make_number (1), |
| 1362 | intern (keys[i].name))); | 1349 | intern (keys[i].name))); |
| 1363 | } | 1350 | } |
| @@ -1368,22 +1355,22 @@ term_get_fkeys_1 (void) | |||
| 1368 | "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. | 1355 | "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. |
| 1369 | */ | 1356 | */ |
| 1370 | { | 1357 | { |
| 1371 | char *k_semi = tgetstr ("k;", address); | 1358 | const char *k_semi = tgetstr ("k;", address); |
| 1372 | char *k0 = tgetstr ("k0", address); | 1359 | const char *k0 = tgetstr ("k0", address); |
| 1373 | char *k0_name = "f10"; | 1360 | const char *k0_name = "f10"; |
| 1374 | 1361 | ||
| 1375 | if (k_semi) | 1362 | if (k_semi) |
| 1376 | { | 1363 | { |
| 1377 | if (k0) | 1364 | if (k0) |
| 1378 | /* Define f0 first, so that f10 takes precedence in case the | 1365 | /* Define f0 first, so that f10 takes precedence in case the |
| 1379 | key sequences happens to be the same. */ | 1366 | key sequences happens to be the same. */ |
| 1380 | Fdefine_key (kboard->Vinput_decode_map, build_string (k0), | 1367 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k0), |
| 1381 | Fmake_vector (make_number (1), intern ("f0"))); | 1368 | Fmake_vector (make_number (1), intern ("f0"))); |
| 1382 | Fdefine_key (kboard->Vinput_decode_map, build_string (k_semi), | 1369 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k_semi), |
| 1383 | Fmake_vector (make_number (1), intern ("f10"))); | 1370 | Fmake_vector (make_number (1), intern ("f10"))); |
| 1384 | } | 1371 | } |
| 1385 | else if (k0) | 1372 | else if (k0) |
| 1386 | Fdefine_key (kboard->Vinput_decode_map, build_string (k0), | 1373 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k0), |
| 1387 | Fmake_vector (make_number (1), intern (k0_name))); | 1374 | Fmake_vector (make_number (1), intern (k0_name))); |
| 1388 | } | 1375 | } |
| 1389 | 1376 | ||
| @@ -1406,7 +1393,7 @@ term_get_fkeys_1 (void) | |||
| 1406 | if (sequence) | 1393 | if (sequence) |
| 1407 | { | 1394 | { |
| 1408 | sprintf (fkey, "f%d", i); | 1395 | sprintf (fkey, "f%d", i); |
| 1409 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), | 1396 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (sequence), |
| 1410 | Fmake_vector (make_number (1), | 1397 | Fmake_vector (make_number (1), |
| 1411 | intern (fkey))); | 1398 | intern (fkey))); |
| 1412 | } | 1399 | } |
| @@ -1423,7 +1410,7 @@ term_get_fkeys_1 (void) | |||
| 1423 | { \ | 1410 | { \ |
| 1424 | char *sequence = tgetstr (cap2, address); \ | 1411 | char *sequence = tgetstr (cap2, address); \ |
| 1425 | if (sequence) \ | 1412 | if (sequence) \ |
| 1426 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), \ | 1413 | Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (sequence), \ |
| 1427 | Fmake_vector (make_number (1), \ | 1414 | Fmake_vector (make_number (1), \ |
| 1428 | intern (sym))); \ | 1415 | intern (sym))); \ |
| 1429 | } | 1416 | } |
| @@ -1463,7 +1450,7 @@ static void append_glyph (struct it *); | |||
| 1463 | static void produce_stretch_glyph (struct it *); | 1450 | static void produce_stretch_glyph (struct it *); |
| 1464 | static void append_composite_glyph (struct it *); | 1451 | static void append_composite_glyph (struct it *); |
| 1465 | static void produce_composite_glyph (struct it *); | 1452 | static void produce_composite_glyph (struct it *); |
| 1466 | static void append_glyphless_glyph (struct it *, int, char *); | 1453 | static void append_glyphless_glyph (struct it *, int, const char *); |
| 1467 | static void produce_glyphless_glyph (struct it *, int, Lisp_Object); | 1454 | static void produce_glyphless_glyph (struct it *, int, Lisp_Object); |
| 1468 | 1455 | ||
| 1469 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for | 1456 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for |
| @@ -1831,7 +1818,7 @@ produce_composite_glyph (struct it *it) | |||
| 1831 | comes from it->nglyphs bytes). */ | 1818 | comes from it->nglyphs bytes). */ |
| 1832 | 1819 | ||
| 1833 | static void | 1820 | static void |
| 1834 | append_glyphless_glyph (struct it *it, int face_id, char *str) | 1821 | append_glyphless_glyph (struct it *it, int face_id, const char *str) |
| 1835 | { | 1822 | { |
| 1836 | struct glyph *glyph, *end; | 1823 | struct glyph *glyph, *end; |
| 1837 | int i; | 1824 | int i; |
| @@ -1906,7 +1893,8 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) | |||
| 1906 | { | 1893 | { |
| 1907 | int face_id; | 1894 | int face_id; |
| 1908 | int len; | 1895 | int len; |
| 1909 | char buf[9], *str = " "; | 1896 | char buf[9]; |
| 1897 | char const *str = " "; | ||
| 1910 | 1898 | ||
| 1911 | /* Get a face ID for the glyph by utilizing a cache (the same way as | 1899 | /* Get a face ID for the glyph by utilizing a cache (the same way as |
| 1912 | done for `escape-glyph' in get_next_display_element). */ | 1900 | done for `escape-glyph' in get_next_display_element). */ |
| @@ -1947,6 +1935,8 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) | |||
| 1947 | { | 1935 | { |
| 1948 | if (! STRINGP (acronym) && CHAR_TABLE_P (Vglyphless_char_display)) | 1936 | if (! STRINGP (acronym) && CHAR_TABLE_P (Vglyphless_char_display)) |
| 1949 | acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c); | 1937 | acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c); |
| 1938 | if (CONSP (acronym)) | ||
| 1939 | acronym = XCDR (acronym); | ||
| 1950 | buf[0] = '['; | 1940 | buf[0] = '['; |
| 1951 | str = STRINGP (acronym) ? SSDATA (acronym) : ""; | 1941 | str = STRINGP (acronym) ? SSDATA (acronym) : ""; |
| 1952 | for (len = 0; len < 6 && str[len] && ASCII_BYTE_P (str[len]); len++) | 1942 | for (len = 0; len < 6 && str[len] && ASCII_BYTE_P (str[len]); len++) |
| @@ -1966,7 +1956,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) | |||
| 1966 | 1956 | ||
| 1967 | it->pixel_width = len; | 1957 | it->pixel_width = len; |
| 1968 | it->nglyphs = len; | 1958 | it->nglyphs = len; |
| 1969 | if (len > 0 && it->glyph_row) | 1959 | if (it->glyph_row) |
| 1970 | append_glyphless_glyph (it, face_id, str); | 1960 | append_glyphless_glyph (it, face_id, str); |
| 1971 | } | 1961 | } |
| 1972 | 1962 | ||
| @@ -2125,12 +2115,13 @@ turn_on_face (struct frame *f, int face_id) | |||
| 2125 | 2115 | ||
| 2126 | if (tty->TN_max_colors > 0) | 2116 | if (tty->TN_max_colors > 0) |
| 2127 | { | 2117 | { |
| 2128 | char *ts, *p; | 2118 | const char *ts; |
| 2119 | char *p; | ||
| 2129 | 2120 | ||
| 2130 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; | 2121 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; |
| 2131 | if (fg >= 0 && ts) | 2122 | if (fg >= 0 && ts) |
| 2132 | { | 2123 | { |
| 2133 | p = tparam (ts, NULL, 0, (int) fg); | 2124 | p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); |
| 2134 | OUTPUT (tty, p); | 2125 | OUTPUT (tty, p); |
| 2135 | xfree (p); | 2126 | xfree (p); |
| 2136 | } | 2127 | } |
| @@ -2138,7 +2129,7 @@ turn_on_face (struct frame *f, int face_id) | |||
| 2138 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; | 2129 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; |
| 2139 | if (bg >= 0 && ts) | 2130 | if (bg >= 0 && ts) |
| 2140 | { | 2131 | { |
| 2141 | p = tparam (ts, NULL, 0, (int) bg); | 2132 | p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); |
| 2142 | OUTPUT (tty, p); | 2133 | OUTPUT (tty, p); |
| 2143 | xfree (p); | 2134 | xfree (p); |
| 2144 | } | 2135 | } |
| @@ -2380,7 +2371,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f) | |||
| 2380 | 2371 | ||
| 2381 | /* Return the tty display object specified by TERMINAL. */ | 2372 | /* Return the tty display object specified by TERMINAL. */ |
| 2382 | 2373 | ||
| 2383 | struct terminal * | 2374 | static struct terminal * |
| 2384 | get_tty_terminal (Lisp_Object terminal, int throw) | 2375 | get_tty_terminal (Lisp_Object terminal, int throw) |
| 2385 | { | 2376 | { |
| 2386 | struct terminal *t = get_terminal (terminal, throw); | 2377 | struct terminal *t = get_terminal (terminal, throw); |
| @@ -2513,13 +2504,10 @@ A suspended tty may be resumed by calling `resume-tty' on it. */) | |||
| 2513 | /* First run `suspend-tty-functions' and then clean up the tty | 2504 | /* First run `suspend-tty-functions' and then clean up the tty |
| 2514 | state because `suspend-tty-functions' might need to change | 2505 | state because `suspend-tty-functions' might need to change |
| 2515 | the tty state. */ | 2506 | the tty state. */ |
| 2516 | if (!NILP (Vrun_hooks)) | 2507 | Lisp_Object args[2]; |
| 2517 | { | 2508 | args[0] = intern ("suspend-tty-functions"); |
| 2518 | Lisp_Object args[2]; | 2509 | XSETTERMINAL (args[1], t); |
| 2519 | args[0] = intern ("suspend-tty-functions"); | 2510 | Frun_hook_with_args (2, args); |
| 2520 | XSETTERMINAL (args[1], t); | ||
| 2521 | Frun_hook_with_args (2, args); | ||
| 2522 | } | ||
| 2523 | 2511 | ||
| 2524 | reset_sys_modes (t->display_info.tty); | 2512 | reset_sys_modes (t->display_info.tty); |
| 2525 | delete_keyboard_wait_descriptor (fileno (f)); | 2513 | delete_keyboard_wait_descriptor (fileno (f)); |
| @@ -2607,16 +2595,16 @@ frame's terminal). */) | |||
| 2607 | FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); | 2595 | FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); |
| 2608 | } | 2596 | } |
| 2609 | 2597 | ||
| 2598 | set_tty_hooks (t); | ||
| 2610 | init_sys_modes (t->display_info.tty); | 2599 | init_sys_modes (t->display_info.tty); |
| 2611 | 2600 | ||
| 2612 | /* Run `resume-tty-functions'. */ | 2601 | { |
| 2613 | if (!NILP (Vrun_hooks)) | 2602 | /* Run `resume-tty-functions'. */ |
| 2614 | { | 2603 | Lisp_Object args[2]; |
| 2615 | Lisp_Object args[2]; | 2604 | args[0] = intern ("resume-tty-functions"); |
| 2616 | args[0] = intern ("resume-tty-functions"); | 2605 | XSETTERMINAL (args[1], t); |
| 2617 | XSETTERMINAL (args[1], t); | 2606 | Frun_hook_with_args (2, args); |
| 2618 | Frun_hook_with_args (2, args); | 2607 | } |
| 2619 | } | ||
| 2620 | } | 2608 | } |
| 2621 | 2609 | ||
| 2622 | set_tty_hooks (t); | 2610 | set_tty_hooks (t); |
| @@ -2630,6 +2618,8 @@ frame's terminal). */) | |||
| 2630 | ***********************************************************************/ | 2618 | ***********************************************************************/ |
| 2631 | 2619 | ||
| 2632 | #ifdef HAVE_GPM | 2620 | #ifdef HAVE_GPM |
| 2621 | |||
| 2622 | #ifndef HAVE_WINDOW_SYSTEM | ||
| 2633 | void | 2623 | void |
| 2634 | term_mouse_moveto (int x, int y) | 2624 | term_mouse_moveto (int x, int y) |
| 2635 | { | 2625 | { |
| @@ -2643,6 +2633,7 @@ term_mouse_moveto (int x, int y) | |||
| 2643 | last_mouse_x = x; | 2633 | last_mouse_x = x; |
| 2644 | last_mouse_y = y; */ | 2634 | last_mouse_y = y; */ |
| 2645 | } | 2635 | } |
| 2636 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 2646 | 2637 | ||
| 2647 | /* Implementation of draw_row_with_mouse_face for TTY/GPM. */ | 2638 | /* Implementation of draw_row_with_mouse_face for TTY/GPM. */ |
| 2648 | void | 2639 | void |
| @@ -2701,16 +2692,17 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 2701 | Set *bar_window to Qnil, and *x and *y to the column and | 2692 | Set *bar_window to Qnil, and *x and *y to the column and |
| 2702 | row of the character cell the mouse is over. | 2693 | row of the character cell the mouse is over. |
| 2703 | 2694 | ||
| 2704 | Set *time to the time the mouse was at the returned position. | 2695 | Set *timeptr to the time the mouse was at the returned position. |
| 2705 | 2696 | ||
| 2706 | This clears mouse_moved until the next motion | 2697 | This clears mouse_moved until the next motion |
| 2707 | event arrives. */ | 2698 | event arrives. */ |
| 2708 | static void | 2699 | static void |
| 2709 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | 2700 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, |
| 2710 | enum scroll_bar_part *part, Lisp_Object *x, | 2701 | enum scroll_bar_part *part, Lisp_Object *x, |
| 2711 | Lisp_Object *y, unsigned long *time) | 2702 | Lisp_Object *y, Time *timeptr) |
| 2712 | { | 2703 | { |
| 2713 | struct timeval now; | 2704 | struct timeval now; |
| 2705 | Time sec, usec; | ||
| 2714 | 2706 | ||
| 2715 | *fp = SELECTED_FRAME (); | 2707 | *fp = SELECTED_FRAME (); |
| 2716 | (*fp)->mouse_moved = 0; | 2708 | (*fp)->mouse_moved = 0; |
| @@ -2721,7 +2713,9 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 2721 | XSETINT (*x, last_mouse_x); | 2713 | XSETINT (*x, last_mouse_x); |
| 2722 | XSETINT (*y, last_mouse_y); | 2714 | XSETINT (*y, last_mouse_y); |
| 2723 | gettimeofday(&now, 0); | 2715 | gettimeofday(&now, 0); |
| 2724 | *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); | 2716 | sec = now.tv_sec; |
| 2717 | usec = now.tv_usec; | ||
| 2718 | *timeptr = (sec * 1000) + (usec / 1000); | ||
| 2725 | } | 2719 | } |
| 2726 | 2720 | ||
| 2727 | /* Prepare a mouse-event in *RESULT for placement in the input queue. | 2721 | /* Prepare a mouse-event in *RESULT for placement in the input queue. |
| @@ -3130,7 +3124,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3130 | terminal = create_terminal (); | 3124 | terminal = create_terminal (); |
| 3131 | #ifdef MSDOS | 3125 | #ifdef MSDOS |
| 3132 | if (been_here > 0) | 3126 | if (been_here > 0) |
| 3133 | maybe_fatal (1, 0, "Attempt to create another terminal %s", "", | 3127 | maybe_fatal (0, 0, "Attempt to create another terminal %s", "", |
| 3134 | name, ""); | 3128 | name, ""); |
| 3135 | been_here = 1; | 3129 | been_here = 1; |
| 3136 | tty = &the_only_display_info; | 3130 | tty = &the_only_display_info; |
| @@ -3171,13 +3165,12 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3171 | if we don't have one at the moment. */ | 3165 | if we don't have one at the moment. */ |
| 3172 | fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); | 3166 | fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); |
| 3173 | else | 3167 | else |
| 3174 | #else | 3168 | #endif /* O_IGNORE_CTTY */ |
| 3175 | /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only | 3169 | /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only |
| 3176 | defined on Hurd. On other systems, we need to explicitly | 3170 | defined on Hurd. On other systems, we need to explicitly |
| 3177 | dissociate ourselves from the controlling tty when we want to | 3171 | dissociate ourselves from the controlling tty when we want to |
| 3178 | open a frame on the same terminal. */ | 3172 | open a frame on the same terminal. */ |
| 3179 | fd = emacs_open (name, O_RDWR | O_NOCTTY, 0); | 3173 | fd = emacs_open (name, O_RDWR | O_NOCTTY, 0); |
| 3180 | #endif /* O_IGNORE_CTTY */ | ||
| 3181 | 3174 | ||
| 3182 | tty->name = xstrdup (name); | 3175 | tty->name = xstrdup (name); |
| 3183 | terminal->name = xstrdup (name); | 3176 | terminal->name = xstrdup (name); |
| @@ -3418,7 +3411,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3418 | 3411 | ||
| 3419 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 3412 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); |
| 3420 | init_kboard (terminal->kboard); | 3413 | init_kboard (terminal->kboard); |
| 3421 | terminal->kboard->Vwindow_system = Qnil; | 3414 | KVAR (terminal->kboard, Vwindow_system) = Qnil; |
| 3422 | terminal->kboard->next_kboard = all_kboards; | 3415 | terminal->kboard->next_kboard = all_kboards; |
| 3423 | all_kboards = terminal->kboard; | 3416 | all_kboards = terminal->kboard; |
| 3424 | terminal->kboard->reference_count++; | 3417 | terminal->kboard->reference_count++; |
| @@ -3535,10 +3528,10 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3535 | If it were in the termcap entry, it would confuse other programs. */ | 3528 | If it were in the termcap entry, it would confuse other programs. */ |
| 3536 | if (!tty->TS_set_window) | 3529 | if (!tty->TS_set_window) |
| 3537 | { | 3530 | { |
| 3538 | p = tty->TS_termcap_modes; | 3531 | const char *m = tty->TS_termcap_modes; |
| 3539 | while (*p && strcmp (p, "\033v ")) | 3532 | while (*m && strcmp (m, "\033v ")) |
| 3540 | p++; | 3533 | m++; |
| 3541 | if (*p) | 3534 | if (*m) |
| 3542 | tty->TS_set_window = "\033v%C %C %C %C "; | 3535 | tty->TS_set_window = "\033v%C %C %C %C "; |
| 3543 | } | 3536 | } |
| 3544 | /* Termcap entry often fails to have :in: flag */ | 3537 | /* Termcap entry often fails to have :in: flag */ |
| @@ -3629,7 +3622,6 @@ vfatal (const char *str, va_list ap) | |||
| 3629 | vfprintf (stderr, str, ap); | 3622 | vfprintf (stderr, str, ap); |
| 3630 | if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) | 3623 | if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) |
| 3631 | fprintf (stderr, "\n"); | 3624 | fprintf (stderr, "\n"); |
| 3632 | va_end (ap); | ||
| 3633 | fflush (stderr); | 3625 | fflush (stderr); |
| 3634 | exit (1); | 3626 | exit (1); |
| 3635 | } | 3627 | } |
| @@ -3637,7 +3629,7 @@ vfatal (const char *str, va_list ap) | |||
| 3637 | 3629 | ||
| 3638 | /* Auxiliary error-handling function for init_tty. | 3630 | /* Auxiliary error-handling function for init_tty. |
| 3639 | Delete TERMINAL, then call error or fatal with str1 or str2, | 3631 | Delete TERMINAL, then call error or fatal with str1 or str2, |
| 3640 | respectively, according to MUST_SUCCEED. */ | 3632 | respectively, according to whether MUST_SUCCEED is zero or not. */ |
| 3641 | 3633 | ||
| 3642 | static void | 3634 | static void |
| 3643 | maybe_fatal (int must_succeed, struct terminal *terminal, | 3635 | maybe_fatal (int must_succeed, struct terminal *terminal, |