aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/src/term.c b/src/term.c
index f082bb40e89..e84bbe125f8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -32,6 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include "lisp.h" 32#include "lisp.h"
33#include "termchar.h" 33#include "termchar.h"
34#include "termopts.h" 34#include "termopts.h"
35#include "tparam.h"
35#include "buffer.h" 36#include "buffer.h"
36#include "character.h" 37#include "character.h"
37#include "charset.h" 38#include "charset.h"
@@ -53,18 +54,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
53static int been_here = -1; 54static int been_here = -1;
54#endif 55#endif
55 56
56/* For now, don't try to include termcap.h. On some systems,
57 configure finds a non-standard termcap.h that the main build
58 won't find. */
59extern void tputs (const char *, int, int (*)(int));
60extern int tgetent (char *, const char *);
61extern int tgetflag (char *id);
62extern int tgetnum (char *id);
63
64char *tparam (char *, char *, int, int, ...);
65
66extern char *tgetstr (char *, char **);
67
68#include "cm.h" 57#include "cm.h"
69#ifdef HAVE_X_WINDOWS 58#ifdef HAVE_X_WINDOWS
70#include "xterm.h" 59#include "xterm.h"
@@ -262,7 +251,7 @@ tty_set_scroll_region (struct frame *f, int start, int stop)
262 struct tty_display_info *tty = FRAME_TTY (f); 251 struct tty_display_info *tty = FRAME_TTY (f);
263 252
264 if (tty->TS_set_scroll_region) 253 if (tty->TS_set_scroll_region)
265 buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); 254 buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0);
266 else if (tty->TS_set_scroll_region_1) 255 else if (tty->TS_set_scroll_region_1)
267 buf = tparam (tty->TS_set_scroll_region_1, 0, 0, 256 buf = tparam (tty->TS_set_scroll_region_1, 0, 0,
268 FRAME_LINES (f), start, 257 FRAME_LINES (f), start,
@@ -544,8 +533,8 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
544 { 533 {
545 if (src->type == COMPOSITE_GLYPH) 534 if (src->type == COMPOSITE_GLYPH)
546 { 535 {
547 struct composition *cmp; 536 struct composition *cmp IF_LINT (= NULL);
548 Lisp_Object gstring; 537 Lisp_Object gstring IF_LINT (= Qnil);
549 int i; 538 int i;
550 539
551 nbytes = buf - encode_terminal_src; 540 nbytes = buf - encode_terminal_src;
@@ -606,7 +595,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
606 else if (! CHAR_GLYPH_PADDING_P (*src)) 595 else if (! CHAR_GLYPH_PADDING_P (*src))
607 { 596 {
608 GLYPH g; 597 GLYPH g;
609 int c; 598 int c IF_LINT (= 0);
610 Lisp_Object string; 599 Lisp_Object string;
611 600
612 string = Qnil; 601 string = Qnil;
@@ -664,8 +653,6 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
664 } 653 }
665 else 654 else
666 { 655 {
667 unsigned char *p = SDATA (string);
668
669 if (! STRING_MULTIBYTE (string)) 656 if (! STRING_MULTIBYTE (string))
670 string = string_to_multibyte (string); 657 string = string_to_multibyte (string);
671 nbytes = buf - encode_terminal_src; 658 nbytes = buf - encode_terminal_src;
@@ -861,7 +848,7 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len)
861 848
862 if (tty->TS_ins_multi_chars) 849 if (tty->TS_ins_multi_chars)
863 { 850 {
864 buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); 851 buf = tparam (tty->TS_ins_multi_chars, 0, 0, len, 0, 0, 0);
865 OUTPUT1 (tty, buf); 852 OUTPUT1 (tty, buf);
866 xfree (buf); 853 xfree (buf);
867 if (start) 854 if (start)
@@ -957,7 +944,7 @@ tty_delete_glyphs (struct frame *f, int n)
957 944
958 if (tty->TS_del_multi_chars) 945 if (tty->TS_del_multi_chars)
959 { 946 {
960 buf = tparam (tty->TS_del_multi_chars, 0, 0, n); 947 buf = tparam (tty->TS_del_multi_chars, 0, 0, n, 0, 0, 0);
961 OUTPUT1 (tty, buf); 948 OUTPUT1 (tty, buf);
962 xfree (buf); 949 xfree (buf);
963 } 950 }
@@ -974,9 +961,10 @@ static void
974tty_ins_del_lines (struct frame *f, int vpos, int n) 961tty_ins_del_lines (struct frame *f, int vpos, int n)
975{ 962{
976 struct tty_display_info *tty = FRAME_TTY (f); 963 struct tty_display_info *tty = FRAME_TTY (f);
977 char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; 964 const char *multi =
978 char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; 965 n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines;
979 char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; 966 const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
967 const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
980 968
981 register int i = n > 0 ? n : -n; 969 register int i = n > 0 ? n : -n;
982 register char *buf; 970 register char *buf;
@@ -999,7 +987,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
999 { 987 {
1000 raw_cursor_to (f, vpos, 0); 988 raw_cursor_to (f, vpos, 0);
1001 tty_background_highlight (tty); 989 tty_background_highlight (tty);
1002 buf = tparam (multi, 0, 0, i); 990 buf = tparam (multi, 0, 0, i, 0, 0, 0);
1003 OUTPUT (tty, buf); 991 OUTPUT (tty, buf);
1004 xfree (buf); 992 xfree (buf);
1005 } 993 }
@@ -1151,9 +1139,9 @@ calculate_costs (struct frame *frame)
1151 if (FRAME_TERMCAP_P (frame)) 1139 if (FRAME_TERMCAP_P (frame))
1152 { 1140 {
1153 struct tty_display_info *tty = FRAME_TTY (frame); 1141 struct tty_display_info *tty = FRAME_TTY (frame);
1154 register char *f = (tty->TS_set_scroll_region 1142 register const char *f = (tty->TS_set_scroll_region
1155 ? tty->TS_set_scroll_region 1143 ? tty->TS_set_scroll_region
1156 : tty->TS_set_scroll_region_1); 1144 : tty->TS_set_scroll_region_1);
1157 1145
1158 FRAME_SCROLL_REGION_COST (frame) = string_cost (f); 1146 FRAME_SCROLL_REGION_COST (frame) = string_cost (f);
1159 1147
@@ -1207,7 +1195,7 @@ calculate_costs (struct frame *frame)
1207} 1195}
1208 1196
1209struct fkey_table { 1197struct fkey_table {
1210 char *cap, *name; 1198 const char *cap, *name;
1211}; 1199};
1212 1200
1213 /* Termcap capability names that correspond directly to X keysyms. 1201 /* Termcap capability names that correspond directly to X keysyms.
@@ -1365,9 +1353,9 @@ term_get_fkeys_1 (void)
1365 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. 1353 "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10.
1366 */ 1354 */
1367 { 1355 {
1368 char *k_semi = tgetstr ("k;", address); 1356 const char *k_semi = tgetstr ("k;", address);
1369 char *k0 = tgetstr ("k0", address); 1357 const char *k0 = tgetstr ("k0", address);
1370 char *k0_name = "f10"; 1358 const char *k0_name = "f10";
1371 1359
1372 if (k_semi) 1360 if (k_semi)
1373 { 1361 {
@@ -1460,7 +1448,7 @@ static void append_glyph (struct it *);
1460static void produce_stretch_glyph (struct it *); 1448static void produce_stretch_glyph (struct it *);
1461static void append_composite_glyph (struct it *); 1449static void append_composite_glyph (struct it *);
1462static void produce_composite_glyph (struct it *); 1450static void produce_composite_glyph (struct it *);
1463static void append_glyphless_glyph (struct it *, int, char *); 1451static void append_glyphless_glyph (struct it *, int, const char *);
1464static void produce_glyphless_glyph (struct it *, int, Lisp_Object); 1452static void produce_glyphless_glyph (struct it *, int, Lisp_Object);
1465 1453
1466/* Append glyphs to IT's glyph_row. Called from produce_glyphs for 1454/* Append glyphs to IT's glyph_row. Called from produce_glyphs for
@@ -1828,7 +1816,7 @@ produce_composite_glyph (struct it *it)
1828 comes from it->nglyphs bytes). */ 1816 comes from it->nglyphs bytes). */
1829 1817
1830static void 1818static void
1831append_glyphless_glyph (struct it *it, int face_id, char *str) 1819append_glyphless_glyph (struct it *it, int face_id, const char *str)
1832{ 1820{
1833 struct glyph *glyph, *end; 1821 struct glyph *glyph, *end;
1834 int i; 1822 int i;
@@ -1903,7 +1891,8 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
1903{ 1891{
1904 int face_id; 1892 int face_id;
1905 int len; 1893 int len;
1906 char buf[9], *str = " "; 1894 char buf[9];
1895 char const *str = " ";
1907 1896
1908 /* Get a face ID for the glyph by utilizing a cache (the same way as 1897 /* Get a face ID for the glyph by utilizing a cache (the same way as
1909 done for `escape-glyph' in get_next_display_element). */ 1898 done for `escape-glyph' in get_next_display_element). */
@@ -2122,12 +2111,13 @@ turn_on_face (struct frame *f, int face_id)
2122 2111
2123 if (tty->TN_max_colors > 0) 2112 if (tty->TN_max_colors > 0)
2124 { 2113 {
2125 char *ts, *p; 2114 const char *ts;
2115 char *p;
2126 2116
2127 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; 2117 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
2128 if (fg >= 0 && ts) 2118 if (fg >= 0 && ts)
2129 { 2119 {
2130 p = tparam (ts, NULL, 0, (int) fg); 2120 p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0);
2131 OUTPUT (tty, p); 2121 OUTPUT (tty, p);
2132 xfree (p); 2122 xfree (p);
2133 } 2123 }
@@ -2135,7 +2125,7 @@ turn_on_face (struct frame *f, int face_id)
2135 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; 2125 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
2136 if (bg >= 0 && ts) 2126 if (bg >= 0 && ts)
2137 { 2127 {
2138 p = tparam (ts, NULL, 0, (int) bg); 2128 p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0);
2139 OUTPUT (tty, p); 2129 OUTPUT (tty, p);
2140 xfree (p); 2130 xfree (p);
2141 } 2131 }
@@ -2698,14 +2688,14 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2698 Set *bar_window to Qnil, and *x and *y to the column and 2688 Set *bar_window to Qnil, and *x and *y to the column and
2699 row of the character cell the mouse is over. 2689 row of the character cell the mouse is over.
2700 2690
2701 Set *time to the time the mouse was at the returned position. 2691 Set *timeptr to the time the mouse was at the returned position.
2702 2692
2703 This clears mouse_moved until the next motion 2693 This clears mouse_moved until the next motion
2704 event arrives. */ 2694 event arrives. */
2705static void 2695static void
2706term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, 2696term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2707 enum scroll_bar_part *part, Lisp_Object *x, 2697 enum scroll_bar_part *part, Lisp_Object *x,
2708 Lisp_Object *y, unsigned long *time) 2698 Lisp_Object *y, unsigned long *timeptr)
2709{ 2699{
2710 struct timeval now; 2700 struct timeval now;
2711 2701
@@ -2718,7 +2708,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2718 XSETINT (*x, last_mouse_x); 2708 XSETINT (*x, last_mouse_x);
2719 XSETINT (*y, last_mouse_y); 2709 XSETINT (*y, last_mouse_y);
2720 gettimeofday(&now, 0); 2710 gettimeofday(&now, 0);
2721 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); 2711 *timeptr = (now.tv_sec * 1000) + (now.tv_usec / 1000);
2722} 2712}
2723 2713
2724/* Prepare a mouse-event in *RESULT for placement in the input queue. 2714/* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -3532,10 +3522,10 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3532 If it were in the termcap entry, it would confuse other programs. */ 3522 If it were in the termcap entry, it would confuse other programs. */
3533 if (!tty->TS_set_window) 3523 if (!tty->TS_set_window)
3534 { 3524 {
3535 p = tty->TS_termcap_modes; 3525 const char *m = tty->TS_termcap_modes;
3536 while (*p && strcmp (p, "\033v ")) 3526 while (*m && strcmp (m, "\033v "))
3537 p++; 3527 m++;
3538 if (*p) 3528 if (*m)
3539 tty->TS_set_window = "\033v%C %C %C %C "; 3529 tty->TS_set_window = "\033v%C %C %C %C ";
3540 } 3530 }
3541 /* Termcap entry often fails to have :in: flag */ 3531 /* Termcap entry often fails to have :in: flag */