Mercurial > hg > xemacs-beta
comparison src/redisplay-tty.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 15872534500d |
children | f53b5ca2e663 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
51 other conflicts as well on some systems, so screw it: we'll just | 51 other conflicts as well on some systems, so screw it: we'll just |
52 re-declare the routines we use and assume the code in this file is | 52 re-declare the routines we use and assume the code in this file is |
53 invoking them correctly. */ | 53 invoking them correctly. */ |
54 /* # include <curses.h> */ | 54 /* # include <curses.h> */ |
55 /* # include <term.h> */ | 55 /* # include <term.h> */ |
56 #ifdef __cplusplus | |
57 extern "C" { | |
58 #endif | |
56 extern int tgetent (CONST char *, CONST char *); | 59 extern int tgetent (CONST char *, CONST char *); |
57 extern int tgetflag (CONST char *); | 60 extern int tgetflag (CONST char *); |
58 extern int tgetnum (CONST char *); | 61 extern int tgetnum (CONST char *); |
59 extern char *tgetstr (CONST char *, char **); | 62 extern char *tgetstr (CONST char *, char **); |
60 extern void tputs (CONST char *, int, void (*)(int)); | 63 extern void tputs (CONST char *, int, void (*)(int)); |
64 #ifdef __cplusplus | |
65 } | |
66 #endif | |
61 #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0) | 67 #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0) |
62 #define OUTPUTN(c, a, n) \ | 68 #define OUTPUTN(c, a, n) \ |
63 do { \ | 69 do { \ |
64 cmputc_console = c; \ | 70 cmputc_console = c; \ |
65 FORCE_CURSOR_UPDATE (c); \ | 71 FORCE_CURSOR_UPDATE (c); \ |
75 } while (0) | 81 } while (0) |
76 #define OUTPUT1_IF(c, a) OUTPUTN_IF (c, a, 1) | 82 #define OUTPUT1_IF(c, a) OUTPUTN_IF (c, a, 1) |
77 | 83 |
78 static void tty_output_emchar_dynarr (struct window *w, | 84 static void tty_output_emchar_dynarr (struct window *w, |
79 struct display_line *dl, | 85 struct display_line *dl, |
80 emchar_dynarr *buf, int xpos, | 86 Emchar_dynarr *buf, int xpos, |
81 face_index findex, | 87 face_index findex, |
82 int cursor); | 88 int cursor); |
83 static void tty_output_bufbyte_string (struct window *w, | 89 static void tty_output_bufbyte_string (struct window *w, |
84 struct display_line *dl, | 90 struct display_line *dl, |
85 Bufbyte *str, Bytecount len, | 91 Bufbyte *str, Bytecount len, |
192 int start, int end, int start_pixpos, | 198 int start, int end, int start_pixpos, |
193 int cursor_start, int cursor_width, | 199 int cursor_start, int cursor_width, |
194 int cursor_height) | 200 int cursor_height) |
195 { | 201 { |
196 struct frame *f = XFRAME (w->frame); | 202 struct frame *f = XFRAME (w->frame); |
197 emchar_dynarr *buf = Dynarr_new (Emchar); | 203 Emchar_dynarr *buf = Dynarr_new (Emchar); |
198 | 204 |
199 struct display_block *db = Dynarr_atp (dl->display_blocks, block); | 205 struct display_block *db = Dynarr_atp (dl->display_blocks, block); |
200 rune_dynarr *rba = db->runes; | 206 rune_dynarr *rba = db->runes; |
201 struct rune *rb; | 207 struct rune *rb; |
202 | 208 |
368 len -= i; | 374 len -= i; |
369 } | 375 } |
370 | 376 |
371 tty_output_bufbyte_string (w, dl, temptemp, len, | 377 tty_output_bufbyte_string (w, dl, temptemp, len, |
372 xpos, findex, 0); | 378 xpos, findex, 0); |
373 | 379 |
374 if (xpos >= cursor_start | 380 if (xpos >= cursor_start |
375 && (cursor_start < | 381 && (cursor_start < |
376 xpos + (bufbyte_string_displayed_columns | 382 xpos + (bufbyte_string_displayed_columns |
377 (temptemp, len)))) | 383 (temptemp, len)))) |
378 { | 384 { |
578 | 584 |
579 /* Turn the face properties back off. */ | 585 /* Turn the face properties back off. */ |
580 tty_turn_off_face (w, findex); | 586 tty_turn_off_face (w, findex); |
581 } | 587 } |
582 | 588 |
583 static bufbyte_dynarr *tty_output_emchar_dynarr_dynarr; | 589 static Bufbyte_dynarr *tty_output_emchar_dynarr_dynarr; |
584 | 590 |
585 /***************************************************************************** | 591 /***************************************************************************** |
586 tty_output_emchar_dynarr | 592 tty_output_emchar_dynarr |
587 | 593 |
588 Given a string and a starting position, output that string in the | 594 Given a string and a starting position, output that string in the |
589 given face. If cursor is true, draw a cursor around the string. | 595 given face. If cursor is true, draw a cursor around the string. |
590 ****************************************************************************/ | 596 ****************************************************************************/ |
591 static void | 597 static void |
592 tty_output_emchar_dynarr (struct window *w, struct display_line *dl, | 598 tty_output_emchar_dynarr (struct window *w, struct display_line *dl, |
593 emchar_dynarr *buf, int xpos, face_index findex, | 599 Emchar_dynarr *buf, int xpos, face_index findex, |
594 int cursor) | 600 int cursor) |
595 { | 601 { |
596 if (!tty_output_emchar_dynarr_dynarr) | 602 if (!tty_output_emchar_dynarr_dynarr) |
597 tty_output_emchar_dynarr_dynarr = Dynarr_new (Bufbyte); | 603 tty_output_emchar_dynarr_dynarr = Dynarr_new (Bufbyte); |
598 else | 604 else |
608 xpos, findex, cursor); | 614 xpos, findex, cursor); |
609 } | 615 } |
610 | 616 |
611 #if 0 | 617 #if 0 |
612 | 618 |
613 static bufbyte_dynarr *sidcs_dynarr; | 619 static Bufbyte_dynarr *sidcs_dynarr; |
614 | 620 |
615 static void | 621 static void |
616 substitute_in_dynamic_color_string (Lisp_Object spec, Lisp_Object string) | 622 substitute_in_dynamic_color_string (Lisp_Object spec, Lisp_Object string) |
617 { | 623 { |
618 int i; | 624 int i; |
773 tty_turn_on_face (struct window *w, face_index findex) | 779 tty_turn_on_face (struct window *w, face_index findex) |
774 { | 780 { |
775 struct frame *f = XFRAME (w->frame); | 781 struct frame *f = XFRAME (w->frame); |
776 struct console *c = XCONSOLE (FRAME_CONSOLE (f)); | 782 struct console *c = XCONSOLE (FRAME_CONSOLE (f)); |
777 | 783 |
778 tty_turn_on_face_1 (c, | 784 tty_turn_on_face_1 (c, |
779 WINDOW_FACE_CACHEL_HIGHLIGHT_P (w, findex), | 785 WINDOW_FACE_CACHEL_HIGHLIGHT_P (w, findex), |
780 WINDOW_FACE_CACHEL_BLINKING_P (w, findex), | 786 WINDOW_FACE_CACHEL_BLINKING_P (w, findex), |
781 WINDOW_FACE_CACHEL_DIM_P (w, findex), | 787 WINDOW_FACE_CACHEL_DIM_P (w, findex), |
782 WINDOW_FACE_CACHEL_UNDERLINE_P (w, findex), | 788 WINDOW_FACE_CACHEL_UNDERLINE_P (w, findex), |
783 WINDOW_FACE_CACHEL_REVERSE_P (w, findex), | 789 WINDOW_FACE_CACHEL_REVERSE_P (w, findex), |
836 static void | 842 static void |
837 tty_turn_on_frame_face (struct frame *f, Lisp_Object face) | 843 tty_turn_on_frame_face (struct frame *f, Lisp_Object face) |
838 { | 844 { |
839 Lisp_Object frame = Qnil; | 845 Lisp_Object frame = Qnil; |
840 struct console *c = XCONSOLE (FRAME_CONSOLE (f)); | 846 struct console *c = XCONSOLE (FRAME_CONSOLE (f)); |
841 | 847 |
842 XSETFRAME (frame, f); | 848 XSETFRAME (frame, f); |
843 tty_turn_on_face_1 (c, | 849 tty_turn_on_face_1 (c, |
844 FACE_HIGHLIGHT_P (face, frame), | 850 FACE_HIGHLIGHT_P (face, frame), |
845 FACE_BLINKING_P (face, frame), | 851 FACE_BLINKING_P (face, frame), |
846 FACE_DIM_P (face, frame), | 852 FACE_DIM_P (face, frame), |
847 FACE_UNDERLINE_P (face, frame), | 853 FACE_UNDERLINE_P (face, frame), |
848 FACE_REVERSE_P (face, frame), | 854 FACE_REVERSE_P (face, frame), |
1092 /* What we should really do is allocate just enough space for | 1098 /* What we should really do is allocate just enough space for |
1093 the actual strings that are stored; but this would require | 1099 the actual strings that are stored; but this would require |
1094 doing this after all the tgetstr()s and adjusting all the | 1100 doing this after all the tgetstr()s and adjusting all the |
1095 pointers. */ | 1101 pointers. */ |
1096 CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044); | 1102 CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044); |
1097 bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer; | 1103 bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer; |
1098 | 1104 |
1099 EMACS_BLOCK_SIGNAL (SIGTTOU); | 1105 EMACS_BLOCK_SIGNAL (SIGTTOU); |
1100 status = tgetent (entry_buffer, terminal_type); | 1106 status = tgetent (entry_buffer, terminal_type); |
1101 EMACS_UNBLOCK_SIGNAL (SIGTTOU); | 1107 EMACS_UNBLOCK_SIGNAL (SIGTTOU); |
1102 #if 0 | 1108 #if 0 |
1239 if (TTY_FLAGS (c).standout_width == -1) | 1245 if (TTY_FLAGS (c).standout_width == -1) |
1240 TTY_FLAGS (c).standout_width = 0; | 1246 TTY_FLAGS (c).standout_width = 0; |
1241 if (TTY_FLAGS (c).underline_width == -1) | 1247 if (TTY_FLAGS (c).underline_width == -1) |
1242 TTY_FLAGS (c).underline_width = 0; | 1248 TTY_FLAGS (c).underline_width = 0; |
1243 | 1249 |
1244 TTY_FLAGS (c).meta_key = | 1250 TTY_FLAGS (c).meta_key = |
1245 eight_bit_tty (d) ? tgetflag ("km") || tgetflag ("MT") ? 1 : 2 : 0; | 1251 eight_bit_tty (d) ? tgetflag ("km") || tgetflag ("MT") ? 1 : 2 : 0; |
1246 | 1252 |
1247 | 1253 |
1248 /* | 1254 /* |
1249 * Setup the costs tables for this tty console. | 1255 * Setup the costs tables for this tty console. |
1250 */ | 1256 */ |
1251 cm_cost_init (c); | 1257 cm_cost_init (c); |
1252 | 1258 |
1272 | 1278 |
1273 #### we should support the other (non-ANSI) ways of specifying | 1279 #### we should support the other (non-ANSI) ways of specifying |
1274 color, too. */ | 1280 color, too. */ |
1275 char foobuf[500]; | 1281 char foobuf[500]; |
1276 char *fooptr = foobuf; | 1282 char *fooptr = foobuf; |
1277 if (tgetstr ("AB", &fooptr) && tgetstr ("AF", &fooptr)) | 1283 if ((tgetstr ("AB", &fooptr) && tgetstr ("AF", &fooptr)) || |
1284 (tgetstr ("Sf", &fooptr) && tgetstr ("Sb", &fooptr)) || | |
1285 ((tgetnum ("Co") > 0) && (tgetnum ("pa") > 0))) | |
1278 DEVICE_CLASS (d) = Qcolor; | 1286 DEVICE_CLASS (d) = Qcolor; |
1279 else | 1287 else |
1280 DEVICE_CLASS (d) = Qmono; | 1288 DEVICE_CLASS (d) = Qmono; |
1281 } | 1289 } |
1282 | 1290 |
1376 | 1384 |
1377 static Lisp_Object term_get_fkeys_1 (Lisp_Object keymap); | 1385 static Lisp_Object term_get_fkeys_1 (Lisp_Object keymap); |
1378 static Lisp_Object term_get_fkeys_error (Lisp_Object err, Lisp_Object arg); | 1386 static Lisp_Object term_get_fkeys_error (Lisp_Object err, Lisp_Object arg); |
1379 | 1387 |
1380 /* Find the escape codes sent by the function keys for Vfunction_key_map. | 1388 /* Find the escape codes sent by the function keys for Vfunction_key_map. |
1381 This function scans the termcap function key sequence entries, and | 1389 This function scans the termcap function key sequence entries, and |
1382 adds entries to Vfunction_key_map for each function key it finds. */ | 1390 adds entries to Vfunction_key_map for each function key it finds. */ |
1383 | 1391 |
1384 static void | 1392 static void |
1385 term_get_fkeys (Lisp_Object keymap, char **address) | 1393 term_get_fkeys (Lisp_Object keymap, char **address) |
1386 { | 1394 { |
1481 if (sequence) \ | 1489 if (sequence) \ |
1482 Fdefine_key (function_key_map, \ | 1490 Fdefine_key (function_key_map, \ |
1483 build_string (sequence), \ | 1491 build_string (sequence), \ |
1484 vector1 (intern (sym))); \ | 1492 vector1 (intern (sym))); \ |
1485 } | 1493 } |
1486 | 1494 |
1487 /* if there's no key_next keycap, map key_npage to `next' keysym */ | 1495 /* if there's no key_next keycap, map key_npage to `next' keysym */ |
1488 CONDITIONAL_REASSIGN ("%5", "kN", "next"); | 1496 CONDITIONAL_REASSIGN ("%5", "kN", "next"); |
1489 /* if there's no key_prev keycap, map key_ppage to `previous' keysym */ | 1497 /* if there's no key_prev keycap, map key_ppage to `previous' keysym */ |
1490 CONDITIONAL_REASSIGN ("%8", "kP", "prior"); | 1498 CONDITIONAL_REASSIGN ("%8", "kP", "prior"); |
1491 /* if there's no key_dc keycap, map key_ic to `insert' keysym */ | 1499 /* if there's no key_dc keycap, map key_ic to `insert' keysym */ |