1 /* Terminal control module for terminals described by TERMCAP
2 Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2011
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 /* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */
37 #include "character.h"
40 #include "composite.h"
44 #include "termhooks.h"
45 #include "dispextern.h"
48 #include "blockinput.h"
49 #include "syssignal.h"
51 #include "intervals.h"
54 static int been_here
= -1;
70 /* The name of the default console device. */
72 #define DEV_TTY "CONOUT$"
74 #define DEV_TTY "/dev/tty"
77 static void tty_set_scroll_region (struct frame
*f
, int start
, int stop
);
78 static void turn_on_face (struct frame
*, int face_id
);
79 static void turn_off_face (struct frame
*, int face_id
);
80 static void tty_turn_off_highlight (struct tty_display_info
*);
81 static void tty_show_cursor (struct tty_display_info
*);
82 static void tty_hide_cursor (struct tty_display_info
*);
83 static void tty_background_highlight (struct tty_display_info
*tty
);
84 static struct terminal
*get_tty_terminal (Lisp_Object
, int);
85 static void clear_tty_hooks (struct terminal
*terminal
);
86 static void set_tty_hooks (struct terminal
*terminal
);
87 static void dissociate_if_controlling_tty (int fd
);
88 static void delete_tty (struct terminal
*);
89 static void maybe_fatal (int must_succeed
, struct terminal
*terminal
,
90 const char *str1
, const char *str2
, ...)
91 NO_RETURN
ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
92 static void vfatal (const char *str
, va_list ap
)
93 NO_RETURN
ATTRIBUTE_FORMAT_PRINTF (1, 0);
96 #define OUTPUT(tty, a) \
97 emacs_tputs ((tty), a, \
98 (int) (FRAME_LINES (XFRAME (selected_frame)) \
102 #define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
103 #define OUTPUTL(tty, a, lines) emacs_tputs ((tty), a, lines, cmputc)
105 #define OUTPUT_IF(tty, a) \
111 #define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0)
113 /* Display space properties */
115 /* Chain of all tty device parameters. */
116 struct tty_display_info
*tty_list
;
118 /* Meaning of bits in no_color_video. Each bit set means that the
119 corresponding attribute cannot be combined with colors. */
123 NC_STANDOUT
= 1 << 0,
124 NC_UNDERLINE
= 1 << 1,
131 NC_ALT_CHARSET
= 1 << 8
136 /* The largest frame width in any call to calculate_costs. */
138 static int max_frame_cols
;
140 /* The largest frame height in any call to calculate_costs. */
142 static int max_frame_lines
;
144 /* Non-zero if we have dropped our controlling tty and therefore
145 should not open a frame on stdout. */
146 static int no_controlling_tty
;
151 #include <sys/fcntl.h>
153 /* The device for which we have enabled gpm support (or NULL). */
154 struct tty_display_info
*gpm_tty
= NULL
;
156 /* Last recorded mouse coordinates. */
157 static int last_mouse_x
, last_mouse_y
;
158 #endif /* HAVE_GPM */
160 /* Ring the bell on a tty. */
163 tty_ring_bell (struct frame
*f
)
165 struct tty_display_info
*tty
= FRAME_TTY (f
);
169 OUTPUT (tty
, (tty
->TS_visible_bell
&& visible_bell
170 ? tty
->TS_visible_bell
172 fflush (tty
->output
);
176 /* Set up termcap modes for Emacs. */
179 tty_set_terminal_modes (struct terminal
*terminal
)
181 struct tty_display_info
*tty
= terminal
->display_info
.tty
;
185 if (tty
->TS_termcap_modes
)
186 OUTPUT (tty
, tty
->TS_termcap_modes
);
189 /* Output enough newlines to scroll all the old screen contents
190 off the screen, so it won't be overwritten and lost. */
193 for (i
= 0; i
< FRAME_LINES (XFRAME (selected_frame
)); i
++)
197 OUTPUT_IF (tty
, visible_cursor
? tty
->TS_cursor_visible
: tty
->TS_cursor_normal
);
198 OUTPUT_IF (tty
, tty
->TS_keypad_mode
);
200 fflush (tty
->output
);
204 /* Reset termcap modes before exiting Emacs. */
207 tty_reset_terminal_modes (struct terminal
*terminal
)
209 struct tty_display_info
*tty
= terminal
->display_info
.tty
;
213 tty_turn_off_highlight (tty
);
214 tty_turn_off_insert (tty
);
215 OUTPUT_IF (tty
, tty
->TS_end_keypad_mode
);
216 OUTPUT_IF (tty
, tty
->TS_cursor_normal
);
217 OUTPUT_IF (tty
, tty
->TS_end_termcap_modes
);
218 OUTPUT_IF (tty
, tty
->TS_orig_pair
);
219 /* Output raw CR so kernel can track the cursor hpos. */
222 fflush (tty
->output
);
226 /* Flag the end of a display update on a termcap terminal. */
229 tty_update_end (struct frame
*f
)
231 struct tty_display_info
*tty
= FRAME_TTY (f
);
233 if (!XWINDOW (selected_window
)->cursor_off_p
)
234 tty_show_cursor (tty
);
235 tty_turn_off_insert (tty
);
236 tty_background_highlight (tty
);
239 /* The implementation of set_terminal_window for termcap frames. */
242 tty_set_terminal_window (struct frame
*f
, int size
)
244 struct tty_display_info
*tty
= FRAME_TTY (f
);
246 tty
->specified_window
= size
? size
: FRAME_LINES (f
);
247 if (FRAME_SCROLL_REGION_OK (f
))
248 tty_set_scroll_region (f
, 0, tty
->specified_window
);
252 tty_set_scroll_region (struct frame
*f
, int start
, int stop
)
255 struct tty_display_info
*tty
= FRAME_TTY (f
);
257 if (tty
->TS_set_scroll_region
)
258 buf
= tparam (tty
->TS_set_scroll_region
, 0, 0, start
, stop
- 1, 0, 0);
259 else if (tty
->TS_set_scroll_region_1
)
260 buf
= tparam (tty
->TS_set_scroll_region_1
, 0, 0,
261 FRAME_LINES (f
), start
,
262 FRAME_LINES (f
) - stop
,
265 buf
= tparam (tty
->TS_set_window
, 0, 0, start
, 0, stop
, FRAME_COLS (f
));
274 tty_turn_on_insert (struct tty_display_info
*tty
)
276 if (!tty
->insert_mode
)
277 OUTPUT (tty
, tty
->TS_insert_mode
);
278 tty
->insert_mode
= 1;
282 tty_turn_off_insert (struct tty_display_info
*tty
)
284 if (tty
->insert_mode
)
285 OUTPUT (tty
, tty
->TS_end_insert_mode
);
286 tty
->insert_mode
= 0;
289 /* Handle highlighting. */
292 tty_turn_off_highlight (struct tty_display_info
*tty
)
294 if (tty
->standout_mode
)
295 OUTPUT_IF (tty
, tty
->TS_end_standout_mode
);
296 tty
->standout_mode
= 0;
300 tty_turn_on_highlight (struct tty_display_info
*tty
)
302 if (!tty
->standout_mode
)
303 OUTPUT_IF (tty
, tty
->TS_standout_mode
);
304 tty
->standout_mode
= 1;
308 tty_toggle_highlight (struct tty_display_info
*tty
)
310 if (tty
->standout_mode
)
311 tty_turn_off_highlight (tty
);
313 tty_turn_on_highlight (tty
);
317 /* Make cursor invisible. */
320 tty_hide_cursor (struct tty_display_info
*tty
)
322 if (tty
->cursor_hidden
== 0)
324 tty
->cursor_hidden
= 1;
325 OUTPUT_IF (tty
, tty
->TS_cursor_invisible
);
330 /* Ensure that cursor is visible. */
333 tty_show_cursor (struct tty_display_info
*tty
)
335 if (tty
->cursor_hidden
)
337 tty
->cursor_hidden
= 0;
338 OUTPUT_IF (tty
, tty
->TS_cursor_normal
);
340 OUTPUT_IF (tty
, tty
->TS_cursor_visible
);
345 /* Set standout mode to the state it should be in for
346 empty space inside windows. What this is,
347 depends on the user option inverse-video. */
350 tty_background_highlight (struct tty_display_info
*tty
)
353 tty_turn_on_highlight (tty
);
355 tty_turn_off_highlight (tty
);
358 /* Set standout mode to the mode specified for the text to be output. */
361 tty_highlight_if_desired (struct tty_display_info
*tty
)
364 tty_turn_on_highlight (tty
);
366 tty_turn_off_highlight (tty
);
370 /* Move cursor to row/column position VPOS/HPOS. HPOS/VPOS are
371 frame-relative coordinates. */
374 tty_cursor_to (struct frame
*f
, int vpos
, int hpos
)
376 struct tty_display_info
*tty
= FRAME_TTY (f
);
378 /* Detect the case where we are called from reset_sys_modes
379 and the costs have never been calculated. Do nothing. */
380 if (! tty
->costs_set
)
383 if (curY (tty
) == vpos
384 && curX (tty
) == hpos
)
386 if (!tty
->TF_standout_motion
)
387 tty_background_highlight (tty
);
388 if (!tty
->TF_insmode_motion
)
389 tty_turn_off_insert (tty
);
390 cmgoto (tty
, vpos
, hpos
);
393 /* Similar but don't take any account of the wasted characters. */
396 tty_raw_cursor_to (struct frame
*f
, int row
, int col
)
398 struct tty_display_info
*tty
= FRAME_TTY (f
);
400 if (curY (tty
) == row
401 && curX (tty
) == col
)
403 if (!tty
->TF_standout_motion
)
404 tty_background_highlight (tty
);
405 if (!tty
->TF_insmode_motion
)
406 tty_turn_off_insert (tty
);
407 cmgoto (tty
, row
, col
);
410 /* Erase operations */
412 /* Clear from cursor to end of frame on a termcap device. */
415 tty_clear_to_end (struct frame
*f
)
418 struct tty_display_info
*tty
= FRAME_TTY (f
);
420 if (tty
->TS_clr_to_bottom
)
422 tty_background_highlight (tty
);
423 OUTPUT (tty
, tty
->TS_clr_to_bottom
);
427 for (i
= curY (tty
); i
< FRAME_LINES (f
); i
++)
430 clear_end_of_line (f
, FRAME_COLS (f
));
435 /* Clear an entire termcap frame. */
438 tty_clear_frame (struct frame
*f
)
440 struct tty_display_info
*tty
= FRAME_TTY (f
);
442 if (tty
->TS_clr_frame
)
444 tty_background_highlight (tty
);
445 OUTPUT (tty
, tty
->TS_clr_frame
);
455 /* An implementation of clear_end_of_line for termcap frames.
457 Note that the cursor may be moved, on terminals lacking a `ce' string. */
460 tty_clear_end_of_line (struct frame
*f
, int first_unused_hpos
)
463 struct tty_display_info
*tty
= FRAME_TTY (f
);
465 /* Detect the case where we are called from reset_sys_modes
466 and the costs have never been calculated. Do nothing. */
467 if (! tty
->costs_set
)
470 if (curX (tty
) >= first_unused_hpos
)
472 tty_background_highlight (tty
);
473 if (tty
->TS_clr_line
)
475 OUTPUT1 (tty
, tty
->TS_clr_line
);
478 { /* have to do it the hard way */
479 tty_turn_off_insert (tty
);
481 /* Do not write in last row last col with Auto-wrap on. */
483 && curY (tty
) == FrameRows (tty
) - 1
484 && first_unused_hpos
== FrameCols (tty
))
487 for (i
= curX (tty
); i
< first_unused_hpos
; i
++)
490 fputc (' ', tty
->termscript
);
491 fputc (' ', tty
->output
);
493 cmplus (tty
, first_unused_hpos
- curX (tty
));
497 /* Buffers to store the source and result of code conversion for terminal. */
498 static unsigned char *encode_terminal_src
;
499 static unsigned char *encode_terminal_dst
;
500 /* Allocated sizes of the above buffers. */
501 static int encode_terminal_src_size
;
502 static int encode_terminal_dst_size
;
504 /* Encode SRC_LEN glyphs starting at SRC to terminal output codes.
505 Set CODING->produced to the byte-length of the resulting byte
506 sequence, and return a pointer to that byte sequence. */
509 encode_terminal_code (struct glyph
*src
, int src_len
, struct coding_system
*coding
)
511 struct glyph
*src_end
= src
+ src_len
;
513 int nchars
, nbytes
, required
;
514 register int tlen
= GLYPH_TABLE_LENGTH
;
515 register Lisp_Object
*tbase
= GLYPH_TABLE_BASE
;
516 Lisp_Object charset_list
;
518 /* Allocate sufficient size of buffer to store all characters in
519 multibyte-form. But, it may be enlarged on demand if
520 Vglyph_table contains a string or a composite glyph is
522 required
= MAX_MULTIBYTE_LENGTH
* src_len
;
523 if (encode_terminal_src_size
< required
)
525 if (encode_terminal_src
)
526 encode_terminal_src
= xrealloc (encode_terminal_src
, required
);
528 encode_terminal_src
= xmalloc (required
);
529 encode_terminal_src_size
= required
;
532 charset_list
= coding_charset_list (coding
);
534 buf
= encode_terminal_src
;
536 while (src
< src_end
)
538 if (src
->type
== COMPOSITE_GLYPH
)
540 struct composition
*cmp
IF_LINT (= NULL
);
541 Lisp_Object gstring
IF_LINT (= Qnil
);
544 nbytes
= buf
- encode_terminal_src
;
545 if (src
->u
.cmp
.automatic
)
547 gstring
= composition_gstring_from_id (src
->u
.cmp
.id
);
548 required
= src
->slice
.cmp
.to
+ 1 - src
->slice
.cmp
.from
;
552 cmp
= composition_table
[src
->u
.cmp
.id
];
553 required
= MAX_MULTIBYTE_LENGTH
* cmp
->glyph_len
;
556 if (encode_terminal_src_size
< nbytes
+ required
)
558 encode_terminal_src_size
= nbytes
+ required
;
559 encode_terminal_src
= xrealloc (encode_terminal_src
,
560 encode_terminal_src_size
);
561 buf
= encode_terminal_src
+ nbytes
;
564 if (src
->u
.cmp
.automatic
)
565 for (i
= src
->slice
.cmp
.from
; i
<= src
->slice
.cmp
.to
; i
++)
567 Lisp_Object g
= LGSTRING_GLYPH (gstring
, i
);
568 int c
= LGLYPH_CHAR (g
);
570 if (! char_charset (c
, charset_list
, NULL
))
572 buf
+= CHAR_STRING (c
, buf
);
576 for (i
= 0; i
< cmp
->glyph_len
; i
++)
578 int c
= COMPOSITION_GLYPH (cmp
, i
);
582 if (char_charset (c
, charset_list
, NULL
))
584 if (CHAR_WIDTH (c
) == 0
585 && i
> 0 && COMPOSITION_GLYPH (cmp
, i
- 1) == '\t')
586 /* Should be left-padded */
588 buf
+= CHAR_STRING (' ', buf
);
594 buf
+= CHAR_STRING (c
, buf
);
598 /* We must skip glyphs to be padded for a wide character. */
599 else if (! CHAR_GLYPH_PADDING_P (*src
))
606 SET_GLYPH_FROM_CHAR_GLYPH (g
, src
[0]);
608 if (GLYPH_INVALID_P (g
) || GLYPH_SIMPLE_P (tbase
, tlen
, g
))
610 /* This glyph doesn't have an entry in Vglyph_table. */
615 /* This glyph has an entry in Vglyph_table,
616 so process any alias before testing for simpleness. */
617 GLYPH_FOLLOW_ALIASES (tbase
, tlen
, g
);
619 if (GLYPH_SIMPLE_P (tbase
, tlen
, g
))
620 /* We set the multi-byte form of a character in G
621 (that should be an ASCII character) at WORKBUF. */
624 /* We have a string in Vglyph_table. */
625 string
= tbase
[GLYPH_CHAR (g
)];
630 nbytes
= buf
- encode_terminal_src
;
631 if (encode_terminal_src_size
< nbytes
+ MAX_MULTIBYTE_LENGTH
)
633 encode_terminal_src_size
= nbytes
+ MAX_MULTIBYTE_LENGTH
;
634 encode_terminal_src
= xrealloc (encode_terminal_src
,
635 encode_terminal_src_size
);
636 buf
= encode_terminal_src
+ nbytes
;
639 || char_charset (c
, charset_list
, NULL
))
641 /* Store the multibyte form of C at BUF. */
642 buf
+= CHAR_STRING (c
, buf
);
647 /* C is not encodable. */
650 while (src
+ 1 < src_end
&& CHAR_GLYPH_PADDING_P (src
[1]))
660 if (! STRING_MULTIBYTE (string
))
661 string
= string_to_multibyte (string
);
662 nbytes
= buf
- encode_terminal_src
;
663 if (encode_terminal_src_size
< nbytes
+ SBYTES (string
))
665 encode_terminal_src_size
= nbytes
+ SBYTES (string
);
666 encode_terminal_src
= xrealloc (encode_terminal_src
,
667 encode_terminal_src_size
);
668 buf
= encode_terminal_src
+ nbytes
;
670 memcpy (buf
, SDATA (string
), SBYTES (string
));
671 buf
+= SBYTES (string
);
672 nchars
+= SCHARS (string
);
680 coding
->produced
= 0;
684 nbytes
= buf
- encode_terminal_src
;
685 coding
->source
= encode_terminal_src
;
686 if (encode_terminal_dst_size
== 0)
688 encode_terminal_dst_size
= encode_terminal_src_size
;
689 if (encode_terminal_dst
)
690 encode_terminal_dst
= xrealloc (encode_terminal_dst
,
691 encode_terminal_dst_size
);
693 encode_terminal_dst
= xmalloc (encode_terminal_dst_size
);
695 coding
->destination
= encode_terminal_dst
;
696 coding
->dst_bytes
= encode_terminal_dst_size
;
697 encode_coding_object (coding
, Qnil
, 0, 0, nchars
, nbytes
, Qnil
);
698 /* coding->destination may have been reallocated. */
699 encode_terminal_dst
= coding
->destination
;
700 encode_terminal_dst_size
= coding
->dst_bytes
;
702 return (encode_terminal_dst
);
707 /* An implementation of write_glyphs for termcap frames. */
710 tty_write_glyphs (struct frame
*f
, struct glyph
*string
, int len
)
712 unsigned char *conversion_buffer
;
713 struct coding_system
*coding
;
716 struct tty_display_info
*tty
= FRAME_TTY (f
);
718 tty_turn_off_insert (tty
);
719 tty_hide_cursor (tty
);
721 /* Don't dare write in last column of bottom line, if Auto-Wrap,
722 since that would scroll the whole frame on some terminals. */
725 && curY (tty
) + 1 == FRAME_LINES (f
)
726 && (curX (tty
) + len
) == FRAME_COLS (f
))
733 /* If terminal_coding does any conversion, use it, otherwise use
734 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
735 because it always return 1 if the member src_multibyte is 1. */
736 coding
= (FRAME_TERMINAL_CODING (f
)->common_flags
& CODING_REQUIRE_ENCODING_MASK
737 ? FRAME_TERMINAL_CODING (f
) : &safe_terminal_coding
);
738 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
740 coding
->mode
&= ~CODING_MODE_LAST_BLOCK
;
742 for (stringlen
= len
; stringlen
!= 0; stringlen
-= n
)
744 /* Identify a run of glyphs with the same face. */
745 int face_id
= string
->face_id
;
747 for (n
= 1; n
< stringlen
; ++n
)
748 if (string
[n
].face_id
!= face_id
)
751 /* Turn appearance modes of the face of the run on. */
752 tty_highlight_if_desired (tty
);
753 turn_on_face (f
, face_id
);
756 /* This is the last run. */
757 coding
->mode
|= CODING_MODE_LAST_BLOCK
;
758 conversion_buffer
= encode_terminal_code (string
, n
, coding
);
759 if (coding
->produced
> 0)
762 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->output
);
763 if (ferror (tty
->output
))
764 clearerr (tty
->output
);
766 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->termscript
);
771 /* Turn appearance modes off. */
772 turn_off_face (f
, face_id
);
773 tty_turn_off_highlight (tty
);
779 #ifdef HAVE_GPM /* Only used by GPM code. */
782 tty_write_glyphs_with_face (register struct frame
*f
, register struct glyph
*string
,
783 register int len
, register int face_id
)
785 unsigned char *conversion_buffer
;
786 struct coding_system
*coding
;
788 struct tty_display_info
*tty
= FRAME_TTY (f
);
790 tty_turn_off_insert (tty
);
791 tty_hide_cursor (tty
);
793 /* Don't dare write in last column of bottom line, if Auto-Wrap,
794 since that would scroll the whole frame on some terminals. */
797 && curY (tty
) + 1 == FRAME_LINES (f
)
798 && (curX (tty
) + len
) == FRAME_COLS (f
))
805 /* If terminal_coding does any conversion, use it, otherwise use
806 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
807 because it always return 1 if the member src_multibyte is 1. */
808 coding
= (FRAME_TERMINAL_CODING (f
)->common_flags
& CODING_REQUIRE_ENCODING_MASK
809 ? FRAME_TERMINAL_CODING (f
) : &safe_terminal_coding
);
810 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
812 coding
->mode
&= ~CODING_MODE_LAST_BLOCK
;
814 /* Turn appearance modes of the face. */
815 tty_highlight_if_desired (tty
);
816 turn_on_face (f
, face_id
);
818 coding
->mode
|= CODING_MODE_LAST_BLOCK
;
819 conversion_buffer
= encode_terminal_code (string
, len
, coding
);
820 if (coding
->produced
> 0)
823 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->output
);
824 if (ferror (tty
->output
))
825 clearerr (tty
->output
);
827 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->termscript
);
831 /* Turn appearance modes off. */
832 turn_off_face (f
, face_id
);
833 tty_turn_off_highlight (tty
);
839 /* An implementation of insert_glyphs for termcap frames. */
842 tty_insert_glyphs (struct frame
*f
, struct glyph
*start
, int len
)
845 struct glyph
*glyph
= NULL
;
846 unsigned char *conversion_buffer
;
847 unsigned char space
[1];
848 struct coding_system
*coding
;
850 struct tty_display_info
*tty
= FRAME_TTY (f
);
852 if (tty
->TS_ins_multi_chars
)
854 buf
= tparam (tty
->TS_ins_multi_chars
, 0, 0, len
, 0, 0, 0);
858 write_glyphs (f
, start
, len
);
862 tty_turn_on_insert (tty
);
866 space
[0] = SPACEGLYPH
;
868 /* If terminal_coding does any conversion, use it, otherwise use
869 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
870 because it always return 1 if the member src_multibyte is 1. */
871 coding
= (FRAME_TERMINAL_CODING (f
)->common_flags
& CODING_REQUIRE_ENCODING_MASK
872 ? FRAME_TERMINAL_CODING (f
) : &safe_terminal_coding
);
873 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
875 coding
->mode
&= ~CODING_MODE_LAST_BLOCK
;
879 OUTPUT1_IF (tty
, tty
->TS_ins_char
);
882 conversion_buffer
= space
;
883 coding
->produced
= 1;
887 tty_highlight_if_desired (tty
);
888 turn_on_face (f
, start
->face_id
);
891 /* We must open sufficient space for a character which
892 occupies more than one column. */
893 while (len
&& CHAR_GLYPH_PADDING_P (*start
))
895 OUTPUT1_IF (tty
, tty
->TS_ins_char
);
900 /* This is the last glyph. */
901 coding
->mode
|= CODING_MODE_LAST_BLOCK
;
903 conversion_buffer
= encode_terminal_code (glyph
, 1, coding
);
906 if (coding
->produced
> 0)
909 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->output
);
910 if (ferror (tty
->output
))
911 clearerr (tty
->output
);
913 fwrite (conversion_buffer
, 1, coding
->produced
, tty
->termscript
);
917 OUTPUT1_IF (tty
, tty
->TS_pad_inserted_char
);
920 turn_off_face (f
, glyph
->face_id
);
921 tty_turn_off_highlight (tty
);
928 /* An implementation of delete_glyphs for termcap frames. */
931 tty_delete_glyphs (struct frame
*f
, int n
)
936 struct tty_display_info
*tty
= FRAME_TTY (f
);
938 if (tty
->delete_in_insert_mode
)
940 tty_turn_on_insert (tty
);
944 tty_turn_off_insert (tty
);
945 OUTPUT_IF (tty
, tty
->TS_delete_mode
);
948 if (tty
->TS_del_multi_chars
)
950 buf
= tparam (tty
->TS_del_multi_chars
, 0, 0, n
, 0, 0, 0);
955 for (i
= 0; i
< n
; i
++)
956 OUTPUT1 (tty
, tty
->TS_del_char
);
957 if (!tty
->delete_in_insert_mode
)
958 OUTPUT_IF (tty
, tty
->TS_end_delete_mode
);
961 /* An implementation of ins_del_lines for termcap frames. */
964 tty_ins_del_lines (struct frame
*f
, int vpos
, int n
)
966 struct tty_display_info
*tty
= FRAME_TTY (f
);
968 n
> 0 ? tty
->TS_ins_multi_lines
: tty
->TS_del_multi_lines
;
969 const char *single
= n
> 0 ? tty
->TS_ins_line
: tty
->TS_del_line
;
970 const char *scroll
= n
> 0 ? tty
->TS_rev_scroll
: tty
->TS_fwd_scroll
;
972 register int i
= n
> 0 ? n
: -n
;
975 /* If the lines below the insertion are being pushed
976 into the end of the window, this is the same as clearing;
977 and we know the lines are already clear, since the matching
978 deletion has already been done. So can ignore this. */
979 /* If the lines below the deletion are blank lines coming
980 out of the end of the window, don't bother,
981 as there will be a matching inslines later that will flush them. */
982 if (FRAME_SCROLL_REGION_OK (f
)
983 && vpos
+ i
>= tty
->specified_window
)
985 if (!FRAME_MEMORY_BELOW_FRAME (f
)
986 && vpos
+ i
>= FRAME_LINES (f
))
991 raw_cursor_to (f
, vpos
, 0);
992 tty_background_highlight (tty
);
993 buf
= tparam (multi
, 0, 0, i
, 0, 0, 0);
999 raw_cursor_to (f
, vpos
, 0);
1000 tty_background_highlight (tty
);
1002 OUTPUT (tty
, single
);
1003 if (tty
->TF_teleray
)
1008 tty_set_scroll_region (f
, vpos
, tty
->specified_window
);
1010 raw_cursor_to (f
, tty
->specified_window
- 1, 0);
1012 raw_cursor_to (f
, vpos
, 0);
1013 tty_background_highlight (tty
);
1015 OUTPUTL (tty
, scroll
, tty
->specified_window
- vpos
);
1016 tty_set_scroll_region (f
, 0, tty
->specified_window
);
1019 if (!FRAME_SCROLL_REGION_OK (f
)
1020 && FRAME_MEMORY_BELOW_FRAME (f
)
1023 cursor_to (f
, FRAME_LINES (f
) + n
, 0);
1028 /* Compute cost of sending "str", in characters,
1029 not counting any line-dependent padding. */
1032 string_cost (const char *str
)
1036 tputs (str
, 0, evalcost
);
1040 /* Compute cost of sending "str", in characters,
1041 counting any line-dependent padding at one line. */
1044 string_cost_one_line (const char *str
)
1048 tputs (str
, 1, evalcost
);
1052 /* Compute per line amount of line-dependent padding,
1053 in tenths of characters. */
1056 per_line_cost (const char *str
)
1060 tputs (str
, 0, evalcost
);
1063 tputs (str
, 10, evalcost
);
1067 /* char_ins_del_cost[n] is cost of inserting N characters.
1068 char_ins_del_cost[-n] is cost of deleting N characters.
1069 The length of this vector is based on max_frame_cols. */
1071 int *char_ins_del_vector
;
1073 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_COLS ((f))])
1077 calculate_ins_del_char_costs (struct frame
*f
)
1079 struct tty_display_info
*tty
= FRAME_TTY (f
);
1080 int ins_startup_cost
, del_startup_cost
;
1081 int ins_cost_per_char
, del_cost_per_char
;
1085 if (tty
->TS_ins_multi_chars
)
1087 ins_cost_per_char
= 0;
1088 ins_startup_cost
= string_cost_one_line (tty
->TS_ins_multi_chars
);
1090 else if (tty
->TS_ins_char
|| tty
->TS_pad_inserted_char
1091 || (tty
->TS_insert_mode
&& tty
->TS_end_insert_mode
))
1093 ins_startup_cost
= (30 * (string_cost (tty
->TS_insert_mode
)
1094 + string_cost (tty
->TS_end_insert_mode
))) / 100;
1095 ins_cost_per_char
= (string_cost_one_line (tty
->TS_ins_char
)
1096 + string_cost_one_line (tty
->TS_pad_inserted_char
));
1100 ins_startup_cost
= 9999;
1101 ins_cost_per_char
= 0;
1104 if (tty
->TS_del_multi_chars
)
1106 del_cost_per_char
= 0;
1107 del_startup_cost
= string_cost_one_line (tty
->TS_del_multi_chars
);
1109 else if (tty
->TS_del_char
)
1111 del_startup_cost
= (string_cost (tty
->TS_delete_mode
)
1112 + string_cost (tty
->TS_end_delete_mode
));
1113 if (tty
->delete_in_insert_mode
)
1114 del_startup_cost
/= 2;
1115 del_cost_per_char
= string_cost_one_line (tty
->TS_del_char
);
1119 del_startup_cost
= 9999;
1120 del_cost_per_char
= 0;
1123 /* Delete costs are at negative offsets */
1124 p
= &char_ins_del_cost (f
)[0];
1125 for (i
= FRAME_COLS (f
); --i
>= 0;)
1126 *--p
= (del_startup_cost
+= del_cost_per_char
);
1128 /* Doing nothing is free */
1129 p
= &char_ins_del_cost (f
)[0];
1132 /* Insert costs are at positive offsets */
1133 for (i
= FRAME_COLS (f
); --i
>= 0;)
1134 *p
++ = (ins_startup_cost
+= ins_cost_per_char
);
1138 calculate_costs (struct frame
*frame
)
1140 FRAME_COST_BAUD_RATE (frame
) = baud_rate
;
1142 if (FRAME_TERMCAP_P (frame
))
1144 struct tty_display_info
*tty
= FRAME_TTY (frame
);
1145 register const char *f
= (tty
->TS_set_scroll_region
1146 ? tty
->TS_set_scroll_region
1147 : tty
->TS_set_scroll_region_1
);
1149 FRAME_SCROLL_REGION_COST (frame
) = string_cost (f
);
1153 /* These variables are only used for terminal stuff. They are
1154 allocated once for the terminal frame of X-windows emacs, but not
1157 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
1158 X turns off char_ins_del_ok. */
1160 max_frame_lines
= max (max_frame_lines
, FRAME_LINES (frame
));
1161 max_frame_cols
= max (max_frame_cols
, FRAME_COLS (frame
));
1163 if (char_ins_del_vector
!= 0)
1165 = (int *) xrealloc (char_ins_del_vector
,
1167 + 2 * max_frame_cols
* sizeof (int)));
1170 = (int *) xmalloc (sizeof (int)
1171 + 2 * max_frame_cols
* sizeof (int));
1173 memset (char_ins_del_vector
, 0,
1174 (sizeof (int) + 2 * max_frame_cols
* sizeof (int)));
1177 if (f
&& (!tty
->TS_ins_line
&& !tty
->TS_del_line
))
1178 do_line_insertion_deletion_costs (frame
,
1179 tty
->TS_rev_scroll
, tty
->TS_ins_multi_lines
,
1180 tty
->TS_fwd_scroll
, tty
->TS_del_multi_lines
,
1183 do_line_insertion_deletion_costs (frame
,
1184 tty
->TS_ins_line
, tty
->TS_ins_multi_lines
,
1185 tty
->TS_del_line
, tty
->TS_del_multi_lines
,
1188 calculate_ins_del_char_costs (frame
);
1190 /* Don't use TS_repeat if its padding is worse than sending the chars */
1191 if (tty
->TS_repeat
&& per_line_cost (tty
->TS_repeat
) * baud_rate
< 9000)
1192 tty
->RPov
= string_cost (tty
->TS_repeat
);
1194 tty
->RPov
= FRAME_COLS (frame
) * 2;
1196 cmcostinit (FRAME_TTY (frame
)); /* set up cursor motion costs */
1201 const char *cap
, *name
;
1204 /* Termcap capability names that correspond directly to X keysyms.
1205 Some of these (marked "terminfo") aren't supplied by old-style
1206 (Berkeley) termcap entries. They're listed in X keysym order;
1207 except we put the keypad keys first, so that if they clash with
1208 other keys (as on the IBM PC keyboard) they get overridden.
1211 static const struct fkey_table keys
[] =
1213 {"kh", "home"}, /* termcap */
1214 {"kl", "left"}, /* termcap */
1215 {"ku", "up"}, /* termcap */
1216 {"kr", "right"}, /* termcap */
1217 {"kd", "down"}, /* termcap */
1218 {"%8", "prior"}, /* terminfo */
1219 {"%5", "next"}, /* terminfo */
1220 {"@7", "end"}, /* terminfo */
1221 {"@1", "begin"}, /* terminfo */
1222 {"*6", "select"}, /* terminfo */
1223 {"%9", "print"}, /* terminfo */
1224 {"@4", "execute"}, /* terminfo --- actually the `command' key */
1226 * "insert" --- see below
1228 {"&8", "undo"}, /* terminfo */
1229 {"%0", "redo"}, /* terminfo */
1230 {"%7", "menu"}, /* terminfo --- actually the `options' key */
1231 {"@0", "find"}, /* terminfo */
1232 {"@2", "cancel"}, /* terminfo */
1233 {"%1", "help"}, /* terminfo */
1235 * "break" goes here, but can't be reliably intercepted with termcap
1237 {"&4", "reset"}, /* terminfo --- actually `restart' */
1239 * "system" and "user" --- no termcaps
1241 {"kE", "clearline"}, /* terminfo */
1242 {"kA", "insertline"}, /* terminfo */
1243 {"kL", "deleteline"}, /* terminfo */
1244 {"kI", "insertchar"}, /* terminfo */
1245 {"kD", "deletechar"}, /* terminfo */
1246 {"kB", "backtab"}, /* terminfo */
1248 * "kp_backtab", "kp-space", "kp-tab" --- no termcaps
1250 {"@8", "kp-enter"}, /* terminfo */
1252 * "kp-f1", "kp-f2", "kp-f3" "kp-f4",
1253 * "kp-multiply", "kp-add", "kp-separator",
1254 * "kp-subtract", "kp-decimal", "kp-divide", "kp-0";
1255 * --- no termcaps for any of these.
1257 {"K4", "kp-1"}, /* terminfo */
1259 * "kp-2" --- no termcap
1261 {"K5", "kp-3"}, /* terminfo */
1263 * "kp-4" --- no termcap
1265 {"K2", "kp-5"}, /* terminfo */
1267 * "kp-6" --- no termcap
1269 {"K1", "kp-7"}, /* terminfo */
1271 * "kp-8" --- no termcap
1273 {"K3", "kp-9"}, /* terminfo */
1275 * "kp-equal" --- no termcap
1287 {"&0", "S-cancel"}, /*shifted cancel key*/
1288 {"&9", "S-begin"}, /*shifted begin key*/
1289 {"*0", "S-find"}, /*shifted find key*/
1290 {"*1", "S-execute"}, /*shifted execute? actually shifted command key*/
1291 {"*4", "S-delete"}, /*shifted delete-character key*/
1292 {"*7", "S-end"}, /*shifted end key*/
1293 {"*8", "S-clearline"}, /*shifted clear-to end-of-line key*/
1294 {"#1", "S-help"}, /*shifted help key*/
1295 {"#2", "S-home"}, /*shifted home key*/
1296 {"#3", "S-insert"}, /*shifted insert-character key*/
1297 {"#4", "S-left"}, /*shifted left-arrow key*/
1298 {"%d", "S-menu"}, /*shifted menu? actually shifted options key*/
1299 {"%c", "S-next"}, /*shifted next key*/
1300 {"%e", "S-prior"}, /*shifted previous key*/
1301 {"%f", "S-print"}, /*shifted print key*/
1302 {"%g", "S-redo"}, /*shifted redo key*/
1303 {"%i", "S-right"}, /*shifted right-arrow key*/
1304 {"!3", "S-undo"} /*shifted undo key*/
1308 static char **term_get_fkeys_address
;
1309 static KBOARD
*term_get_fkeys_kboard
;
1310 static Lisp_Object
term_get_fkeys_1 (void);
1312 /* Find the escape codes sent by the function keys for Vinput_decode_map.
1313 This function scans the termcap function key sequence entries, and
1314 adds entries to Vinput_decode_map for each function key it finds. */
1317 term_get_fkeys (char **address
, KBOARD
*kboard
)
1319 /* We run the body of the function (term_get_fkeys_1) and ignore all Lisp
1320 errors during the call. The only errors should be from Fdefine_key
1321 when given a key sequence containing an invalid prefix key. If the
1322 termcap defines function keys which use a prefix that is already bound
1323 to a command by the default bindings, we should silently ignore that
1324 function key specification, rather than giving the user an error and
1325 refusing to run at all on such a terminal. */
1327 term_get_fkeys_address
= address
;
1328 term_get_fkeys_kboard
= kboard
;
1329 internal_condition_case (term_get_fkeys_1
, Qerror
, Fidentity
);
1333 term_get_fkeys_1 (void)
1337 char **address
= term_get_fkeys_address
;
1338 KBOARD
*kboard
= term_get_fkeys_kboard
;
1340 /* This can happen if CANNOT_DUMP or with strange options. */
1341 if (!KEYMAPP (KVAR (kboard
, Vinput_decode_map
)))
1342 KVAR (kboard
, Vinput_decode_map
) = Fmake_sparse_keymap (Qnil
);
1344 for (i
= 0; i
< (sizeof (keys
)/sizeof (keys
[0])); i
++)
1346 char *sequence
= tgetstr (keys
[i
].cap
, address
);
1348 Fdefine_key (KVAR (kboard
, Vinput_decode_map
), build_string (sequence
),
1349 Fmake_vector (make_number (1),
1350 intern (keys
[i
].name
)));
1353 /* The uses of the "k0" capability are inconsistent; sometimes it
1354 describes F10, whereas othertimes it describes F0 and "k;" describes F10.
1355 We will attempt to politely accommodate both systems by testing for
1356 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10.
1359 const char *k_semi
= tgetstr ("k;", address
);
1360 const char *k0
= tgetstr ("k0", address
);
1361 const char *k0_name
= "f10";
1366 /* Define f0 first, so that f10 takes precedence in case the
1367 key sequences happens to be the same. */
1368 Fdefine_key (KVAR (kboard
, Vinput_decode_map
), build_string (k0
),
1369 Fmake_vector (make_number (1), intern ("f0")));
1370 Fdefine_key (KVAR (kboard
, Vinput_decode_map
), build_string (k_semi
),
1371 Fmake_vector (make_number (1), intern ("f10")));
1374 Fdefine_key (KVAR (kboard
, Vinput_decode_map
), build_string (k0
),
1375 Fmake_vector (make_number (1), intern (k0_name
)));
1378 /* Set up cookies for numbered function keys above f10. */
1380 char fcap
[3], fkey
[4];
1382 fcap
[0] = 'F'; fcap
[2] = '\0';
1383 for (i
= 11; i
< 64; i
++)
1386 fcap
[1] = '1' + i
- 11;
1388 fcap
[1] = 'A' + i
- 20;
1390 fcap
[1] = 'a' + i
- 46;
1393 char *sequence
= tgetstr (fcap
, address
);
1396 sprintf (fkey
, "f%d", i
);
1397 Fdefine_key (KVAR (kboard
, Vinput_decode_map
), build_string (sequence
),
1398 Fmake_vector (make_number (1),
1406 * Various mappings to try and get a better fit.
1409 #define CONDITIONAL_REASSIGN(cap1, cap2, sym) \
1410 if (!tgetstr (cap1, address)) \
1412 char *sequence = tgetstr (cap2, address); \
1414 Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (sequence), \
1415 Fmake_vector (make_number (1), \
1419 /* if there's no key_next keycap, map key_npage to `next' keysym */
1420 CONDITIONAL_REASSIGN ("%5", "kN", "next");
1421 /* if there's no key_prev keycap, map key_ppage to `previous' keysym */
1422 CONDITIONAL_REASSIGN ("%8", "kP", "prior");
1423 /* if there's no key_dc keycap, map key_ic to `insert' keysym */
1424 CONDITIONAL_REASSIGN ("kD", "kI", "insert");
1425 /* if there's no key_end keycap, map key_ll to 'end' keysym */
1426 CONDITIONAL_REASSIGN ("@7", "kH", "end");
1428 /* IBM has their own non-standard dialect of terminfo.
1429 If the standard name isn't found, try the IBM name. */
1430 CONDITIONAL_REASSIGN ("kB", "KO", "backtab");
1431 CONDITIONAL_REASSIGN ("@4", "kJ", "execute"); /* actually "action" */
1432 CONDITIONAL_REASSIGN ("@4", "kc", "execute"); /* actually "command" */
1433 CONDITIONAL_REASSIGN ("%7", "ki", "menu");
1434 CONDITIONAL_REASSIGN ("@7", "kw", "end");
1435 CONDITIONAL_REASSIGN ("F1", "k<", "f11");
1436 CONDITIONAL_REASSIGN ("F2", "k>", "f12");
1437 CONDITIONAL_REASSIGN ("%1", "kq", "help");
1438 CONDITIONAL_REASSIGN ("*6", "kU", "select");
1439 #undef CONDITIONAL_REASSIGN
1444 #endif /* not DOS_NT */
1447 /***********************************************************************
1448 Character Display Information
1449 ***********************************************************************/
1450 static void append_glyph (struct it
*);
1451 static void produce_stretch_glyph (struct it
*);
1452 static void append_composite_glyph (struct it
*);
1453 static void produce_composite_glyph (struct it
*);
1454 static void append_glyphless_glyph (struct it
*, int, const char *);
1455 static void produce_glyphless_glyph (struct it
*, int, Lisp_Object
);
1457 /* Append glyphs to IT's glyph_row. Called from produce_glyphs for
1458 terminal frames if IT->glyph_row != NULL. IT->char_to_display is
1459 the character for which to produce glyphs; IT->face_id contains the
1460 character's face. Padding glyphs are appended if IT->c has a
1461 IT->pixel_width > 1. */
1464 append_glyph (struct it
*it
)
1466 struct glyph
*glyph
, *end
;
1469 xassert (it
->glyph_row
);
1470 glyph
= (it
->glyph_row
->glyphs
[it
->area
]
1471 + it
->glyph_row
->used
[it
->area
]);
1472 end
= it
->glyph_row
->glyphs
[1 + it
->area
];
1474 /* If the glyph row is reversed, we need to prepend the glyph rather
1476 if (it
->glyph_row
->reversed_p
&& it
->area
== TEXT_AREA
)
1479 int move_by
= it
->pixel_width
;
1481 /* Make room for the new glyphs. */
1482 if (move_by
> end
- glyph
) /* don't overstep end of this area */
1483 move_by
= end
- glyph
;
1484 for (g
= glyph
- 1; g
>= it
->glyph_row
->glyphs
[it
->area
]; g
--)
1486 glyph
= it
->glyph_row
->glyphs
[it
->area
];
1487 end
= glyph
+ move_by
;
1490 /* BIDI Note: we put the glyphs of a "multi-pixel" character left to
1491 right, even in the REVERSED_P case, since (a) all of its u.ch are
1492 identical, and (b) the PADDING_P flag needs to be set for the
1493 leftmost one, because we write to the terminal left-to-right. */
1495 i
< it
->pixel_width
&& glyph
< end
;
1498 glyph
->type
= CHAR_GLYPH
;
1499 glyph
->pixel_width
= 1;
1500 glyph
->u
.ch
= it
->char_to_display
;
1501 glyph
->face_id
= it
->face_id
;
1502 glyph
->padding_p
= i
> 0;
1503 glyph
->charpos
= CHARPOS (it
->position
);
1504 glyph
->object
= it
->object
;
1507 glyph
->resolved_level
= it
->bidi_it
.resolved_level
;
1508 if ((it
->bidi_it
.type
& 7) != it
->bidi_it
.type
)
1510 glyph
->bidi_type
= it
->bidi_it
.type
;
1514 glyph
->resolved_level
= 0;
1515 glyph
->bidi_type
= UNKNOWN_BT
;
1518 ++it
->glyph_row
->used
[it
->area
];
1523 /* Produce glyphs for the display element described by IT. *IT
1524 specifies what we want to produce a glyph for (character, image, ...),
1525 and where in the glyph matrix we currently are (glyph row and hpos).
1526 produce_glyphs fills in output fields of *IT with information such as the
1527 pixel width and height of a character, and maybe output actual glyphs at
1528 the same time if IT->glyph_row is non-null. For an overview, see
1529 the explanation in dispextern.h, before the definition of the
1530 display_element_type enumeration.
1532 produce_glyphs also stores the result of glyph width, ascent
1533 etc. computations in *IT.
1535 IT->glyph_row may be null, in which case produce_glyphs does not
1536 actually fill in the glyphs. This is used in the move_* functions
1537 in xdisp.c for text width and height computations.
1539 Callers usually don't call produce_glyphs directly;
1540 instead they use the macro PRODUCE_GLYPHS. */
1543 produce_glyphs (struct it
*it
)
1545 /* If a hook is installed, let it do the work. */
1547 /* Nothing but characters are supported on terminal frames. */
1548 xassert (it
->what
== IT_CHARACTER
1549 || it
->what
== IT_COMPOSITION
1550 || it
->what
== IT_STRETCH
);
1552 if (it
->what
== IT_STRETCH
)
1554 produce_stretch_glyph (it
);
1558 if (it
->what
== IT_COMPOSITION
)
1560 produce_composite_glyph (it
);
1564 if (it
->what
== IT_GLYPHLESS
)
1566 produce_glyphless_glyph (it
, 0, Qnil
);
1570 if (it
->char_to_display
>= 040 && it
->char_to_display
< 0177)
1572 it
->pixel_width
= it
->nglyphs
= 1;
1576 else if (it
->char_to_display
== '\n')
1577 it
->pixel_width
= it
->nglyphs
= 0;
1578 else if (it
->char_to_display
== '\t')
1580 int absolute_x
= (it
->current_x
1581 + it
->continuation_lines_width
);
1583 = (((1 + absolute_x
+ it
->tab_width
- 1)
1588 /* If part of the TAB has been displayed on the previous line
1589 which is continued now, continuation_lines_width will have
1590 been incremented already by the part that fitted on the
1591 continued line. So, we will get the right number of spaces
1593 nspaces
= next_tab_x
- absolute_x
;
1599 it
->char_to_display
= ' ';
1600 it
->pixel_width
= it
->len
= 1;
1606 it
->pixel_width
= nspaces
;
1607 it
->nglyphs
= nspaces
;
1609 else if (CHAR_BYTE8_P (it
->char_to_display
))
1611 /* Coming here means that we must send the raw 8-bit byte as is
1612 to the terminal. Although there's no way to know how many
1613 columns it occupies on a screen, it is a good assumption that
1614 a single byte code has 1-column width. */
1615 it
->pixel_width
= it
->nglyphs
= 1;
1621 Lisp_Object charset_list
= FRAME_TERMINAL (it
->f
)->charset_list
;
1623 if (char_charset (it
->char_to_display
, charset_list
, NULL
))
1625 it
->pixel_width
= CHAR_WIDTH (it
->char_to_display
);
1626 it
->nglyphs
= it
->pixel_width
;
1632 Lisp_Object acronym
= lookup_glyphless_char_display (-1, it
);
1634 xassert (it
->what
== IT_GLYPHLESS
);
1635 produce_glyphless_glyph (it
, 1, acronym
);
1640 /* Advance current_x by the pixel width as a convenience for
1642 if (it
->area
== TEXT_AREA
)
1643 it
->current_x
+= it
->pixel_width
;
1644 it
->ascent
= it
->max_ascent
= it
->phys_ascent
= it
->max_phys_ascent
= 0;
1645 it
->descent
= it
->max_descent
= it
->phys_descent
= it
->max_phys_descent
= 1;
1649 /* Produce a stretch glyph for iterator IT. IT->object is the value
1650 of the glyph property displayed. The value must be a list
1651 `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
1654 1. `:width WIDTH' specifies that the space should be WIDTH *
1655 canonical char width wide. WIDTH may be an integer or floating
1658 2. `:align-to HPOS' specifies that the space should be wide enough
1659 to reach HPOS, a value in canonical character units. */
1662 produce_stretch_glyph (struct it
*it
)
1664 /* (space :width WIDTH ...) */
1665 Lisp_Object prop
, plist
;
1666 int width
= 0, align_to
= -1;
1667 int zero_width_ok_p
= 0;
1670 /* List should start with `space'. */
1671 xassert (CONSP (it
->object
) && EQ (XCAR (it
->object
), Qspace
));
1672 plist
= XCDR (it
->object
);
1674 /* Compute the width of the stretch. */
1675 if ((prop
= Fplist_get (plist
, QCwidth
), !NILP (prop
))
1676 && calc_pixel_width_or_height (&tem
, it
, prop
, 0, 1, 0))
1678 /* Absolute width `:width WIDTH' specified and valid. */
1679 zero_width_ok_p
= 1;
1680 width
= (int)(tem
+ 0.5);
1682 else if ((prop
= Fplist_get (plist
, QCalign_to
), !NILP (prop
))
1683 && calc_pixel_width_or_height (&tem
, it
, prop
, 0, 1, &align_to
))
1685 if (it
->glyph_row
== NULL
|| !it
->glyph_row
->mode_line_p
)
1686 align_to
= (align_to
< 0
1688 : align_to
- window_box_left_offset (it
->w
, TEXT_AREA
));
1689 else if (align_to
< 0)
1690 align_to
= window_box_left_offset (it
->w
, TEXT_AREA
);
1691 width
= max (0, (int)(tem
+ 0.5) + align_to
- it
->current_x
);
1692 zero_width_ok_p
= 1;
1695 /* Nothing specified -> width defaults to canonical char width. */
1696 width
= FRAME_COLUMN_WIDTH (it
->f
);
1698 if (width
<= 0 && (width
< 0 || !zero_width_ok_p
))
1701 if (width
> 0 && it
->line_wrap
!= TRUNCATE
1702 && it
->current_x
+ width
> it
->last_visible_x
)
1703 width
= it
->last_visible_x
- it
->current_x
- 1;
1705 if (width
> 0 && it
->glyph_row
)
1707 Lisp_Object o_object
= it
->object
;
1708 Lisp_Object object
= it
->stack
[it
->sp
- 1].string
;
1711 if (!STRINGP (object
))
1712 object
= it
->w
->buffer
;
1713 it
->object
= object
;
1714 it
->char_to_display
= ' ';
1715 it
->pixel_width
= it
->len
= 1;
1718 it
->object
= o_object
;
1720 it
->pixel_width
= width
;
1721 it
->nglyphs
= width
;
1725 /* Append glyphs to IT's glyph_row for the composition IT->cmp_id.
1726 Called from produce_composite_glyph for terminal frames if
1727 IT->glyph_row != NULL. IT->face_id contains the character's
1731 append_composite_glyph (struct it
*it
)
1733 struct glyph
*glyph
;
1735 xassert (it
->glyph_row
);
1736 glyph
= it
->glyph_row
->glyphs
[it
->area
] + it
->glyph_row
->used
[it
->area
];
1737 if (glyph
< it
->glyph_row
->glyphs
[1 + it
->area
])
1739 /* If the glyph row is reversed, we need to prepend the glyph
1740 rather than append it. */
1741 if (it
->glyph_row
->reversed_p
&& it
->area
== TEXT_AREA
)
1745 /* Make room for the new glyph. */
1746 for (g
= glyph
- 1; g
>= it
->glyph_row
->glyphs
[it
->area
]; g
--)
1748 glyph
= it
->glyph_row
->glyphs
[it
->area
];
1750 glyph
->type
= COMPOSITE_GLYPH
;
1751 glyph
->pixel_width
= it
->pixel_width
;
1752 glyph
->u
.cmp
.id
= it
->cmp_it
.id
;
1753 if (it
->cmp_it
.ch
< 0)
1755 glyph
->u
.cmp
.automatic
= 0;
1756 glyph
->u
.cmp
.id
= it
->cmp_it
.id
;
1760 glyph
->u
.cmp
.automatic
= 1;
1761 glyph
->u
.cmp
.id
= it
->cmp_it
.id
;
1762 glyph
->slice
.cmp
.from
= it
->cmp_it
.from
;
1763 glyph
->slice
.cmp
.to
= it
->cmp_it
.to
- 1;
1766 glyph
->face_id
= it
->face_id
;
1767 glyph
->padding_p
= 0;
1768 glyph
->charpos
= CHARPOS (it
->position
);
1769 glyph
->object
= it
->object
;
1772 glyph
->resolved_level
= it
->bidi_it
.resolved_level
;
1773 if ((it
->bidi_it
.type
& 7) != it
->bidi_it
.type
)
1775 glyph
->bidi_type
= it
->bidi_it
.type
;
1779 glyph
->resolved_level
= 0;
1780 glyph
->bidi_type
= UNKNOWN_BT
;
1783 ++it
->glyph_row
->used
[it
->area
];
1789 /* Produce a composite glyph for iterator IT. IT->cmp_id is the ID of
1790 the composition. We simply produces components of the composition
1791 assuming that the terminal has a capability to layout/render it
1795 produce_composite_glyph (struct it
*it
)
1797 if (it
->cmp_it
.ch
< 0)
1799 struct composition
*cmp
= composition_table
[it
->cmp_it
.id
];
1801 it
->pixel_width
= cmp
->width
;
1805 Lisp_Object gstring
= composition_gstring_from_id (it
->cmp_it
.id
);
1807 it
->pixel_width
= composition_gstring_width (gstring
, it
->cmp_it
.from
,
1808 it
->cmp_it
.to
, NULL
);
1812 append_composite_glyph (it
);
1816 /* Append a glyph for a glyphless character to IT->glyph_row. FACE_ID
1817 is a face ID to be used for the glyph. What is actually appended
1818 are glyphs of type CHAR_GLYPH whose characters are in STR (which
1819 comes from it->nglyphs bytes). */
1822 append_glyphless_glyph (struct it
*it
, int face_id
, const char *str
)
1824 struct glyph
*glyph
, *end
;
1827 xassert (it
->glyph_row
);
1828 glyph
= it
->glyph_row
->glyphs
[it
->area
] + it
->glyph_row
->used
[it
->area
];
1829 end
= it
->glyph_row
->glyphs
[1 + it
->area
];
1831 /* If the glyph row is reversed, we need to prepend the glyph rather
1833 if (it
->glyph_row
->reversed_p
&& it
->area
== TEXT_AREA
)
1836 int move_by
= it
->pixel_width
;
1838 /* Make room for the new glyphs. */
1839 if (move_by
> end
- glyph
) /* don't overstep end of this area */
1840 move_by
= end
- glyph
;
1841 for (g
= glyph
- 1; g
>= it
->glyph_row
->glyphs
[it
->area
]; g
--)
1843 glyph
= it
->glyph_row
->glyphs
[it
->area
];
1844 end
= glyph
+ move_by
;
1849 glyph
->type
= CHAR_GLYPH
;
1850 glyph
->pixel_width
= 1;
1851 glyph
->face_id
= face_id
;
1852 glyph
->padding_p
= 0;
1853 glyph
->charpos
= CHARPOS (it
->position
);
1854 glyph
->object
= it
->object
;
1857 glyph
->resolved_level
= it
->bidi_it
.resolved_level
;
1858 if ((it
->bidi_it
.type
& 7) != it
->bidi_it
.type
)
1860 glyph
->bidi_type
= it
->bidi_it
.type
;
1864 glyph
->resolved_level
= 0;
1865 glyph
->bidi_type
= UNKNOWN_BT
;
1868 /* BIDI Note: we put the glyphs of characters left to right, even in
1869 the REVERSED_P case because we write to the terminal
1871 for (i
= 0; i
< it
->nglyphs
&& glyph
< end
; ++i
)
1874 glyph
[0] = glyph
[-1];
1875 glyph
->u
.ch
= str
[i
];
1876 ++it
->glyph_row
->used
[it
->area
];
1881 /* Produce glyphs for a glyphless character for iterator IT.
1882 IT->glyphless_method specifies which method to use for displaying
1883 the character. See the description of enum
1884 glyphless_display_method in dispextern.h for the details.
1886 FOR_NO_FONT is nonzero if and only if this is for a character that
1887 is not supproted by the coding system of the terminal. ACRONYM, if
1888 non-nil, is an acronym string for the character.
1890 The glyphs actually produced are of type CHAR_GLYPH. */
1893 produce_glyphless_glyph (struct it
*it
, int for_no_font
, Lisp_Object acronym
)
1898 char const *str
= " ";
1900 /* Get a face ID for the glyph by utilizing a cache (the same way as
1901 done for `escape-glyph' in get_next_display_element). */
1902 if (it
->f
== last_glyphless_glyph_frame
1903 && it
->face_id
== last_glyphless_glyph_face_id
)
1905 face_id
= last_glyphless_glyph_merged_face_id
;
1909 /* Merge the `glyphless-char' face into the current face. */
1910 face_id
= merge_faces (it
->f
, Qglyphless_char
, 0, it
->face_id
);
1911 last_glyphless_glyph_frame
= it
->f
;
1912 last_glyphless_glyph_face_id
= it
->face_id
;
1913 last_glyphless_glyph_merged_face_id
= face_id
;
1916 if (it
->glyphless_method
== GLYPHLESS_DISPLAY_THIN_SPACE
)
1918 /* As there's no way to produce a thin space, we produce a space
1919 of canonical width. */
1922 else if (it
->glyphless_method
== GLYPHLESS_DISPLAY_EMPTY_BOX
)
1924 len
= CHAR_WIDTH (it
->c
);
1929 sprintf (buf
, "[%.*s]", len
, str
);
1935 if (it
->glyphless_method
== GLYPHLESS_DISPLAY_ACRONYM
)
1937 if (! STRINGP (acronym
) && CHAR_TABLE_P (Vglyphless_char_display
))
1938 acronym
= CHAR_TABLE_REF (Vglyphless_char_display
, it
->c
);
1939 if (CONSP (acronym
))
1940 acronym
= XCDR (acronym
);
1942 str
= STRINGP (acronym
) ? SSDATA (acronym
) : "";
1943 for (len
= 0; len
< 6 && str
[len
] && ASCII_BYTE_P (str
[len
]); len
++)
1944 buf
[1 + len
] = str
[len
];
1950 xassert (it
->glyphless_method
== GLYPHLESS_DISPLAY_HEX_CODE
);
1951 len
= (it
->c
< 0x10000 ? sprintf (buf
, "\\u%04X", it
->c
)
1952 : it
->c
<= MAX_UNICODE_CHAR
? sprintf (buf
, "\\U%06X", it
->c
)
1953 : sprintf (buf
, "\\x%06X", it
->c
));
1958 it
->pixel_width
= len
;
1961 append_glyphless_glyph (it
, face_id
, str
);
1965 /* Get information about special display element WHAT in an
1966 environment described by IT. WHAT is one of IT_TRUNCATION or
1967 IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a
1968 non-null glyph_row member. This function ensures that fields like
1969 face_id, c, len of IT are left untouched. */
1972 produce_special_glyphs (struct it
*it
, enum display_element_type what
)
1980 temp_it
.what
= IT_CHARACTER
;
1982 temp_it
.object
= make_number (0);
1983 memset (&temp_it
.current
, 0, sizeof temp_it
.current
);
1985 if (what
== IT_CONTINUATION
)
1987 /* Continuation glyph. For R2L lines, we mirror it by hand. */
1988 if (it
->bidi_it
.paragraph_dir
== R2L
)
1989 SET_GLYPH_FROM_CHAR (glyph
, '/');
1991 SET_GLYPH_FROM_CHAR (glyph
, '\\');
1993 && (gc
= DISP_CONTINUE_GLYPH (it
->dp
), GLYPH_CODE_P (gc
))
1994 && GLYPH_CODE_CHAR_VALID_P (gc
))
1996 /* FIXME: Should we mirror GC for R2L lines? */
1997 SET_GLYPH_FROM_GLYPH_CODE (glyph
, gc
);
1998 spec_glyph_lookup_face (XWINDOW (it
->window
), &glyph
);
2001 else if (what
== IT_TRUNCATION
)
2003 /* Truncation glyph. */
2004 SET_GLYPH_FROM_CHAR (glyph
, '$');
2006 && (gc
= DISP_TRUNC_GLYPH (it
->dp
), GLYPH_CODE_P (gc
))
2007 && GLYPH_CODE_CHAR_VALID_P (gc
))
2009 /* FIXME: Should we mirror GC for R2L lines? */
2010 SET_GLYPH_FROM_GLYPH_CODE (glyph
, gc
);
2011 spec_glyph_lookup_face (XWINDOW (it
->window
), &glyph
);
2017 temp_it
.c
= temp_it
.char_to_display
= GLYPH_CHAR (glyph
);
2018 temp_it
.face_id
= GLYPH_FACE (glyph
);
2019 temp_it
.len
= CHAR_BYTES (temp_it
.c
);
2021 produce_glyphs (&temp_it
);
2022 it
->pixel_width
= temp_it
.pixel_width
;
2023 it
->nglyphs
= temp_it
.pixel_width
;
2028 /***********************************************************************
2030 ***********************************************************************/
2032 /* Value is non-zero if attribute ATTR may be used. ATTR should be
2033 one of the enumerators from enum no_color_bit, or a bit set built
2034 from them. Some display attributes may not be used together with
2035 color; the termcap capability `NC' specifies which ones. */
2037 #define MAY_USE_WITH_COLORS_P(tty, ATTR) \
2038 (tty->TN_max_colors > 0 \
2039 ? (tty->TN_no_color_video & (ATTR)) == 0 \
2042 /* Turn appearances of face FACE_ID on tty frame F on.
2043 FACE_ID is a realized face ID number, in the face cache. */
2046 turn_on_face (struct frame
*f
, int face_id
)
2048 struct face
*face
= FACE_FROM_ID (f
, face_id
);
2049 long fg
= face
->foreground
;
2050 long bg
= face
->background
;
2051 struct tty_display_info
*tty
= FRAME_TTY (f
);
2053 /* Do this first because TS_end_standout_mode may be the same
2054 as TS_exit_attribute_mode, which turns all appearances off. */
2055 if (MAY_USE_WITH_COLORS_P (tty
, NC_REVERSE
))
2057 if (tty
->TN_max_colors
> 0)
2059 if (fg
>= 0 && bg
>= 0)
2061 /* If the terminal supports colors, we can set them
2062 below without using reverse video. The face's fg
2063 and bg colors are set as they should appear on
2064 the screen, i.e. they take the inverse-video'ness
2065 of the face already into account. */
2067 else if (inverse_video
)
2069 if (fg
== FACE_TTY_DEFAULT_FG_COLOR
2070 || bg
== FACE_TTY_DEFAULT_BG_COLOR
)
2071 tty_toggle_highlight (tty
);
2075 if (fg
== FACE_TTY_DEFAULT_BG_COLOR
2076 || bg
== FACE_TTY_DEFAULT_FG_COLOR
)
2077 tty_toggle_highlight (tty
);
2082 /* If we can't display colors, use reverse video
2083 if the face specifies that. */
2086 if (fg
== FACE_TTY_DEFAULT_FG_COLOR
2087 || bg
== FACE_TTY_DEFAULT_BG_COLOR
)
2088 tty_toggle_highlight (tty
);
2092 if (fg
== FACE_TTY_DEFAULT_BG_COLOR
2093 || bg
== FACE_TTY_DEFAULT_FG_COLOR
)
2094 tty_toggle_highlight (tty
);
2099 if (face
->tty_bold_p
&& MAY_USE_WITH_COLORS_P (tty
, NC_BOLD
))
2100 OUTPUT1_IF (tty
, tty
->TS_enter_bold_mode
);
2102 if (face
->tty_dim_p
&& MAY_USE_WITH_COLORS_P (tty
, NC_DIM
))
2103 OUTPUT1_IF (tty
, tty
->TS_enter_dim_mode
);
2105 /* Alternate charset and blinking not yet used. */
2106 if (face
->tty_alt_charset_p
2107 && MAY_USE_WITH_COLORS_P (tty
, NC_ALT_CHARSET
))
2108 OUTPUT1_IF (tty
, tty
->TS_enter_alt_charset_mode
);
2110 if (face
->tty_blinking_p
2111 && MAY_USE_WITH_COLORS_P (tty
, NC_BLINK
))
2112 OUTPUT1_IF (tty
, tty
->TS_enter_blink_mode
);
2114 if (face
->tty_underline_p
&& MAY_USE_WITH_COLORS_P (tty
, NC_UNDERLINE
))
2115 OUTPUT1_IF (tty
, tty
->TS_enter_underline_mode
);
2117 if (tty
->TN_max_colors
> 0)
2122 ts
= tty
->standout_mode
? tty
->TS_set_background
: tty
->TS_set_foreground
;
2125 p
= tparam (ts
, NULL
, 0, (int) fg
, 0, 0, 0);
2130 ts
= tty
->standout_mode
? tty
->TS_set_foreground
: tty
->TS_set_background
;
2133 p
= tparam (ts
, NULL
, 0, (int) bg
, 0, 0, 0);
2141 /* Turn off appearances of face FACE_ID on tty frame F. */
2144 turn_off_face (struct frame
*f
, int face_id
)
2146 struct face
*face
= FACE_FROM_ID (f
, face_id
);
2147 struct tty_display_info
*tty
= FRAME_TTY (f
);
2149 xassert (face
!= NULL
);
2151 if (tty
->TS_exit_attribute_mode
)
2153 /* Capability "me" will turn off appearance modes double-bright,
2154 half-bright, reverse-video, standout, underline. It may or
2155 may not turn off alt-char-mode. */
2156 if (face
->tty_bold_p
2158 || face
->tty_reverse_p
2159 || face
->tty_alt_charset_p
2160 || face
->tty_blinking_p
2161 || face
->tty_underline_p
)
2163 OUTPUT1_IF (tty
, tty
->TS_exit_attribute_mode
);
2164 if (strcmp (tty
->TS_exit_attribute_mode
, tty
->TS_end_standout_mode
) == 0)
2165 tty
->standout_mode
= 0;
2168 if (face
->tty_alt_charset_p
)
2169 OUTPUT_IF (tty
, tty
->TS_exit_alt_charset_mode
);
2173 /* If we don't have "me" we can only have those appearances
2174 that have exit sequences defined. */
2175 if (face
->tty_alt_charset_p
)
2176 OUTPUT_IF (tty
, tty
->TS_exit_alt_charset_mode
);
2178 if (face
->tty_underline_p
)
2179 OUTPUT_IF (tty
, tty
->TS_exit_underline_mode
);
2182 /* Switch back to default colors. */
2183 if (tty
->TN_max_colors
> 0
2184 && ((face
->foreground
!= FACE_TTY_DEFAULT_COLOR
2185 && face
->foreground
!= FACE_TTY_DEFAULT_FG_COLOR
)
2186 || (face
->background
!= FACE_TTY_DEFAULT_COLOR
2187 && face
->background
!= FACE_TTY_DEFAULT_BG_COLOR
)))
2188 OUTPUT1_IF (tty
, tty
->TS_orig_pair
);
2192 /* Return non-zero if the terminal on frame F supports all of the
2193 capabilities in CAPS simultaneously, with foreground and background
2194 colors FG and BG. */
2197 tty_capable_p (struct tty_display_info
*tty
, unsigned int caps
,
2198 unsigned long fg
, unsigned long bg
)
2200 #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \
2201 if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \
2204 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_INVERSE
, tty
->TS_standout_mode
, NC_REVERSE
);
2205 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_UNDERLINE
, tty
->TS_enter_underline_mode
, NC_UNDERLINE
);
2206 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_BOLD
, tty
->TS_enter_bold_mode
, NC_BOLD
);
2207 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_DIM
, tty
->TS_enter_dim_mode
, NC_DIM
);
2208 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_BLINK
, tty
->TS_enter_blink_mode
, NC_BLINK
);
2209 TTY_CAPABLE_P_TRY (tty
, TTY_CAP_ALT_CHARSET
, tty
->TS_enter_alt_charset_mode
, NC_ALT_CHARSET
);
2215 /* Return non-zero if the terminal is capable to display colors. */
2217 DEFUN ("tty-display-color-p", Ftty_display_color_p
, Stty_display_color_p
,
2219 doc
: /* Return non-nil if the tty device TERMINAL can display colors.
2221 TERMINAL can be a terminal object, a frame, or nil (meaning the
2222 selected frame's terminal). This function always returns nil if
2223 TERMINAL does not refer to a text-only terminal. */)
2224 (Lisp_Object terminal
)
2226 struct terminal
*t
= get_tty_terminal (terminal
, 0);
2230 return t
->display_info
.tty
->TN_max_colors
> 0 ? Qt
: Qnil
;
2233 /* Return the number of supported colors. */
2234 DEFUN ("tty-display-color-cells", Ftty_display_color_cells
,
2235 Stty_display_color_cells
, 0, 1, 0,
2236 doc
: /* Return the number of colors supported by the tty device TERMINAL.
2238 TERMINAL can be a terminal object, a frame, or nil (meaning the
2239 selected frame's terminal). This function always returns 0 if
2240 TERMINAL does not refer to a text-only terminal. */)
2241 (Lisp_Object terminal
)
2243 struct terminal
*t
= get_tty_terminal (terminal
, 0);
2245 return make_number (0);
2247 return make_number (t
->display_info
.tty
->TN_max_colors
);
2252 /* Declare here rather than in the function, as in the rest of Emacs,
2253 to work around an HPUX compiler bug (?). See
2254 http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg00410.html */
2255 static int default_max_colors
;
2256 static int default_max_pairs
;
2257 static int default_no_color_video
;
2258 static char *default_orig_pair
;
2259 static char *default_set_foreground
;
2260 static char *default_set_background
;
2262 /* Save or restore the default color-related capabilities of this
2265 tty_default_color_capabilities (struct tty_display_info
*tty
, int save
)
2270 xfree (default_orig_pair
);
2271 default_orig_pair
= tty
->TS_orig_pair
? xstrdup (tty
->TS_orig_pair
) : NULL
;
2273 xfree (default_set_foreground
);
2274 default_set_foreground
= tty
->TS_set_foreground
? xstrdup (tty
->TS_set_foreground
)
2277 xfree (default_set_background
);
2278 default_set_background
= tty
->TS_set_background
? xstrdup (tty
->TS_set_background
)
2281 default_max_colors
= tty
->TN_max_colors
;
2282 default_max_pairs
= tty
->TN_max_pairs
;
2283 default_no_color_video
= tty
->TN_no_color_video
;
2287 tty
->TS_orig_pair
= default_orig_pair
;
2288 tty
->TS_set_foreground
= default_set_foreground
;
2289 tty
->TS_set_background
= default_set_background
;
2290 tty
->TN_max_colors
= default_max_colors
;
2291 tty
->TN_max_pairs
= default_max_pairs
;
2292 tty
->TN_no_color_video
= default_no_color_video
;
2296 /* Setup one of the standard tty color schemes according to MODE.
2297 MODE's value is generally the number of colors which we want to
2298 support; zero means set up for the default capabilities, the ones
2299 we saw at init_tty time; -1 means turn off color support. */
2301 tty_setup_colors (struct tty_display_info
*tty
, int mode
)
2303 /* Canonicalize all negative values of MODE. */
2309 case -1: /* no colors at all */
2310 tty
->TN_max_colors
= 0;
2311 tty
->TN_max_pairs
= 0;
2312 tty
->TN_no_color_video
= 0;
2313 tty
->TS_set_foreground
= tty
->TS_set_background
= tty
->TS_orig_pair
= NULL
;
2315 case 0: /* default colors, if any */
2317 tty_default_color_capabilities (tty
, 0);
2319 case 8: /* 8 standard ANSI colors */
2320 tty
->TS_orig_pair
= "\033[0m";
2322 tty
->TS_set_foreground
= "\033[3%p1%dm";
2323 tty
->TS_set_background
= "\033[4%p1%dm";
2325 tty
->TS_set_foreground
= "\033[3%dm";
2326 tty
->TS_set_background
= "\033[4%dm";
2328 tty
->TN_max_colors
= 8;
2329 tty
->TN_max_pairs
= 64;
2330 tty
->TN_no_color_video
= 0;
2336 set_tty_color_mode (struct tty_display_info
*tty
, struct frame
*f
)
2338 Lisp_Object tem
, val
;
2339 Lisp_Object color_mode
;
2341 Lisp_Object tty_color_mode_alist
2342 = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil
);
2344 tem
= assq_no_quit (Qtty_color_mode
, f
->param_alist
);
2345 val
= CONSP (tem
) ? XCDR (tem
) : Qnil
;
2349 else if (SYMBOLP (tty_color_mode_alist
))
2351 tem
= Fassq (val
, Fsymbol_value (tty_color_mode_alist
));
2352 color_mode
= CONSP (tem
) ? XCDR (tem
) : Qnil
;
2357 mode
= INTEGERP (color_mode
) ? XINT (color_mode
) : 0;
2359 if (mode
!= tty
->previous_color_mode
)
2361 Lisp_Object funsym
= intern ("tty-set-up-initial-frame-faces");
2362 tty
->previous_color_mode
= mode
;
2363 tty_setup_colors (tty
, mode
);
2364 /* This recomputes all the faces given the new color definitions. */
2365 safe_call (1, &funsym
);
2369 #endif /* !DOS_NT */
2373 /* Return the tty display object specified by TERMINAL. */
2375 static struct terminal
*
2376 get_tty_terminal (Lisp_Object terminal
, int throw)
2378 struct terminal
*t
= get_terminal (terminal
, throw);
2380 if (t
&& t
->type
!= output_termcap
&& t
->type
!= output_msdos_raw
)
2383 error ("Device %d is not a termcap terminal device", t
->id
);
2391 /* Return an active termcap device that uses the tty device with the
2394 This function ignores suspended devices.
2396 Returns NULL if the named terminal device is not opened. */
2399 get_named_tty (const char *name
)
2406 for (t
= terminal_list
; t
; t
= t
->next_terminal
)
2408 if ((t
->type
== output_termcap
|| t
->type
== output_msdos_raw
)
2409 && !strcmp (t
->display_info
.tty
->name
, name
)
2410 && TERMINAL_ACTIVE_P (t
))
2418 DEFUN ("tty-type", Ftty_type
, Stty_type
, 0, 1, 0,
2419 doc
: /* Return the type of the tty device that TERMINAL uses.
2420 Returns nil if TERMINAL is not on a tty device.
2422 TERMINAL can be a terminal object, a frame, or nil (meaning the
2423 selected frame's terminal). */)
2424 (Lisp_Object terminal
)
2426 struct terminal
*t
= get_terminal (terminal
, 1);
2428 if (t
->type
!= output_termcap
&& t
->type
!= output_msdos_raw
)
2431 if (t
->display_info
.tty
->type
)
2432 return build_string (t
->display_info
.tty
->type
);
2437 DEFUN ("controlling-tty-p", Fcontrolling_tty_p
, Scontrolling_tty_p
, 0, 1, 0,
2438 doc
: /* Return non-nil if TERMINAL is the controlling tty of the Emacs process.
2440 TERMINAL can be a terminal object, a frame, or nil (meaning the
2441 selected frame's terminal). This function always returns nil if
2442 TERMINAL is not on a tty device. */)
2443 (Lisp_Object terminal
)
2445 struct terminal
*t
= get_terminal (terminal
, 1);
2447 if ((t
->type
!= output_termcap
&& t
->type
!= output_msdos_raw
)
2448 || strcmp (t
->display_info
.tty
->name
, DEV_TTY
) != 0)
2454 DEFUN ("tty-no-underline", Ftty_no_underline
, Stty_no_underline
, 0, 1, 0,
2455 doc
: /* Declare that the tty used by TERMINAL does not handle underlining.
2456 This is used to override the terminfo data, for certain terminals that
2457 do not really do underlining, but say that they do. This function has
2458 no effect if used on a non-tty terminal.
2460 TERMINAL can be a terminal object, a frame or nil (meaning the
2461 selected frame's terminal). This function always returns nil if
2462 TERMINAL does not refer to a text-only terminal. */)
2463 (Lisp_Object terminal
)
2465 struct terminal
*t
= get_terminal (terminal
, 1);
2467 if (t
->type
== output_termcap
)
2468 t
->display_info
.tty
->TS_enter_underline_mode
= 0;
2474 DEFUN ("suspend-tty", Fsuspend_tty
, Ssuspend_tty
, 0, 1, 0,
2475 doc
: /* Suspend the terminal device TTY.
2477 The device is restored to its default state, and Emacs ceases all
2478 access to the tty device. Frames that use the device are not deleted,
2479 but input is not read from them and if they change, their display is
2482 TTY may be a terminal object, a frame, or nil for the terminal device
2483 of the currently selected frame.
2485 This function runs `suspend-tty-functions' after suspending the
2486 device. The functions are run with one arg, the id of the suspended
2489 `suspend-tty' does nothing if it is called on a device that is already
2492 A suspended tty may be resumed by calling `resume-tty' on it. */)
2495 struct terminal
*t
= get_tty_terminal (tty
, 1);
2499 error ("Unknown tty device");
2501 f
= t
->display_info
.tty
->input
;
2505 /* First run `suspend-tty-functions' and then clean up the tty
2506 state because `suspend-tty-functions' might need to change
2508 Lisp_Object args
[2];
2509 args
[0] = intern ("suspend-tty-functions");
2510 XSETTERMINAL (args
[1], t
);
2511 Frun_hook_with_args (2, args
);
2513 reset_sys_modes (t
->display_info
.tty
);
2514 delete_keyboard_wait_descriptor (fileno (f
));
2518 if (f
!= t
->display_info
.tty
->output
)
2519 fclose (t
->display_info
.tty
->output
);
2522 t
->display_info
.tty
->input
= 0;
2523 t
->display_info
.tty
->output
= 0;
2525 if (FRAMEP (t
->display_info
.tty
->top_frame
))
2526 FRAME_SET_VISIBLE (XFRAME (t
->display_info
.tty
->top_frame
), 0);
2530 /* Clear display hooks to prevent further output. */
2531 clear_tty_hooks (t
);
2536 DEFUN ("resume-tty", Fresume_tty
, Sresume_tty
, 0, 1, 0,
2537 doc
: /* Resume the previously suspended terminal device TTY.
2538 The terminal is opened and reinitialized. Frames that are on the
2539 suspended terminal are revived.
2541 It is an error to resume a terminal while another terminal is active
2544 This function runs `resume-tty-functions' after resuming the terminal.
2545 The functions are run with one arg, the id of the resumed terminal
2548 `resume-tty' does nothing if it is called on a device that is not
2551 TTY may be a terminal object, a frame, or nil (meaning the selected
2552 frame's terminal). */)
2555 struct terminal
*t
= get_tty_terminal (tty
, 1);
2559 error ("Unknown tty device");
2561 if (!t
->display_info
.tty
->input
)
2563 if (get_named_tty (t
->display_info
.tty
->name
))
2564 error ("Cannot resume display while another display is active on the same device");
2567 t
->display_info
.tty
->output
= stdout
;
2568 t
->display_info
.tty
->input
= stdin
;
2570 fd
= emacs_open (t
->display_info
.tty
->name
, O_RDWR
| O_NOCTTY
, 0);
2573 error ("Can not reopen tty device %s: %s", t
->display_info
.tty
->name
, strerror (errno
));
2575 if (strcmp (t
->display_info
.tty
->name
, DEV_TTY
))
2576 dissociate_if_controlling_tty (fd
);
2578 t
->display_info
.tty
->output
= fdopen (fd
, "w+");
2579 t
->display_info
.tty
->input
= t
->display_info
.tty
->output
;
2582 add_keyboard_wait_descriptor (fd
);
2584 if (FRAMEP (t
->display_info
.tty
->top_frame
))
2586 struct frame
*f
= XFRAME (t
->display_info
.tty
->top_frame
);
2588 int old_height
= FRAME_COLS (f
);
2589 int old_width
= FRAME_LINES (f
);
2591 /* Check if terminal/window size has changed while the frame
2593 get_tty_size (fileno (t
->display_info
.tty
->input
), &width
, &height
);
2594 if (width
!= old_width
|| height
!= old_height
)
2595 change_frame_size (f
, height
, width
, 0, 0, 0);
2596 FRAME_SET_VISIBLE (XFRAME (t
->display_info
.tty
->top_frame
), 1);
2599 init_sys_modes (t
->display_info
.tty
);
2602 /* Run `resume-tty-functions'. */
2603 Lisp_Object args
[2];
2604 args
[0] = intern ("resume-tty-functions");
2605 XSETTERMINAL (args
[1], t
);
2606 Frun_hook_with_args (2, args
);
2616 /***********************************************************************
2618 ***********************************************************************/
2622 #ifndef HAVE_WINDOW_SYSTEM
2624 term_mouse_moveto (int x
, int y
)
2626 /* TODO: how to set mouse position?
2629 name = (const char *) ttyname (0);
2630 fd = open (name, O_WRONLY);
2631 SOME_FUNCTION (x, y, fd);
2634 last_mouse_y = y; */
2636 #endif /* HAVE_WINDOW_SYSTEM */
2638 /* Implementation of draw_row_with_mouse_face for TTY/GPM. */
2640 tty_draw_row_with_mouse_face (struct window
*w
, struct glyph_row
*row
,
2641 int start_hpos
, int end_hpos
,
2642 enum draw_glyphs_face draw
)
2644 int nglyphs
= end_hpos
- start_hpos
;
2645 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
2646 struct tty_display_info
*tty
= FRAME_TTY (f
);
2647 int face_id
= tty
->mouse_highlight
.mouse_face_face_id
;
2648 int save_x
, save_y
, pos_x
, pos_y
;
2650 if (end_hpos
>= row
->used
[TEXT_AREA
])
2651 nglyphs
= row
->used
[TEXT_AREA
] - start_hpos
;
2653 pos_y
= row
->y
+ WINDOW_TOP_EDGE_Y (w
);
2654 pos_x
= row
->used
[LEFT_MARGIN_AREA
] + start_hpos
+ WINDOW_LEFT_EDGE_X (w
);
2656 /* Save current cursor co-ordinates. */
2657 save_y
= curY (tty
);
2658 save_x
= curX (tty
);
2659 cursor_to (f
, pos_y
, pos_x
);
2661 if (draw
== DRAW_MOUSE_FACE
)
2662 tty_write_glyphs_with_face (f
, row
->glyphs
[TEXT_AREA
] + start_hpos
,
2664 else if (draw
== DRAW_NORMAL_TEXT
)
2665 write_glyphs (f
, row
->glyphs
[TEXT_AREA
] + start_hpos
, nglyphs
);
2667 cursor_to (f
, save_y
, save_x
);
2671 term_mouse_movement (FRAME_PTR frame
, Gpm_Event
*event
)
2673 /* Has the mouse moved off the glyph it was on at the last sighting? */
2674 if (event
->x
!= last_mouse_x
|| event
->y
!= last_mouse_y
)
2676 frame
->mouse_moved
= 1;
2677 note_mouse_highlight (frame
, event
->x
, event
->y
);
2678 /* Remember which glyph we're now on. */
2679 last_mouse_x
= event
->x
;
2680 last_mouse_y
= event
->y
;
2686 /* Return the current position of the mouse.
2688 Set *f to the frame the mouse is in, or zero if the mouse is in no
2689 Emacs frame. If it is set to zero, all the other arguments are
2692 Set *bar_window to Qnil, and *x and *y to the column and
2693 row of the character cell the mouse is over.
2695 Set *timeptr to the time the mouse was at the returned position.
2697 This clears mouse_moved until the next motion
2700 term_mouse_position (FRAME_PTR
*fp
, int insist
, Lisp_Object
*bar_window
,
2701 enum scroll_bar_part
*part
, Lisp_Object
*x
,
2702 Lisp_Object
*y
, unsigned long *timeptr
)
2706 *fp
= SELECTED_FRAME ();
2707 (*fp
)->mouse_moved
= 0;
2712 XSETINT (*x
, last_mouse_x
);
2713 XSETINT (*y
, last_mouse_y
);
2714 gettimeofday(&now
, 0);
2715 *timeptr
= (now
.tv_sec
* 1000) + (now
.tv_usec
/ 1000);
2718 /* Prepare a mouse-event in *RESULT for placement in the input queue.
2720 If the event is a button press, then note that we have grabbed
2724 term_mouse_click (struct input_event
*result
, Gpm_Event
*event
,
2730 result
->kind
= GPM_CLICK_EVENT
;
2731 for (i
= 0, j
= GPM_B_LEFT
; i
< 3; i
++, j
>>= 1 )
2733 if (event
->buttons
& j
) {
2734 result
->code
= i
; /* button number */
2738 gettimeofday(&now
, 0);
2739 result
->timestamp
= (now
.tv_sec
* 1000) + (now
.tv_usec
/ 1000);
2741 if (event
->type
& GPM_UP
)
2742 result
->modifiers
= up_modifier
;
2743 else if (event
->type
& GPM_DOWN
)
2744 result
->modifiers
= down_modifier
;
2746 result
->modifiers
= 0;
2748 if (event
->type
& GPM_SINGLE
)
2749 result
->modifiers
|= click_modifier
;
2751 if (event
->type
& GPM_DOUBLE
)
2752 result
->modifiers
|= double_modifier
;
2754 if (event
->type
& GPM_TRIPLE
)
2755 result
->modifiers
|= triple_modifier
;
2757 if (event
->type
& GPM_DRAG
)
2758 result
->modifiers
|= drag_modifier
;
2760 if (!(event
->type
& (GPM_MOVE
| GPM_DRAG
))) {
2763 if (event
->modifiers
& (1 << 0))
2764 result
->modifiers
|= shift_modifier
;
2767 if (event
->modifiers
& (1 << 2))
2768 result
->modifiers
|= ctrl_modifier
;
2770 /* 1 << KG_ALT || KG_ALTGR */
2771 if (event
->modifiers
& (1 << 3)
2772 || event
->modifiers
& (1 << 1))
2773 result
->modifiers
|= meta_modifier
;
2776 XSETINT (result
->x
, event
->x
);
2777 XSETINT (result
->y
, event
->y
);
2778 XSETFRAME (result
->frame_or_window
, f
);
2784 handle_one_term_event (struct tty_display_info
*tty
, Gpm_Event
*event
, struct input_event
* hold_quit
)
2786 struct frame
*f
= XFRAME (tty
->top_frame
);
2787 struct input_event ie
;
2795 if (event
->type
& (GPM_MOVE
| GPM_DRAG
)) {
2796 previous_help_echo_string
= help_echo_string
;
2797 help_echo_string
= Qnil
;
2799 Gpm_DrawPointer (event
->x
, event
->y
, fileno (tty
->output
));
2801 if (!term_mouse_movement (f
, event
))
2802 help_echo_string
= previous_help_echo_string
;
2804 /* If the contents of the global variable help_echo_string
2805 has changed, generate a HELP_EVENT. */
2806 if (!NILP (help_echo_string
)
2807 || !NILP (previous_help_echo_string
))
2814 term_mouse_click (&ie
, event
, f
);
2818 if (ie
.kind
!= NO_EVENT
)
2820 kbd_buffer_store_event_hold (&ie
, hold_quit
);
2825 && !(hold_quit
&& hold_quit
->kind
!= NO_EVENT
))
2830 XSETFRAME (frame
, f
);
2834 gen_help_event (help_echo_string
, frame
, help_echo_window
,
2835 help_echo_object
, help_echo_pos
);
2842 DEFUN ("gpm-mouse-start", Fgpm_mouse_start
, Sgpm_mouse_start
,
2844 doc
: /* Open a connection to Gpm.
2845 Gpm-mouse can only be activated for one tty at a time. */)
2848 struct frame
*f
= SELECTED_FRAME ();
2849 struct tty_display_info
*tty
2850 = ((f
)->output_method
== output_termcap
2851 ? (f
)->terminal
->display_info
.tty
: NULL
);
2852 Gpm_Connect connection
;
2855 error ("Gpm-mouse only works in the GNU/Linux console");
2857 return Qnil
; /* Already activated, nothing to do. */
2859 error ("Gpm-mouse can only be activated for one tty at a time");
2861 connection
.eventMask
= ~0;
2862 connection
.defaultMask
= ~GPM_HARD
;
2863 connection
.maxMod
= ~0;
2864 connection
.minMod
= 0;
2867 if (Gpm_Open (&connection
, 0) < 0)
2868 error ("Gpm-mouse failed to connect to the gpm daemon");
2872 /* `init_sys_modes' arranges for mouse movements sent through gpm_fd
2873 to generate SIGIOs. Apparently we need to call reset_sys_modes
2874 before calling init_sys_modes. */
2875 reset_sys_modes (tty
);
2876 init_sys_modes (tty
);
2877 add_gpm_wait_descriptor (gpm_fd
);
2886 delete_gpm_wait_descriptor (fd
);
2887 while (Gpm_Close()); /* close all the stack */
2891 DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop
, Sgpm_mouse_stop
,
2893 doc
: /* Close a connection to Gpm. */)
2896 struct frame
*f
= SELECTED_FRAME ();
2897 struct tty_display_info
*tty
2898 = ((f
)->output_method
== output_termcap
2899 ? (f
)->terminal
->display_info
.tty
: NULL
);
2901 if (!tty
|| gpm_tty
!= tty
)
2902 return Qnil
; /* Not activated on this terminal, nothing to do. */
2907 #endif /* HAVE_GPM */
2911 /***********************************************************************
2913 ***********************************************************************/
2915 /* Initialize the tty-dependent part of frame F. The frame must
2916 already have its device initialized. */
2919 create_tty_output (struct frame
*f
)
2921 struct tty_output
*t
;
2923 if (! FRAME_TERMCAP_P (f
))
2926 t
= xmalloc (sizeof (struct tty_output
));
2927 memset (t
, 0, sizeof (struct tty_output
));
2929 t
->display_info
= FRAME_TERMINAL (f
)->display_info
.tty
;
2931 f
->output_data
.tty
= t
;
2934 /* Delete frame F's face cache, and its tty-dependent part. */
2937 tty_free_frame_resources (struct frame
*f
)
2939 if (! FRAME_TERMCAP_P (f
))
2942 if (FRAME_FACE_CACHE (f
))
2943 free_frame_faces (f
);
2945 xfree (f
->output_data
.tty
);
2950 /* Delete frame F's face cache. */
2953 tty_free_frame_resources (struct frame
*f
)
2955 if (! FRAME_TERMCAP_P (f
) && ! FRAME_MSDOS_P (f
))
2958 if (FRAME_FACE_CACHE (f
))
2959 free_frame_faces (f
);
2963 /* Reset the hooks in TERMINAL. */
2966 clear_tty_hooks (struct terminal
*terminal
)
2969 terminal
->cursor_to_hook
= 0;
2970 terminal
->raw_cursor_to_hook
= 0;
2971 terminal
->clear_to_end_hook
= 0;
2972 terminal
->clear_frame_hook
= 0;
2973 terminal
->clear_end_of_line_hook
= 0;
2974 terminal
->ins_del_lines_hook
= 0;
2975 terminal
->insert_glyphs_hook
= 0;
2976 terminal
->write_glyphs_hook
= 0;
2977 terminal
->delete_glyphs_hook
= 0;
2978 terminal
->ring_bell_hook
= 0;
2979 terminal
->reset_terminal_modes_hook
= 0;
2980 terminal
->set_terminal_modes_hook
= 0;
2981 terminal
->update_begin_hook
= 0;
2982 terminal
->update_end_hook
= 0;
2983 terminal
->set_terminal_window_hook
= 0;
2984 terminal
->mouse_position_hook
= 0;
2985 terminal
->frame_rehighlight_hook
= 0;
2986 terminal
->frame_raise_lower_hook
= 0;
2987 terminal
->fullscreen_hook
= 0;
2988 terminal
->set_vertical_scroll_bar_hook
= 0;
2989 terminal
->condemn_scroll_bars_hook
= 0;
2990 terminal
->redeem_scroll_bar_hook
= 0;
2991 terminal
->judge_scroll_bars_hook
= 0;
2992 terminal
->read_socket_hook
= 0;
2993 terminal
->frame_up_to_date_hook
= 0;
2995 /* Leave these two set, or suspended frames are not deleted
2997 terminal
->delete_frame_hook
= &tty_free_frame_resources
;
2998 terminal
->delete_terminal_hook
= &delete_tty
;
3001 /* Initialize hooks in TERMINAL with the values needed for a tty. */
3004 set_tty_hooks (struct terminal
*terminal
)
3006 terminal
->rif
= 0; /* ttys don't support window-based redisplay. */
3008 terminal
->cursor_to_hook
= &tty_cursor_to
;
3009 terminal
->raw_cursor_to_hook
= &tty_raw_cursor_to
;
3011 terminal
->clear_to_end_hook
= &tty_clear_to_end
;
3012 terminal
->clear_frame_hook
= &tty_clear_frame
;
3013 terminal
->clear_end_of_line_hook
= &tty_clear_end_of_line
;
3015 terminal
->ins_del_lines_hook
= &tty_ins_del_lines
;
3017 terminal
->insert_glyphs_hook
= &tty_insert_glyphs
;
3018 terminal
->write_glyphs_hook
= &tty_write_glyphs
;
3019 terminal
->delete_glyphs_hook
= &tty_delete_glyphs
;
3021 terminal
->ring_bell_hook
= &tty_ring_bell
;
3023 terminal
->reset_terminal_modes_hook
= &tty_reset_terminal_modes
;
3024 terminal
->set_terminal_modes_hook
= &tty_set_terminal_modes
;
3025 terminal
->update_begin_hook
= 0; /* Not needed. */
3026 terminal
->update_end_hook
= &tty_update_end
;
3027 terminal
->set_terminal_window_hook
= &tty_set_terminal_window
;
3029 terminal
->mouse_position_hook
= 0; /* Not needed. */
3030 terminal
->frame_rehighlight_hook
= 0; /* Not needed. */
3031 terminal
->frame_raise_lower_hook
= 0; /* Not needed. */
3033 terminal
->set_vertical_scroll_bar_hook
= 0; /* Not needed. */
3034 terminal
->condemn_scroll_bars_hook
= 0; /* Not needed. */
3035 terminal
->redeem_scroll_bar_hook
= 0; /* Not needed. */
3036 terminal
->judge_scroll_bars_hook
= 0; /* Not needed. */
3038 terminal
->read_socket_hook
= &tty_read_avail_input
; /* keyboard.c */
3039 terminal
->frame_up_to_date_hook
= 0; /* Not needed. */
3041 terminal
->delete_frame_hook
= &tty_free_frame_resources
;
3042 terminal
->delete_terminal_hook
= &delete_tty
;
3045 /* Drop the controlling terminal if fd is the same device. */
3047 dissociate_if_controlling_tty (int fd
)
3050 int pgid
= tcgetpgrp (fd
); /* If tcgetpgrp succeeds, fd is the ctty. */
3055 no_controlling_tty
= 1;
3056 #elif defined (CYGWIN)
3058 no_controlling_tty
= 1;
3060 #ifdef TIOCNOTTY /* Try BSD ioctls. */
3061 sigblock (sigmask (SIGTTOU
));
3062 fd
= emacs_open (DEV_TTY
, O_RDWR
, 0);
3063 if (fd
!= -1 && ioctl (fd
, TIOCNOTTY
, 0) != -1)
3065 no_controlling_tty
= 1;
3069 sigunblock (sigmask (SIGTTOU
));
3071 /* Unknown system. */
3073 #endif /* ! TIOCNOTTY */
3076 #endif /* !DOS_NT */
3079 /* Create a termcap display on the tty device with the given name and
3082 If NAME is NULL, then use the controlling tty, i.e., "/dev/tty".
3083 Otherwise NAME should be a path to the tty device file,
3086 TERMINAL_TYPE is the termcap type of the device, e.g. "vt100".
3088 If MUST_SUCCEED is true, then all errors are fatal. */
3091 init_tty (const char *name
, const char *terminal_type
, int must_succeed
)
3094 char **address
= &area
;
3095 int buffer_size
= 4096;
3096 register char *p
= NULL
;
3098 struct tty_display_info
*tty
= NULL
;
3099 struct terminal
*terminal
= NULL
;
3100 int ctty
= 0; /* 1 if asked to open controlling tty. */
3103 maybe_fatal (must_succeed
, 0,
3104 "Unknown terminal type",
3105 "Unknown terminal type");
3109 if (!strcmp (name
, DEV_TTY
))
3112 /* If we already have a terminal on the given device, use that. If
3113 all such terminals are suspended, create a new one instead. */
3114 /* XXX Perhaps this should be made explicit by having init_tty
3115 always create a new terminal and separating terminal and frame
3116 creation on Lisp level. */
3117 terminal
= get_named_tty (name
);
3121 terminal
= create_terminal ();
3124 maybe_fatal (0, 0, "Attempt to create another terminal %s", "",
3127 tty
= &the_only_display_info
;
3129 tty
= (struct tty_display_info
*) xmalloc (sizeof (struct tty_display_info
));
3131 memset (tty
, 0, sizeof (struct tty_display_info
));
3132 tty
->next
= tty_list
;
3135 terminal
->type
= output_termcap
;
3136 terminal
->display_info
.tty
= tty
;
3137 tty
->terminal
= terminal
;
3139 tty
->Wcm
= (struct cm
*) xmalloc (sizeof (struct cm
));
3142 encode_terminal_src_size
= 0;
3143 encode_terminal_dst_size
= 0;
3146 terminal
->mouse_position_hook
= term_mouse_position
;
3147 tty
->mouse_highlight
.mouse_face_window
= Qnil
;
3152 set_tty_hooks (terminal
);
3158 #ifdef O_IGNORE_CTTY
3160 /* Open the terminal device. Don't recognize it as our
3161 controlling terminal, and don't make it the controlling tty
3162 if we don't have one at the moment. */
3163 fd
= emacs_open (name
, O_RDWR
| O_IGNORE_CTTY
| O_NOCTTY
, 0);
3165 #endif /* O_IGNORE_CTTY */
3166 /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only
3167 defined on Hurd. On other systems, we need to explicitly
3168 dissociate ourselves from the controlling tty when we want to
3169 open a frame on the same terminal. */
3170 fd
= emacs_open (name
, O_RDWR
| O_NOCTTY
, 0);
3172 tty
->name
= xstrdup (name
);
3173 terminal
->name
= xstrdup (name
);
3176 maybe_fatal (must_succeed
, terminal
,
3177 "Could not open file: %s",
3178 "Could not open file: %s",
3183 maybe_fatal (must_succeed
, terminal
,
3184 "Not a tty device: %s",
3185 "Not a tty device: %s",
3189 #ifndef O_IGNORE_CTTY
3191 dissociate_if_controlling_tty (fd
);
3194 file
= fdopen (fd
, "w+");
3199 tty
->type
= xstrdup (terminal_type
);
3201 add_keyboard_wait_descriptor (fileno (tty
->input
));
3205 tty
->termcap_term_buffer
= (char *) xmalloc (buffer_size
);
3207 /* On some systems, tgetent tries to access the controlling
3209 sigblock (sigmask (SIGTTOU
));
3210 status
= tgetent (tty
->termcap_term_buffer
, terminal_type
);
3211 sigunblock (sigmask (SIGTTOU
));
3216 maybe_fatal (must_succeed
, terminal
,
3217 "Cannot open terminfo database file",
3218 "Cannot open terminfo database file");
3220 maybe_fatal (must_succeed
, terminal
,
3221 "Cannot open termcap database file",
3222 "Cannot open termcap database file");
3227 maybe_fatal (must_succeed
, terminal
,
3228 "Terminal type %s is not defined",
3229 "Terminal type %s is not defined.\n\
3230 If that is not the actual type of terminal you have,\n\
3231 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3232 `setenv TERM ...') to specify the correct type. It may be necessary\n"
3234 "to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
3236 "to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
3242 if (strlen (tty
->termcap_term_buffer
) >= buffer_size
)
3244 buffer_size
= strlen (tty
->termcap_term_buffer
);
3246 tty
->termcap_strings_buffer
= area
= (char *) xmalloc (buffer_size
);
3247 tty
->TS_ins_line
= tgetstr ("al", address
);
3248 tty
->TS_ins_multi_lines
= tgetstr ("AL", address
);
3249 tty
->TS_bell
= tgetstr ("bl", address
);
3250 BackTab (tty
) = tgetstr ("bt", address
);
3251 tty
->TS_clr_to_bottom
= tgetstr ("cd", address
);
3252 tty
->TS_clr_line
= tgetstr ("ce", address
);
3253 tty
->TS_clr_frame
= tgetstr ("cl", address
);
3254 ColPosition (tty
) = NULL
; /* tgetstr ("ch", address); */
3255 AbsPosition (tty
) = tgetstr ("cm", address
);
3256 CR (tty
) = tgetstr ("cr", address
);
3257 tty
->TS_set_scroll_region
= tgetstr ("cs", address
);
3258 tty
->TS_set_scroll_region_1
= tgetstr ("cS", address
);
3259 RowPosition (tty
) = tgetstr ("cv", address
);
3260 tty
->TS_del_char
= tgetstr ("dc", address
);
3261 tty
->TS_del_multi_chars
= tgetstr ("DC", address
);
3262 tty
->TS_del_line
= tgetstr ("dl", address
);
3263 tty
->TS_del_multi_lines
= tgetstr ("DL", address
);
3264 tty
->TS_delete_mode
= tgetstr ("dm", address
);
3265 tty
->TS_end_delete_mode
= tgetstr ("ed", address
);
3266 tty
->TS_end_insert_mode
= tgetstr ("ei", address
);
3267 Home (tty
) = tgetstr ("ho", address
);
3268 tty
->TS_ins_char
= tgetstr ("ic", address
);
3269 tty
->TS_ins_multi_chars
= tgetstr ("IC", address
);
3270 tty
->TS_insert_mode
= tgetstr ("im", address
);
3271 tty
->TS_pad_inserted_char
= tgetstr ("ip", address
);
3272 tty
->TS_end_keypad_mode
= tgetstr ("ke", address
);
3273 tty
->TS_keypad_mode
= tgetstr ("ks", address
);
3274 LastLine (tty
) = tgetstr ("ll", address
);
3275 Right (tty
) = tgetstr ("nd", address
);
3276 Down (tty
) = tgetstr ("do", address
);
3278 Down (tty
) = tgetstr ("nl", address
); /* Obsolete name for "do" */
3279 if (tgetflag ("bs"))
3280 Left (tty
) = "\b"; /* can't possibly be longer! */
3281 else /* (Actually, "bs" is obsolete...) */
3282 Left (tty
) = tgetstr ("le", address
);
3284 Left (tty
) = tgetstr ("bc", address
); /* Obsolete name for "le" */
3285 tty
->TS_pad_char
= tgetstr ("pc", address
);
3286 tty
->TS_repeat
= tgetstr ("rp", address
);
3287 tty
->TS_end_standout_mode
= tgetstr ("se", address
);
3288 tty
->TS_fwd_scroll
= tgetstr ("sf", address
);
3289 tty
->TS_standout_mode
= tgetstr ("so", address
);
3290 tty
->TS_rev_scroll
= tgetstr ("sr", address
);
3291 tty
->Wcm
->cm_tab
= tgetstr ("ta", address
);
3292 tty
->TS_end_termcap_modes
= tgetstr ("te", address
);
3293 tty
->TS_termcap_modes
= tgetstr ("ti", address
);
3294 Up (tty
) = tgetstr ("up", address
);
3295 tty
->TS_visible_bell
= tgetstr ("vb", address
);
3296 tty
->TS_cursor_normal
= tgetstr ("ve", address
);
3297 tty
->TS_cursor_visible
= tgetstr ("vs", address
);
3298 tty
->TS_cursor_invisible
= tgetstr ("vi", address
);
3299 tty
->TS_set_window
= tgetstr ("wi", address
);
3301 tty
->TS_enter_underline_mode
= tgetstr ("us", address
);
3302 tty
->TS_exit_underline_mode
= tgetstr ("ue", address
);
3303 tty
->TS_enter_bold_mode
= tgetstr ("md", address
);
3304 tty
->TS_enter_dim_mode
= tgetstr ("mh", address
);
3305 tty
->TS_enter_blink_mode
= tgetstr ("mb", address
);
3306 tty
->TS_enter_reverse_mode
= tgetstr ("mr", address
);
3307 tty
->TS_enter_alt_charset_mode
= tgetstr ("as", address
);
3308 tty
->TS_exit_alt_charset_mode
= tgetstr ("ae", address
);
3309 tty
->TS_exit_attribute_mode
= tgetstr ("me", address
);
3311 MultiUp (tty
) = tgetstr ("UP", address
);
3312 MultiDown (tty
) = tgetstr ("DO", address
);
3313 MultiLeft (tty
) = tgetstr ("LE", address
);
3314 MultiRight (tty
) = tgetstr ("RI", address
);
3316 /* SVr4/ANSI color suppert. If "op" isn't available, don't support
3317 color because we can't switch back to the default foreground and
3319 tty
->TS_orig_pair
= tgetstr ("op", address
);
3320 if (tty
->TS_orig_pair
)
3322 tty
->TS_set_foreground
= tgetstr ("AF", address
);
3323 tty
->TS_set_background
= tgetstr ("AB", address
);
3324 if (!tty
->TS_set_foreground
)
3327 tty
->TS_set_foreground
= tgetstr ("Sf", address
);
3328 tty
->TS_set_background
= tgetstr ("Sb", address
);
3331 tty
->TN_max_colors
= tgetnum ("Co");
3332 tty
->TN_max_pairs
= tgetnum ("pa");
3334 tty
->TN_no_color_video
= tgetnum ("NC");
3335 if (tty
->TN_no_color_video
== -1)
3336 tty
->TN_no_color_video
= 0;
3339 tty_default_color_capabilities (tty
, 1);
3341 MagicWrap (tty
) = tgetflag ("xn");
3342 /* Since we make MagicWrap terminals look like AutoWrap, we need to have
3343 the former flag imply the latter. */
3344 AutoWrap (tty
) = MagicWrap (tty
) || tgetflag ("am");
3345 terminal
->memory_below_frame
= tgetflag ("db");
3346 tty
->TF_hazeltine
= tgetflag ("hz");
3347 terminal
->must_write_spaces
= tgetflag ("in");
3348 tty
->meta_key
= tgetflag ("km") || tgetflag ("MT");
3349 tty
->TF_insmode_motion
= tgetflag ("mi");
3350 tty
->TF_standout_motion
= tgetflag ("ms");
3351 tty
->TF_underscore
= tgetflag ("ul");
3352 tty
->TF_teleray
= tgetflag ("xt");
3357 struct frame
*f
= XFRAME (selected_frame
);
3359 initialize_w32_display (terminal
);
3361 FrameRows (tty
) = FRAME_LINES (f
);
3362 FrameCols (tty
) = FRAME_COLS (f
);
3363 tty
->specified_window
= FRAME_LINES (f
);
3365 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
3366 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
3367 terminal
->char_ins_del_ok
= 1;
3373 if (strcmp (terminal_type
, "internal") == 0)
3374 terminal
->type
= output_msdos_raw
;
3375 initialize_msdos_display (terminal
);
3377 get_tty_size (fileno (tty
->input
), &width
, &height
);
3378 FrameCols (tty
) = width
;
3379 FrameRows (tty
) = height
;
3380 terminal
->char_ins_del_ok
= 0;
3381 init_baud_rate (fileno (tty
->input
));
3384 tty
->output
= stdout
;
3386 /* The following two are inaccessible from w32console.c. */
3387 terminal
->delete_frame_hook
= &tty_free_frame_resources
;
3388 terminal
->delete_terminal_hook
= &delete_tty
;
3390 tty
->name
= xstrdup (name
);
3391 terminal
->name
= xstrdup (name
);
3392 tty
->type
= xstrdup (terminal_type
);
3394 add_keyboard_wait_descriptor (0);
3396 tty
->delete_in_insert_mode
= 1;
3399 terminal
->scroll_region_ok
= 0;
3401 /* Seems to insert lines when it's not supposed to, messing up the
3402 display. In doing a trace, it didn't seem to be called much, so I
3403 don't think we're losing anything by turning it off. */
3404 terminal
->line_ins_del_ok
= 0;
3406 tty
->TN_max_colors
= 16; /* Required to be non-zero for tty-display-color-p */
3409 terminal
->kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
3410 init_kboard (terminal
->kboard
);
3411 KVAR (terminal
->kboard
, Vwindow_system
) = Qnil
;
3412 terminal
->kboard
->next_kboard
= all_kboards
;
3413 all_kboards
= terminal
->kboard
;
3414 terminal
->kboard
->reference_count
++;
3415 /* Don't let the initial kboard remain current longer than necessary.
3416 That would cause problems if a file loaded on startup tries to
3417 prompt in the mini-buffer. */
3418 if (current_kboard
== initial_kboard
)
3419 current_kboard
= terminal
->kboard
;
3421 term_get_fkeys (address
, terminal
->kboard
);
3423 /* Get frame size from system, or else from termcap. */
3426 get_tty_size (fileno (tty
->input
), &width
, &height
);
3427 FrameCols (tty
) = width
;
3428 FrameRows (tty
) = height
;
3431 if (FrameCols (tty
) <= 0)
3432 FrameCols (tty
) = tgetnum ("co");
3433 if (FrameRows (tty
) <= 0)
3434 FrameRows (tty
) = tgetnum ("li");
3436 if (FrameRows (tty
) < 3 || FrameCols (tty
) < 3)
3437 maybe_fatal (must_succeed
, terminal
,
3438 "Screen size %dx%d is too small",
3439 "Screen size %dx%d is too small",
3440 FrameCols (tty
), FrameRows (tty
));
3442 TabWidth (tty
) = tgetnum ("tw");
3445 tty
->TS_bell
= "\07";
3447 if (!tty
->TS_fwd_scroll
)
3448 tty
->TS_fwd_scroll
= Down (tty
);
3450 PC
= tty
->TS_pad_char
? *tty
->TS_pad_char
: 0;
3452 if (TabWidth (tty
) < 0)
3455 /* Turned off since /etc/termcap seems to have :ta= for most terminals
3456 and newer termcap doc does not seem to say there is a default.
3457 if (!tty->Wcm->cm_tab)
3458 tty->Wcm->cm_tab = "\t";
3461 /* We don't support standout modes that use `magic cookies', so
3462 turn off any that do. */
3463 if (tty
->TS_standout_mode
&& tgetnum ("sg") >= 0)
3465 tty
->TS_standout_mode
= 0;
3466 tty
->TS_end_standout_mode
= 0;
3468 if (tty
->TS_enter_underline_mode
&& tgetnum ("ug") >= 0)
3470 tty
->TS_enter_underline_mode
= 0;
3471 tty
->TS_exit_underline_mode
= 0;
3474 /* If there's no standout mode, try to use underlining instead. */
3475 if (tty
->TS_standout_mode
== 0)
3477 tty
->TS_standout_mode
= tty
->TS_enter_underline_mode
;
3478 tty
->TS_end_standout_mode
= tty
->TS_exit_underline_mode
;
3481 /* If no `se' string, try using a `me' string instead.
3482 If that fails, we can't use standout mode at all. */
3483 if (tty
->TS_end_standout_mode
== 0)
3485 char *s
= tgetstr ("me", address
);
3487 tty
->TS_end_standout_mode
= s
;
3489 tty
->TS_standout_mode
= 0;
3492 if (tty
->TF_teleray
)
3494 tty
->Wcm
->cm_tab
= 0;
3495 /* We can't support standout mode, because it uses magic cookies. */
3496 tty
->TS_standout_mode
= 0;
3497 /* But that means we cannot rely on ^M to go to column zero! */
3499 /* LF can't be trusted either -- can alter hpos */
3500 /* if move at column 0 thru a line with TS_standout_mode */
3504 /* Special handling for certain terminal types known to need it */
3506 if (!strcmp (terminal_type
, "supdup"))
3508 terminal
->memory_below_frame
= 1;
3509 tty
->Wcm
->cm_losewrap
= 1;
3511 if (!strncmp (terminal_type
, "c10", 3)
3512 || !strcmp (terminal_type
, "perq"))
3514 /* Supply a makeshift :wi string.
3515 This string is not valid in general since it works only
3516 for windows starting at the upper left corner;
3517 but that is all Emacs uses.
3519 This string works only if the frame is using
3520 the top of the video memory, because addressing is memory-relative.
3521 So first check the :ti string to see if that is true.
3523 It would be simpler if the :wi string could go in the termcap
3524 entry, but it can't because it is not fully valid.
3525 If it were in the termcap entry, it would confuse other programs. */
3526 if (!tty
->TS_set_window
)
3528 const char *m
= tty
->TS_termcap_modes
;
3529 while (*m
&& strcmp (m
, "\033v "))
3532 tty
->TS_set_window
= "\033v%C %C %C %C ";
3534 /* Termcap entry often fails to have :in: flag */
3535 terminal
->must_write_spaces
= 1;
3536 /* :ti string typically fails to have \E^G! in it */
3537 /* This limits scope of insert-char to one line. */
3538 strcpy (area
, tty
->TS_termcap_modes
);
3539 strcat (area
, "\033\007!");
3540 tty
->TS_termcap_modes
= area
;
3541 area
+= strlen (area
) + 1;
3542 p
= AbsPosition (tty
);
3543 /* Change all %+ parameters to %C, to handle
3544 values above 96 correctly for the C100. */
3547 if (p
[0] == '%' && p
[1] == '+')
3553 tty
->specified_window
= FrameRows (tty
);
3555 if (Wcm_init (tty
) == -1) /* can't do cursor motion */
3557 maybe_fatal (must_succeed
, terminal
,
3558 "Terminal type \"%s\" is not powerful enough to run Emacs",
3559 "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
3560 It lacks the ability to position the cursor.\n\
3561 If that is not the actual type of terminal you have,\n\
3562 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3563 `setenv TERM ...') to specify the correct type. It may be necessary\n"
3565 "to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
3566 # else /* TERMCAP */
3567 "to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
3568 # endif /* TERMINFO */
3572 if (FrameRows (tty
) <= 0 || FrameCols (tty
) <= 0)
3573 maybe_fatal (must_succeed
, terminal
,
3574 "Could not determine the frame size",
3575 "Could not determine the frame size");
3577 tty
->delete_in_insert_mode
3578 = tty
->TS_delete_mode
&& tty
->TS_insert_mode
3579 && !strcmp (tty
->TS_delete_mode
, tty
->TS_insert_mode
);
3581 tty
->se_is_so
= (tty
->TS_standout_mode
3582 && tty
->TS_end_standout_mode
3583 && !strcmp (tty
->TS_standout_mode
, tty
->TS_end_standout_mode
));
3585 UseTabs (tty
) = tabs_safe_p (fileno (tty
->input
)) && TabWidth (tty
) == 8;
3587 terminal
->scroll_region_ok
3589 && (tty
->TS_set_window
|| tty
->TS_set_scroll_region
|| tty
->TS_set_scroll_region_1
));
3591 terminal
->line_ins_del_ok
3592 = (((tty
->TS_ins_line
|| tty
->TS_ins_multi_lines
)
3593 && (tty
->TS_del_line
|| tty
->TS_del_multi_lines
))
3594 || (terminal
->scroll_region_ok
3595 && tty
->TS_fwd_scroll
&& tty
->TS_rev_scroll
));
3597 terminal
->char_ins_del_ok
3598 = ((tty
->TS_ins_char
|| tty
->TS_insert_mode
3599 || tty
->TS_pad_inserted_char
|| tty
->TS_ins_multi_chars
)
3600 && (tty
->TS_del_char
|| tty
->TS_del_multi_chars
));
3602 terminal
->fast_clear_end_of_line
= tty
->TS_clr_line
!= 0;
3604 init_baud_rate (fileno (tty
->input
));
3606 #endif /* not DOS_NT */
3608 /* Init system terminal modes (RAW or CBREAK, etc.). */
3609 init_sys_modes (tty
);
3616 vfatal (const char *str
, va_list ap
)
3618 fprintf (stderr
, "emacs: ");
3619 vfprintf (stderr
, str
, ap
);
3620 if (!(strlen (str
) > 0 && str
[strlen (str
) - 1] == '\n'))
3621 fprintf (stderr
, "\n");
3628 /* Auxiliary error-handling function for init_tty.
3629 Delete TERMINAL, then call error or fatal with str1 or str2,
3630 respectively, according to whether MUST_SUCCEED is zero or not. */
3633 maybe_fatal (int must_succeed
, struct terminal
*terminal
,
3634 const char *str1
, const char *str2
, ...)
3637 va_start (ap
, str2
);
3639 delete_tty (terminal
);
3651 fatal (const char *str
, ...)
3661 /* Delete the given tty terminal, closing all frames on it. */
3664 delete_tty (struct terminal
*terminal
)
3666 struct tty_display_info
*tty
;
3668 /* Protect against recursive calls. delete_frame in
3669 delete_terminal calls us back when it deletes our last frame. */
3670 if (!terminal
->name
)
3673 if (terminal
->type
!= output_termcap
)
3676 tty
= terminal
->display_info
.tty
;
3678 if (tty
== tty_list
)
3679 tty_list
= tty
->next
;
3682 struct tty_display_info
*p
;
3683 for (p
= tty_list
; p
&& p
->next
!= tty
; p
= p
->next
)
3687 /* This should not happen. */
3690 p
->next
= tty
->next
;
3694 /* reset_sys_modes needs a valid device, so this call needs to be
3695 before delete_terminal. */
3696 reset_sys_modes (tty
);
3698 delete_terminal (terminal
);
3705 delete_keyboard_wait_descriptor (fileno (tty
->input
));
3706 if (tty
->input
!= stdin
)
3707 fclose (tty
->input
);
3709 if (tty
->output
&& tty
->output
!= stdout
&& tty
->output
!= tty
->input
)
3710 fclose (tty
->output
);
3711 if (tty
->termscript
)
3712 fclose (tty
->termscript
);
3714 xfree (tty
->old_tty
);
3716 xfree (tty
->termcap_strings_buffer
);
3717 xfree (tty
->termcap_term_buffer
);
3719 memset (tty
, 0, sizeof (struct tty_display_info
));
3725 /* Mark the pointers in the tty_display_info objects.
3726 Called by the Fgarbage_collector. */
3731 struct tty_display_info
*tty
;
3733 for (tty
= tty_list
; tty
; tty
= tty
->next
)
3734 mark_object (tty
->top_frame
);
3742 DEFVAR_BOOL ("system-uses-terminfo", system_uses_terminfo
,
3743 doc
: /* Non-nil means the system uses terminfo rather than termcap.
3744 This variable can be used by terminal emulator packages. */);
3746 system_uses_terminfo
= 1;
3748 system_uses_terminfo
= 0;
3751 DEFVAR_LISP ("suspend-tty-functions", Vsuspend_tty_functions
,
3752 doc
: /* Functions to be run after suspending a tty.
3753 The functions are run with one argument, the terminal object to be suspended.
3754 See `suspend-tty'. */);
3755 Vsuspend_tty_functions
= Qnil
;
3758 DEFVAR_LISP ("resume-tty-functions", Vresume_tty_functions
,
3759 doc
: /* Functions to be run after resuming a tty.
3760 The functions are run with one argument, the terminal object that was revived.
3761 See `resume-tty'. */);
3762 Vresume_tty_functions
= Qnil
;
3764 DEFVAR_BOOL ("visible-cursor", visible_cursor
,
3765 doc
: /* Non-nil means to make the cursor very visible.
3766 This only has an effect when running in a text terminal.
3767 What means \"very visible\" is up to your terminal. It may make the cursor
3768 bigger, or it may make it blink, or it may do nothing at all. */);
3771 defsubr (&Stty_display_color_p
);
3772 defsubr (&Stty_display_color_cells
);
3773 defsubr (&Stty_no_underline
);
3774 defsubr (&Stty_type
);
3775 defsubr (&Scontrolling_tty_p
);
3776 defsubr (&Ssuspend_tty
);
3777 defsubr (&Sresume_tty
);
3779 defsubr (&Sgpm_mouse_start
);
3780 defsubr (&Sgpm_mouse_stop
);
3781 #endif /* HAVE_GPM */
3784 default_orig_pair
= NULL
;
3785 default_set_foreground
= NULL
;
3786 default_set_background
= NULL
;
3787 #endif /* !DOS_NT */
3789 encode_terminal_src
= NULL
;
3790 encode_terminal_dst
= NULL
;