aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/term.c b/src/term.c
index 39d143564c6..b6878a0abd1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -71,13 +71,13 @@ static void tty_turn_off_highlight (struct tty_display_info *);
71static void tty_show_cursor (struct tty_display_info *); 71static void tty_show_cursor (struct tty_display_info *);
72static void tty_hide_cursor (struct tty_display_info *); 72static void tty_hide_cursor (struct tty_display_info *);
73static void tty_background_highlight (struct tty_display_info *tty); 73static void tty_background_highlight (struct tty_display_info *tty);
74static struct terminal *get_tty_terminal (Lisp_Object, int); 74static struct terminal *get_tty_terminal (Lisp_Object, bool);
75static void clear_tty_hooks (struct terminal *terminal); 75static void clear_tty_hooks (struct terminal *terminal);
76static void set_tty_hooks (struct terminal *terminal); 76static void set_tty_hooks (struct terminal *terminal);
77static void dissociate_if_controlling_tty (int fd); 77static void dissociate_if_controlling_tty (int fd);
78static void delete_tty (struct terminal *); 78static void delete_tty (struct terminal *);
79static _Noreturn void maybe_fatal (int must_succeed, struct terminal *terminal, 79static _Noreturn void maybe_fatal (bool, struct terminal *,
80 const char *str1, const char *str2, ...) 80 const char *, const char *, ...)
81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); 81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
82static _Noreturn void vfatal (const char *str, va_list ap) 82static _Noreturn void vfatal (const char *str, va_list ap)
83 ATTRIBUTE_FORMAT_PRINTF (1, 0); 83 ATTRIBUTE_FORMAT_PRINTF (1, 0);
@@ -85,8 +85,7 @@ static _Noreturn void vfatal (const char *str, va_list ap)
85 85
86#define OUTPUT(tty, a) \ 86#define OUTPUT(tty, a) \
87 emacs_tputs ((tty), a, \ 87 emacs_tputs ((tty), a, \
88 (int) (FRAME_LINES (XFRAME (selected_frame)) \ 88 FRAME_LINES (XFRAME (selected_frame)) - curY (tty), \
89 - curY (tty)), \
90 cmputc) 89 cmputc)
91 90
92#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) 91#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
@@ -695,7 +694,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
695{ 694{
696 unsigned char *conversion_buffer; 695 unsigned char *conversion_buffer;
697 struct coding_system *coding; 696 struct coding_system *coding;
698 size_t n, stringlen; 697 int n, stringlen;
699 698
700 struct tty_display_info *tty = FRAME_TTY (f); 699 struct tty_display_info *tty = FRAME_TTY (f);
701 700
@@ -1431,7 +1430,7 @@ static void append_glyph (struct it *);
1431static void append_composite_glyph (struct it *); 1430static void append_composite_glyph (struct it *);
1432static void produce_composite_glyph (struct it *); 1431static void produce_composite_glyph (struct it *);
1433static void append_glyphless_glyph (struct it *, int, const char *); 1432static void append_glyphless_glyph (struct it *, int, const char *);
1434static void produce_glyphless_glyph (struct it *, int, Lisp_Object); 1433static void produce_glyphless_glyph (struct it *, Lisp_Object);
1435 1434
1436/* Append glyphs to IT's glyph_row. Called from produce_glyphs for 1435/* Append glyphs to IT's glyph_row. Called from produce_glyphs for
1437 terminal frames if IT->glyph_row != NULL. IT->char_to_display is 1436 terminal frames if IT->glyph_row != NULL. IT->char_to_display is
@@ -1551,7 +1550,7 @@ produce_glyphs (struct it *it)
1551 1550
1552 if (it->what == IT_GLYPHLESS) 1551 if (it->what == IT_GLYPHLESS)
1553 { 1552 {
1554 produce_glyphless_glyph (it, 0, Qnil); 1553 produce_glyphless_glyph (it, Qnil);
1555 goto done; 1554 goto done;
1556 } 1555 }
1557 1556
@@ -1620,7 +1619,7 @@ produce_glyphs (struct it *it)
1620 Lisp_Object acronym = lookup_glyphless_char_display (-1, it); 1619 Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
1621 1620
1622 eassert (it->what == IT_GLYPHLESS); 1621 eassert (it->what == IT_GLYPHLESS);
1623 produce_glyphless_glyph (it, 1, acronym); 1622 produce_glyphless_glyph (it, acronym);
1624 } 1623 }
1625 } 1624 }
1626 1625
@@ -1794,14 +1793,12 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1794 the character. See the description of enum 1793 the character. See the description of enum
1795 glyphless_display_method in dispextern.h for the details. 1794 glyphless_display_method in dispextern.h for the details.
1796 1795
1797 FOR_NO_FONT is nonzero if and only if this is for a character that 1796 ACRONYM, if non-nil, is an acronym string for the character.
1798 is not supported by the coding system of the terminal. ACRONYM, if
1799 non-nil, is an acronym string for the character.
1800 1797
1801 The glyphs actually produced are of type CHAR_GLYPH. */ 1798 The glyphs actually produced are of type CHAR_GLYPH. */
1802 1799
1803static void 1800static void
1804produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) 1801produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
1805{ 1802{
1806 int face_id; 1803 int face_id;
1807 int len; 1804 int len;
@@ -1968,7 +1965,7 @@ turn_on_face (struct frame *f, int face_id)
1968 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; 1965 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
1969 if (fg >= 0 && ts) 1966 if (fg >= 0 && ts)
1970 { 1967 {
1971 p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); 1968 p = tparam (ts, NULL, 0, fg, 0, 0, 0);
1972 OUTPUT (tty, p); 1969 OUTPUT (tty, p);
1973 xfree (p); 1970 xfree (p);
1974 } 1971 }
@@ -1976,7 +1973,7 @@ turn_on_face (struct frame *f, int face_id)
1976 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; 1973 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
1977 if (bg >= 0 && ts) 1974 if (bg >= 0 && ts)
1978 { 1975 {
1979 p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); 1976 p = tparam (ts, NULL, 0, bg, 0, 0, 0);
1980 OUTPUT (tty, p); 1977 OUTPUT (tty, p);
1981 xfree (p); 1978 xfree (p);
1982 } 1979 }
@@ -2027,11 +2024,11 @@ turn_off_face (struct frame *f, int face_id)
2027} 2024}
2028 2025
2029 2026
2030/* Return non-zero if the terminal on frame F supports all of the 2027/* Return true if the terminal on frame F supports all of the
2031 capabilities in CAPS simultaneously, with foreground and background 2028 capabilities in CAPS simultaneously, with foreground and background
2032 colors FG and BG. */ 2029 colors FG and BG. */
2033 2030
2034int 2031bool
2035tty_capable_p (struct tty_display_info *tty, unsigned int caps, 2032tty_capable_p (struct tty_display_info *tty, unsigned int caps,
2036 unsigned long fg, unsigned long bg) 2033 unsigned long fg, unsigned long bg)
2037{ 2034{
@@ -2099,7 +2096,7 @@ static char *default_set_background;
2099/* Save or restore the default color-related capabilities of this 2096/* Save or restore the default color-related capabilities of this
2100 terminal. */ 2097 terminal. */
2101static void 2098static void
2102tty_default_color_capabilities (struct tty_display_info *tty, int save) 2099tty_default_color_capabilities (struct tty_display_info *tty, bool save)
2103{ 2100{
2104 2101
2105 if (save) 2102 if (save)
@@ -2209,7 +2206,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
2209/* Return the tty display object specified by TERMINAL. */ 2206/* Return the tty display object specified by TERMINAL. */
2210 2207
2211static struct terminal * 2208static struct terminal *
2212get_tty_terminal (Lisp_Object terminal, int throw) 2209get_tty_terminal (Lisp_Object terminal, bool throw)
2213{ 2210{
2214 struct terminal *t = get_terminal (terminal, throw); 2211 struct terminal *t = get_terminal (terminal, throw);
2215 2212
@@ -2481,7 +2478,7 @@ term_mouse_moveto (int x, int y)
2481 name = (const char *) ttyname (0); 2478 name = (const char *) ttyname (0);
2482 fd = emacs_open (name, O_WRONLY, 0); 2479 fd = emacs_open (name, O_WRONLY, 0);
2483 SOME_FUNCTION (x, y, fd); 2480 SOME_FUNCTION (x, y, fd);
2484 close (fd); 2481 emacs_close (fd);
2485 last_mouse_x = x; 2482 last_mouse_x = x;
2486 last_mouse_y = y; */ 2483 last_mouse_y = y; */
2487} 2484}
@@ -2519,7 +2516,7 @@ tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
2519 cursor_to (f, save_y, save_x); 2516 cursor_to (f, save_y, save_x);
2520} 2517}
2521 2518
2522static int 2519static bool
2523term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) 2520term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2524{ 2521{
2525 /* Has the mouse moved off the glyph it was on at the last sighting? */ 2522 /* Has the mouse moved off the glyph it was on at the last sighting? */
@@ -2649,7 +2646,7 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2649{ 2646{
2650 struct frame *f = XFRAME (tty->top_frame); 2647 struct frame *f = XFRAME (tty->top_frame);
2651 struct input_event ie; 2648 struct input_event ie;
2652 int do_help = 0; 2649 bool do_help = 0;
2653 int count = 0; 2650 int count = 0;
2654 2651
2655 EVENT_INIT (ie); 2652 EVENT_INIT (ie);
@@ -2934,7 +2931,7 @@ dissociate_if_controlling_tty (int fd)
2934 If MUST_SUCCEED is true, then all errors are fatal. */ 2931 If MUST_SUCCEED is true, then all errors are fatal. */
2935 2932
2936struct terminal * 2933struct terminal *
2937init_tty (const char *name, const char *terminal_type, int must_succeed) 2934init_tty (const char *name, const char *terminal_type, bool must_succeed)
2938{ 2935{
2939 char *area = NULL; 2936 char *area = NULL;
2940 char **address = &area; 2937 char **address = &area;
@@ -2942,7 +2939,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
2942 int status; 2939 int status;
2943 struct tty_display_info *tty = NULL; 2940 struct tty_display_info *tty = NULL;
2944 struct terminal *terminal = NULL; 2941 struct terminal *terminal = NULL;
2945 int ctty = 0; /* 1 if asked to open controlling tty. */ 2942 bool ctty = 0; /* True if asked to open controlling tty. */
2946 2943
2947 if (!terminal_type) 2944 if (!terminal_type)
2948 maybe_fatal (must_succeed, 0, 2945 maybe_fatal (must_succeed, 0,
@@ -3015,7 +3012,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3015 name); 3012 name);
3016 if (!isatty (fd)) 3013 if (!isatty (fd))
3017 { 3014 {
3018 close (fd); 3015 emacs_close (fd);
3019 maybe_fatal (must_succeed, terminal, 3016 maybe_fatal (must_succeed, terminal,
3020 "Not a tty device: %s", 3017 "Not a tty device: %s",
3021 "Not a tty device: %s", 3018 "Not a tty device: %s",
@@ -3412,10 +3409,10 @@ vfatal (const char *str, va_list ap)
3412 3409
3413/* Auxiliary error-handling function for init_tty. 3410/* Auxiliary error-handling function for init_tty.
3414 Delete TERMINAL, then call error or fatal with str1 or str2, 3411 Delete TERMINAL, then call error or fatal with str1 or str2,
3415 respectively, according to whether MUST_SUCCEED is zero or not. */ 3412 respectively, according to whether MUST_SUCCEED is true. */
3416 3413
3417static void 3414static void
3418maybe_fatal (int must_succeed, struct terminal *terminal, 3415maybe_fatal (bool must_succeed, struct terminal *terminal,
3419 const char *str1, const char *str2, ...) 3416 const char *str1, const char *str2, ...)
3420{ 3417{
3421 va_list ap; 3418 va_list ap;