Mercurial > hg > xemacs-beta
comparison src/redisplay-tty.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
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 | 56 EXTERN_C int tgetent (const char *, const char *); |
57 extern "C" { | 57 EXTERN_C int tgetflag (const char *); |
58 #endif | 58 EXTERN_C int tgetnum (const char *); |
59 extern int tgetent (CONST char *, CONST char *); | 59 EXTERN_C char *tgetstr (const char *, char **); |
60 extern int tgetflag (CONST char *); | 60 EXTERN_C void tputs (const char *, int, void (*)(int)); |
61 extern int tgetnum (CONST char *); | 61 |
62 extern char *tgetstr (CONST char *, char **); | |
63 extern void tputs (CONST char *, int, void (*)(int)); | |
64 #ifdef __cplusplus | |
65 } | |
66 #endif | |
67 #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0) | 62 #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0) |
68 #define OUTPUTN(c, a, n) \ | 63 #define OUTPUTN(c, a, n) \ |
69 do { \ | 64 do { \ |
70 cmputc_console = c; \ | 65 cmputc_console = c; \ |
71 FORCE_CURSOR_UPDATE (c); \ | 66 FORCE_CURSOR_UPDATE (c); \ |
105 is considered to be fixed width -- in other words, we return LEN. | 100 is considered to be fixed width -- in other words, we return LEN. |
106 Under Mule, however, a character can still cover more than one | 101 Under Mule, however, a character can still cover more than one |
107 column, so we use emchar_string_displayed_columns(). | 102 column, so we use emchar_string_displayed_columns(). |
108 ****************************************************************************/ | 103 ****************************************************************************/ |
109 static int | 104 static int |
110 tty_text_width (struct frame *f, struct face_cachel *cachel, CONST Emchar *str, | 105 tty_text_width (struct frame *f, struct face_cachel *cachel, const Emchar *str, |
111 Charcount len) | 106 Charcount len) |
112 { | 107 { |
113 return emchar_string_displayed_columns (str, len); | 108 return emchar_string_displayed_columns (str, len); |
114 } | 109 } |
115 | 110 |
136 { | 131 { |
137 return 1; | 132 return 1; |
138 } | 133 } |
139 | 134 |
140 /***************************************************************************** | 135 /***************************************************************************** |
141 tty_output_begin | 136 tty_frame_output_begin |
142 | 137 |
143 Perform any necessary initialization prior to an update. | 138 Perform any necessary initialization prior to an update. |
144 ****************************************************************************/ | 139 ****************************************************************************/ |
145 #ifdef DEBUG_XEMACS | 140 #ifdef DEBUG_XEMACS |
146 void tty_output_begin (struct device *d); | 141 void tty_frame_output_begin (struct frame *f); |
147 void | 142 void |
148 #else | 143 #else |
149 static void | 144 static void |
150 #endif | 145 #endif |
151 tty_output_begin (struct device *d) | 146 tty_frame_output_begin (struct frame *f) |
152 { | 147 { |
153 #ifndef HAVE_TERMIOS | 148 #ifndef HAVE_TERMIOS |
154 /* Termcap requires `ospeed' to be a global variable so we have to | 149 /* Termcap requires `ospeed' to be a global variable so we have to |
155 always set it for whatever tty console we are actually currently | 150 always set it for whatever tty console we are actually currently |
156 working with. */ | 151 working with. */ |
157 ospeed = DEVICE_TTY_DATA (d)->ospeed; | 152 ospeed = DEVICE_TTY_DATA (XDEVICE (FRAME_DEVICE (f)))->ospeed; |
158 #endif | 153 #endif |
159 } | 154 } |
160 | 155 |
161 /***************************************************************************** | 156 /***************************************************************************** |
162 tty_output_end | 157 tty_frame_output_end |
163 | 158 |
164 Perform any necessary flushing of queues when an update has completed. | 159 Perform any necessary flushing of queues when an update has completed. |
165 ****************************************************************************/ | 160 ****************************************************************************/ |
166 #ifdef DEBUG_XEMACS | 161 #ifdef DEBUG_XEMACS |
167 void tty_output_end (struct device *d); | 162 void tty_frame_output_end (struct frame *f); |
168 void | 163 void |
169 #else | 164 #else |
170 static void | 165 static void |
171 #endif | 166 #endif |
172 tty_output_end (struct device *d) | 167 tty_frame_output_end (struct frame *f) |
173 { | 168 { |
174 struct console *c = XCONSOLE (DEVICE_CONSOLE (d)); | 169 struct console *c = XCONSOLE (FRAME_CONSOLE (f)); |
175 | 170 |
176 CONSOLE_TTY_CURSOR_X (c) = CONSOLE_TTY_FINAL_CURSOR_X (c); | 171 CONSOLE_TTY_CURSOR_X (c) = CONSOLE_TTY_FINAL_CURSOR_X (c); |
177 CONSOLE_TTY_CURSOR_Y (c) = CONSOLE_TTY_FINAL_CURSOR_Y (c); | 172 CONSOLE_TTY_CURSOR_Y (c) = CONSOLE_TTY_FINAL_CURSOR_Y (c); |
178 FORCE_CURSOR_UPDATE (c); | 173 FORCE_CURSOR_UPDATE (c); |
179 Lstream_flush (XLSTREAM (CONSOLE_TTY_DATA (c)->outstream)); | 174 Lstream_flush (XLSTREAM (CONSOLE_TTY_DATA (c)->outstream)); |
331 XSETWINDOW (window, w); | 326 XSETWINDOW (window, w); |
332 instance = glyph_image_instance (rb->object.dglyph.glyph, | 327 instance = glyph_image_instance (rb->object.dglyph.glyph, |
333 window, ERROR_ME_NOT, 1); | 328 window, ERROR_ME_NOT, 1); |
334 | 329 |
335 if (IMAGE_INSTANCEP (instance)) | 330 if (IMAGE_INSTANCEP (instance)) |
336 switch (XIMAGE_INSTANCE_TYPE (instance)) | 331 { |
337 { | 332 switch (XIMAGE_INSTANCE_TYPE (instance)) |
338 case IMAGE_TEXT: | |
339 { | 333 { |
340 Bufbyte *temptemp; | 334 case IMAGE_MONO_PIXMAP: |
341 Lisp_Object string = | 335 case IMAGE_COLOR_PIXMAP: |
342 XIMAGE_INSTANCE_TEXT_STRING (instance); | 336 case IMAGE_SUBWINDOW: |
343 Bytecount len = XSTRING_LENGTH (string); | 337 case IMAGE_WIDGET: |
344 | 338 /* just do nothing here */ |
345 /* In the unlikely instance that a garbage-collect | 339 break; |
346 occurs during encoding, we at least need to | 340 |
347 copy the string. | 341 case IMAGE_NOTHING: |
348 */ | 342 /* nothing is as nothing does */ |
349 temptemp = (Bufbyte *) alloca (len); | 343 break; |
350 memcpy (temptemp, XSTRING_DATA (string), len); | 344 |
351 { | 345 case IMAGE_TEXT: |
352 int i; | 346 case IMAGE_POINTER: |
353 | 347 default: |
354 /* Now truncate the first rb->object.dglyph.xoffset | 348 abort (); |
355 columns. */ | |
356 for (i = 0; i < rb->object.dglyph.xoffset;) | |
357 { | |
358 #ifdef MULE | |
359 Emchar ch = charptr_emchar (temptemp); | |
360 i += XCHARSET_COLUMNS (CHAR_CHARSET (ch)); | |
361 #else | |
362 i++; /* telescope this */ | |
363 #endif | |
364 INC_CHARPTR (temptemp); | |
365 } | |
366 | |
367 /* If we truncated one column too many, then | |
368 add a space at the beginning. */ | |
369 if (i > rb->object.dglyph.xoffset) | |
370 { | |
371 assert (i > 0); | |
372 *--temptemp = ' '; | |
373 i--; | |
374 } | |
375 len -= i; | |
376 } | |
377 | |
378 tty_output_bufbyte_string (w, dl, temptemp, len, | |
379 xpos, findex, 0); | |
380 | |
381 if (xpos >= cursor_start | |
382 && (cursor_start < | |
383 xpos + (bufbyte_string_displayed_columns | |
384 (temptemp, len)))) | |
385 { | |
386 cmgoto (f, dl->ypos - 1, cursor_start); | |
387 } | |
388 } | 349 } |
389 break; | 350 IMAGE_INSTANCE_OPTIMIZE_OUTPUT |
390 | 351 (XIMAGE_INSTANCE (instance)) = 0; |
391 case IMAGE_MONO_PIXMAP: | 352 } |
392 case IMAGE_COLOR_PIXMAP: | |
393 case IMAGE_SUBWINDOW: | |
394 case IMAGE_WIDGET: | |
395 case IMAGE_LAYOUT: | |
396 /* just do nothing here */ | |
397 break; | |
398 | |
399 case IMAGE_POINTER: | |
400 abort (); | |
401 | |
402 case IMAGE_NOTHING: | |
403 /* nothing is as nothing does */ | |
404 break; | |
405 | |
406 default: | |
407 abort (); | |
408 } | |
409 | 353 |
410 xpos += rb->width; | 354 xpos += rb->width; |
411 elt++; | 355 elt++; |
412 } | 356 } |
413 else | 357 else |
564 #ifdef NOT_SURE | 508 #ifdef NOT_SURE |
565 internal_cursor_to (f, 0, 0); | 509 internal_cursor_to (f, 0, 0); |
566 clear_to_end (f); | 510 clear_to_end (f); |
567 #else | 511 #else |
568 /* #### Not implemented. */ | 512 /* #### Not implemented. */ |
569 fprintf (stderr, "Not yet.\n"); | 513 stderr_out ("Not yet.\n"); |
570 #endif | 514 #endif |
571 } | 515 } |
572 tty_turn_off_frame_face (f, Vdefault_face); | 516 tty_turn_off_frame_face (f, Vdefault_face); |
573 } | 517 } |
574 | 518 |
935 | 879 |
936 OUTPUT1_IF (c, TTY_SD (c).orig_pair); | 880 OUTPUT1_IF (c, TTY_SD (c).orig_pair); |
937 OUTPUT1_IF (c, TTY_SD (c).keypad_off); | 881 OUTPUT1_IF (c, TTY_SD (c).keypad_off); |
938 OUTPUT1_IF (c, TTY_SD (c).cursor_normal); | 882 OUTPUT1_IF (c, TTY_SD (c).cursor_normal); |
939 OUTPUT1_IF (c, TTY_SD (c).end_motion); | 883 OUTPUT1_IF (c, TTY_SD (c).end_motion); |
940 tty_output_end (XDEVICE (CONSOLE_SELECTED_DEVICE (c))); | 884 |
885 { | |
886 Lisp_Object frm = CONSOLE_SELECTED_FRAME (c); | |
887 | |
888 if (!NILP (frm)) | |
889 tty_frame_output_end (XFRAME (frm)); | |
890 } | |
941 } | 891 } |
942 | 892 |
943 /***************************************************************************** | 893 /***************************************************************************** |
944 tty_redisplay_shutdown | 894 tty_redisplay_shutdown |
945 | 895 |
962 redisplay_clear_region (FRAME_SELECTED_WINDOW (f), DEFAULT_INDEX, 0, | 912 redisplay_clear_region (FRAME_SELECTED_WINDOW (f), DEFAULT_INDEX, 0, |
963 f->height, f->width, 1); | 913 f->height, f->width, 1); |
964 | 914 |
965 /* And then stick the cursor there. */ | 915 /* And then stick the cursor there. */ |
966 tty_set_final_cursor_coords (f, f->height, 0); | 916 tty_set_final_cursor_coords (f, f->height, 0); |
967 tty_output_end (XDEVICE (dev)); | 917 tty_frame_output_end (f); |
968 } | 918 } |
969 } | 919 } |
970 } | 920 } |
971 | 921 |
972 | 922 |
973 /* #### Everything below here is old shit. It should either be moved | 923 /* #### Everything below here is old shit. It should either be moved |
974 up or removed. */ | 924 up or removed. */ |
975 | 925 |
976 | 926 |
977 /* FLAGS - these don't need to be console local since only one console | 927 /* FLAGS - these don't need to be console local since only one console |
978 can be being updated at a time. */ | 928 can be being updated at a time. */ |
979 static int insert_mode_on; /* nonzero if in insert mode */ | 929 static int insert_mode_on; /* nonzero if in insert mode */ |
980 static int standout_mode_on; /* nonzero if in standout mode */ | 930 static int standout_mode_on; /* nonzero if in standout mode */ |
981 static int underline_mode_on; /* nonzero if in underline mode */ | 931 static int underline_mode_on; /* nonzero if in underline mode */ |
982 static int alternate_mode_on; /* nonzero if in alternate char set */ | 932 static int alternate_mode_on; /* nonzero if in alternate char set */ |
983 static int attributes_on; /* nonzero if any attributes on */ | 933 static int attributes_on; /* nonzero if any attributes on */ |
1107 doing this after all the tgetstr()s and adjusting all the | 1057 doing this after all the tgetstr()s and adjusting all the |
1108 pointers. */ | 1058 pointers. */ |
1109 CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044); | 1059 CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044); |
1110 bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer; | 1060 bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer; |
1111 | 1061 |
1112 #if !defined(WIN32) | 1062 #ifdef SIGTTOU |
1113 /* SIGTT* don't exist under win32 */ | 1063 /* SIGTT* don't exist under win32 */ |
1114 EMACS_BLOCK_SIGNAL (SIGTTOU); | 1064 EMACS_BLOCK_SIGNAL (SIGTTOU); |
1115 #endif | 1065 #endif |
1116 status = tgetent (entry_buffer, terminal_type); | 1066 status = tgetent (entry_buffer, terminal_type); |
1117 #if !defined(WIN32) | 1067 #ifdef SIGTTOU |
1118 EMACS_UNBLOCK_SIGNAL (SIGTTOU); | 1068 EMACS_UNBLOCK_SIGNAL (SIGTTOU); |
1119 #endif | 1069 #endif |
1120 #if 0 | 1070 #if 0 |
1121 if (status < 0) | 1071 if (status < 0) |
1122 return TTY_UNABLE_OPEN_DATABASE; | 1072 return TTY_UNABLE_OPEN_DATABASE; |
1303 return TTY_INIT_SUCCESS; | 1253 return TTY_INIT_SUCCESS; |
1304 } | 1254 } |
1305 | 1255 |
1306 struct fkey_table | 1256 struct fkey_table |
1307 { | 1257 { |
1308 CONST char *cap; | 1258 const char *cap; |
1309 CONST char *name; | 1259 const char *name; |
1310 }; | 1260 }; |
1311 | 1261 |
1312 /* Termcap capability names that correspond directly to X keysyms. | 1262 /* Termcap capability names that correspond directly to X keysyms. |
1313 Some of these (marked "terminfo") aren't supplied by old-style | 1263 Some of these (marked "terminfo") aren't supplied by old-style |
1314 (Berkeley) termcap entries. They're listed in X keysym order; | 1264 (Berkeley) termcap entries. They're listed in X keysym order; |
1446 describes F10, whereas othertimes it describes F0 and "k;" describes F10. | 1396 describes F10, whereas othertimes it describes F0 and "k;" describes F10. |
1447 We will attempt to politely accommodate both systems by testing for | 1397 We will attempt to politely accommodate both systems by testing for |
1448 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. | 1398 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. |
1449 */ | 1399 */ |
1450 { | 1400 { |
1451 CONST char *k_semi = tgetstr ("k;", address); | 1401 const char *k_semi = tgetstr ("k;", address); |
1452 CONST char *k0 = tgetstr ("k0", address); | 1402 const char *k0 = tgetstr ("k0", address); |
1453 | 1403 |
1454 if (k_semi) | 1404 if (k_semi) |
1455 Fdefine_key (function_key_map, build_ext_string (k_semi, Qbinary), | 1405 Fdefine_key (function_key_map, build_ext_string (k_semi, Qbinary), |
1456 vector1 (intern ("f10"))); | 1406 vector1 (intern ("f10"))); |
1457 | 1407 |
1539 CONSOLE_HAS_METHOD (tty, divider_height); | 1489 CONSOLE_HAS_METHOD (tty, divider_height); |
1540 CONSOLE_HAS_METHOD (tty, eol_cursor_width); | 1490 CONSOLE_HAS_METHOD (tty, eol_cursor_width); |
1541 CONSOLE_HAS_METHOD (tty, clear_to_window_end); | 1491 CONSOLE_HAS_METHOD (tty, clear_to_window_end); |
1542 CONSOLE_HAS_METHOD (tty, clear_region); | 1492 CONSOLE_HAS_METHOD (tty, clear_region); |
1543 CONSOLE_HAS_METHOD (tty, clear_frame); | 1493 CONSOLE_HAS_METHOD (tty, clear_frame); |
1544 CONSOLE_HAS_METHOD (tty, output_begin); | 1494 CONSOLE_HAS_METHOD (tty, frame_output_begin); |
1545 CONSOLE_HAS_METHOD (tty, output_end); | 1495 CONSOLE_HAS_METHOD (tty, frame_output_end); |
1546 CONSOLE_HAS_METHOD (tty, flash); | 1496 CONSOLE_HAS_METHOD (tty, flash); |
1547 CONSOLE_HAS_METHOD (tty, ring_bell); | 1497 CONSOLE_HAS_METHOD (tty, ring_bell); |
1548 CONSOLE_HAS_METHOD (tty, set_final_cursor_coords); | 1498 CONSOLE_HAS_METHOD (tty, set_final_cursor_coords); |
1549 } | 1499 } |