aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorKim F. Storm2008-02-27 22:49:29 +0000
committerKim F. Storm2008-02-27 22:49:29 +0000
commitf4d953fcbce96331d8a8aa73b7020de0f5f92ba2 (patch)
tree7101fdb531b3a3a7061751ea1b1b1500388885d5 /src/term.c
parenta08b9f3d7106af8956c9474f9b74d3dace84e5d9 (diff)
downloademacs-f4d953fcbce96331d8a8aa73b7020de0f5f92ba2.tar.gz
emacs-f4d953fcbce96331d8a8aa73b7020de0f5f92ba2.zip
(encode_terminal_code, produce_special_glyphs): Likewise.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c83
1 files changed, 41 insertions, 42 deletions
diff --git a/src/term.c b/src/term.c
index 6c236d1b636..272e8d33326 100644
--- a/src/term.c
+++ b/src/term.c
@@ -235,7 +235,7 @@ void
235tty_set_terminal_modes (struct terminal *terminal) 235tty_set_terminal_modes (struct terminal *terminal)
236{ 236{
237 struct tty_display_info *tty = terminal->display_info.tty; 237 struct tty_display_info *tty = terminal->display_info.tty;
238 238
239 if (tty->output) 239 if (tty->output)
240 { 240 {
241 if (tty->TS_termcap_modes) 241 if (tty->TS_termcap_modes)
@@ -569,7 +569,6 @@ encode_terminal_code (src, src_len, coding)
569 struct coding_system *coding; 569 struct coding_system *coding;
570{ 570{
571 struct glyph *src_end = src + src_len; 571 struct glyph *src_end = src + src_len;
572 register GLYPH g;
573 unsigned char *buf; 572 unsigned char *buf;
574 int nchars, nbytes, required; 573 int nchars, nbytes, required;
575 register int tlen = GLYPH_TABLE_LENGTH; 574 register int tlen = GLYPH_TABLE_LENGTH;
@@ -615,7 +614,7 @@ encode_terminal_code (src, src_len, coding)
615 for (i = 0; i < cmp->glyph_len; i++) 614 for (i = 0; i < cmp->glyph_len; i++)
616 { 615 {
617 int c = COMPOSITION_GLYPH (cmp, i); 616 int c = COMPOSITION_GLYPH (cmp, i);
618 617
619 if (! char_charset (c, charset_list, NULL)) 618 if (! char_charset (c, charset_list, NULL))
620 break; 619 break;
621 buf += CHAR_STRING (c, buf); 620 buf += CHAR_STRING (c, buf);
@@ -631,13 +630,14 @@ encode_terminal_code (src, src_len, coding)
631 /* We must skip glyphs to be padded for a wide character. */ 630 /* We must skip glyphs to be padded for a wide character. */
632 else if (! CHAR_GLYPH_PADDING_P (*src)) 631 else if (! CHAR_GLYPH_PADDING_P (*src))
633 { 632 {
633 GLYPH g;
634 int c; 634 int c;
635 Lisp_Object string; 635 Lisp_Object string;
636 636
637 string = Qnil; 637 string = Qnil;
638 g = GLYPH_FROM_CHAR_GLYPH (src[0]); 638 SET_GLYPH_FROM_CHAR_GLYPH (g, src[0]);
639 639
640 if (g < 0 || g >= tlen) 640 if (GLYPH_INVALID_P (g) || GLYPH_SIMPLE_P (tbase, tlen, g))
641 { 641 {
642 /* This glyph doesn't has an entry in Vglyph_table. */ 642 /* This glyph doesn't has an entry in Vglyph_table. */
643 c = src->u.ch; 643 c = src->u.ch;
@@ -651,10 +651,10 @@ encode_terminal_code (src, src_len, coding)
651 if (GLYPH_SIMPLE_P (tbase, tlen, g)) 651 if (GLYPH_SIMPLE_P (tbase, tlen, g))
652 /* We set the multi-byte form of a character in G 652 /* We set the multi-byte form of a character in G
653 (that should be an ASCII character) at WORKBUF. */ 653 (that should be an ASCII character) at WORKBUF. */
654 c = FAST_GLYPH_CHAR (g); 654 c = GLYPH_CHAR (g);
655 else 655 else
656 /* We have a string in Vglyph_table. */ 656 /* We have a string in Vglyph_table. */
657 string = tbase[g]; 657 string = tbase[GLYPH_CHAR (g)];
658 } 658 }
659 659
660 if (NILP (string)) 660 if (NILP (string))
@@ -1016,7 +1016,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
1016 if (!FRAME_MEMORY_BELOW_FRAME (f) 1016 if (!FRAME_MEMORY_BELOW_FRAME (f)
1017 && vpos + i >= FRAME_LINES (f)) 1017 && vpos + i >= FRAME_LINES (f))
1018 return; 1018 return;
1019 1019
1020 if (multi) 1020 if (multi)
1021 { 1021 {
1022 raw_cursor_to (f, vpos, 0); 1022 raw_cursor_to (f, vpos, 0);
@@ -1046,7 +1046,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
1046 OUTPUTL (tty, scroll, tty->specified_window - vpos); 1046 OUTPUTL (tty, scroll, tty->specified_window - vpos);
1047 tty_set_scroll_region (f, 0, tty->specified_window); 1047 tty_set_scroll_region (f, 0, tty->specified_window);
1048 } 1048 }
1049 1049
1050 if (!FRAME_SCROLL_REGION_OK (f) 1050 if (!FRAME_SCROLL_REGION_OK (f)
1051 && FRAME_MEMORY_BELOW_FRAME (f) 1051 && FRAME_MEMORY_BELOW_FRAME (f)
1052 && n < 0) 1052 && n < 0)
@@ -1371,7 +1371,7 @@ term_get_fkeys_1 ()
1371 1371
1372 char **address = term_get_fkeys_address; 1372 char **address = term_get_fkeys_address;
1373 KBOARD *kboard = term_get_fkeys_kboard; 1373 KBOARD *kboard = term_get_fkeys_kboard;
1374 1374
1375 /* This can happen if CANNOT_DUMP or with strange options. */ 1375 /* This can happen if CANNOT_DUMP or with strange options. */
1376 if (!KEYMAPP (kboard->Vinput_decode_map)) 1376 if (!KEYMAPP (kboard->Vinput_decode_map))
1377 kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil); 1377 kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil);
@@ -1792,6 +1792,7 @@ produce_special_glyphs (it, what)
1792 enum display_element_type what; 1792 enum display_element_type what;
1793{ 1793{
1794 struct it temp_it; 1794 struct it temp_it;
1795 Lisp_Object gc;
1795 GLYPH glyph; 1796 GLYPH glyph;
1796 1797
1797 temp_it = *it; 1798 temp_it = *it;
@@ -1804,34 +1805,32 @@ produce_special_glyphs (it, what)
1804 if (what == IT_CONTINUATION) 1805 if (what == IT_CONTINUATION)
1805 { 1806 {
1806 /* Continuation glyph. */ 1807 /* Continuation glyph. */
1808 SET_GLYPH_FROM_CHAR (glyph, '\\');
1807 if (it->dp 1809 if (it->dp
1808 && INTEGERP (DISP_CONTINUE_GLYPH (it->dp)) 1810 && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc))
1809 && GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (it->dp)))) 1811 && GLYPH_CODE_CHAR_VALID_P (gc))
1810 { 1812 {
1811 glyph = XINT (DISP_CONTINUE_GLYPH (it->dp)); 1813 SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
1812 glyph = spec_glyph_lookup_face (XWINDOW (it->window), glyph); 1814 spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
1813 } 1815 }
1814 else
1815 glyph = '\\';
1816 } 1816 }
1817 else if (what == IT_TRUNCATION) 1817 else if (what == IT_TRUNCATION)
1818 { 1818 {
1819 /* Truncation glyph. */ 1819 /* Truncation glyph. */
1820 SET_GLYPH_FROM_CHAR (glyph, '$');
1820 if (it->dp 1821 if (it->dp
1821 && INTEGERP (DISP_TRUNC_GLYPH (it->dp)) 1822 && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc))
1822 && GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (it->dp)))) 1823 && GLYPH_CODE_CHAR_VALID_P (gc))
1823 { 1824 {
1824 glyph = XINT (DISP_TRUNC_GLYPH (it->dp)); 1825 SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
1825 glyph = spec_glyph_lookup_face (XWINDOW (it->window), glyph); 1826 spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
1826 } 1827 }
1827 else
1828 glyph = '$';
1829 } 1828 }
1830 else 1829 else
1831 abort (); 1830 abort ();
1832 1831
1833 temp_it.c = FAST_GLYPH_CHAR (glyph); 1832 temp_it.c = GLYPH_CHAR (glyph);
1834 temp_it.face_id = FAST_GLYPH_FACE (glyph); 1833 temp_it.face_id = GLYPH_FACE (glyph);
1835 temp_it.len = CHAR_BYTES (temp_it.c); 1834 temp_it.len = CHAR_BYTES (temp_it.c);
1836 1835
1837 produce_glyphs (&temp_it); 1836 produce_glyphs (&temp_it);
@@ -2243,7 +2242,7 @@ get_tty_terminal (Lisp_Object terminal, int throw)
2243 This function ignores suspended devices. 2242 This function ignores suspended devices.
2244 2243
2245 Returns NULL if the named terminal device is not opened. */ 2244 Returns NULL if the named terminal device is not opened. */
2246 2245
2247struct terminal * 2246struct terminal *
2248get_named_tty (name) 2247get_named_tty (name)
2249 char *name; 2248 char *name;
@@ -2347,12 +2346,12 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2347{ 2346{
2348 struct terminal *t = get_tty_terminal (tty, 1); 2347 struct terminal *t = get_tty_terminal (tty, 1);
2349 FILE *f; 2348 FILE *f;
2350 2349
2351 if (!t) 2350 if (!t)
2352 error ("Unknown tty device"); 2351 error ("Unknown tty device");
2353 2352
2354 f = t->display_info.tty->input; 2353 f = t->display_info.tty->input;
2355 2354
2356 if (f) 2355 if (f)
2357 { 2356 {
2358 /* First run `suspend-tty-functions' and then clean up the tty 2357 /* First run `suspend-tty-functions' and then clean up the tty
@@ -2369,17 +2368,17 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2369 reset_sys_modes (t->display_info.tty); 2368 reset_sys_modes (t->display_info.tty);
2370 2369
2371 delete_keyboard_wait_descriptor (fileno (f)); 2370 delete_keyboard_wait_descriptor (fileno (f));
2372 2371
2373 fclose (f); 2372 fclose (f);
2374 if (f != t->display_info.tty->output) 2373 if (f != t->display_info.tty->output)
2375 fclose (t->display_info.tty->output); 2374 fclose (t->display_info.tty->output);
2376 2375
2377 t->display_info.tty->input = 0; 2376 t->display_info.tty->input = 0;
2378 t->display_info.tty->output = 0; 2377 t->display_info.tty->output = 0;
2379 2378
2380 if (FRAMEP (t->display_info.tty->top_frame)) 2379 if (FRAMEP (t->display_info.tty->top_frame))
2381 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0); 2380 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
2382 2381
2383 } 2382 }
2384 2383
2385 /* Clear display hooks to prevent further output. */ 2384 /* Clear display hooks to prevent further output. */
@@ -2492,7 +2491,7 @@ term_show_mouse_face (enum draw_glyphs_face draw)
2492 /* write_glyphs writes at cursor position, so we need to 2491 /* write_glyphs writes at cursor position, so we need to
2493 temporarily move cursor coordinates to the beginning of 2492 temporarily move cursor coordinates to the beginning of
2494 the highlight region. */ 2493 the highlight region. */
2495 2494
2496 /* Save current cursor co-ordinates */ 2495 /* Save current cursor co-ordinates */
2497 save_y = curY (tty); 2496 save_y = curY (tty);
2498 save_x = curX (tty); 2497 save_x = curX (tty);
@@ -2536,7 +2535,7 @@ term_show_mouse_face (enum draw_glyphs_face draw)
2536 pos_y = row->y + WINDOW_TOP_EDGE_Y (w); 2535 pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
2537 pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos 2536 pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
2538 + WINDOW_LEFT_EDGE_X (w); 2537 + WINDOW_LEFT_EDGE_X (w);
2539 2538
2540 cursor_to (f, pos_y, pos_x); 2539 cursor_to (f, pos_y, pos_x);
2541 2540
2542 if (draw == DRAW_MOUSE_FACE) 2541 if (draw == DRAW_MOUSE_FACE)
@@ -2960,10 +2959,10 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2960 result->modifiers = down_modifier; 2959 result->modifiers = down_modifier;
2961 else 2960 else
2962 result->modifiers = 0; 2961 result->modifiers = 0;
2963 2962
2964 if (event->type & GPM_SINGLE) 2963 if (event->type & GPM_SINGLE)
2965 result->modifiers |= click_modifier; 2964 result->modifiers |= click_modifier;
2966 2965
2967 if (event->type & GPM_DOUBLE) 2966 if (event->type & GPM_DOUBLE)
2968 result->modifiers |= double_modifier; 2967 result->modifiers |= double_modifier;
2969 2968
@@ -2996,7 +2995,7 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2996 return Qnil; 2995 return Qnil;
2997} 2996}
2998 2997
2999int 2998int
3000handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct input_event* hold_quit) 2999handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct input_event* hold_quit)
3001{ 3000{
3002 struct frame *f = XFRAME (tty->top_frame); 3001 struct frame *f = XFRAME (tty->top_frame);
@@ -3107,7 +3106,7 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
3107 3106
3108 if (!tty || gpm_tty != tty) 3107 if (!tty || gpm_tty != tty)
3109 return Qnil; /* Not activated on this terminal, nothing to do. */ 3108 return Qnil; /* Not activated on this terminal, nothing to do. */
3110 3109
3111 if (gpm_fd >= 0) 3110 if (gpm_fd >= 0)
3112 delete_gpm_wait_descriptor (gpm_fd); 3111 delete_gpm_wait_descriptor (gpm_fd);
3113 while (Gpm_Close()); /* close all the stack */ 3112 while (Gpm_Close()); /* close all the stack */
@@ -3211,7 +3210,7 @@ set_tty_hooks (struct terminal *terminal)
3211 terminal->delete_glyphs_hook = &tty_delete_glyphs; 3210 terminal->delete_glyphs_hook = &tty_delete_glyphs;
3212 3211
3213 terminal->ring_bell_hook = &tty_ring_bell; 3212 terminal->ring_bell_hook = &tty_ring_bell;
3214 3213
3215 terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes; 3214 terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
3216 terminal->set_terminal_modes_hook = &tty_set_terminal_modes; 3215 terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
3217 terminal->update_begin_hook = 0; /* Not needed. */ 3216 terminal->update_begin_hook = 0; /* Not needed. */
@@ -3229,7 +3228,7 @@ set_tty_hooks (struct terminal *terminal)
3229 3228
3230 terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ 3229 terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
3231 terminal->frame_up_to_date_hook = 0; /* Not needed. */ 3230 terminal->frame_up_to_date_hook = 0; /* Not needed. */
3232 3231
3233 terminal->delete_frame_hook = &delete_tty_output; 3232 terminal->delete_frame_hook = &delete_tty_output;
3234 terminal->delete_terminal_hook = &delete_tty; 3233 terminal->delete_terminal_hook = &delete_tty;
3235} 3234}
@@ -3859,7 +3858,7 @@ maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
3859 3858
3860 if (terminal) 3859 if (terminal)
3861 delete_tty (terminal); 3860 delete_tty (terminal);
3862 3861
3863 if (must_succeed) 3862 if (must_succeed)
3864 fatal (str2, arg1, arg2); 3863 fatal (str2, arg1, arg2);
3865 else 3864 else
@@ -3890,7 +3889,7 @@ delete_tty (struct terminal *terminal)
3890 struct tty_display_info *tty; 3889 struct tty_display_info *tty;
3891 Lisp_Object tail, frame; 3890 Lisp_Object tail, frame;
3892 int last_terminal; 3891 int last_terminal;
3893 3892
3894 /* Protect against recursive calls. Fdelete_frame in 3893 /* Protect against recursive calls. Fdelete_frame in
3895 delete_terminal calls us back when it deletes our last frame. */ 3894 delete_terminal calls us back when it deletes our last frame. */
3896 if (!terminal->name) 3895 if (!terminal->name)
@@ -3900,7 +3899,7 @@ delete_tty (struct terminal *terminal)
3900 abort (); 3899 abort ();
3901 3900
3902 tty = terminal->display_info.tty; 3901 tty = terminal->display_info.tty;
3903 3902
3904 last_terminal = 1; 3903 last_terminal = 1;
3905 FOR_EACH_FRAME (tail, frame) 3904 FOR_EACH_FRAME (tail, frame)
3906 { 3905 {
@@ -3913,7 +3912,7 @@ delete_tty (struct terminal *terminal)
3913 } 3912 }
3914 if (last_terminal) 3913 if (last_terminal)
3915 error ("Attempt to delete the sole terminal device with live frames"); 3914 error ("Attempt to delete the sole terminal device with live frames");
3916 3915
3917 if (tty == tty_list) 3916 if (tty == tty_list)
3918 tty_list = tty->next; 3917 tty_list = tty->next;
3919 else 3918 else