comparison src/term.c @ 7835:4d7ce6c03fda v7.4.1214

commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 30 21:10:09 2016 +0100 patch 7.4.1214 Problem: Using old style function declarations. Solution: Change to new style function declarations. (script by Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Sat, 30 Jan 2016 21:15:04 +0100
parents 0b6c37dd858d
children d8a8e86f39ad
comparison
equal deleted inserted replaced
7834:2d1dc9ec41ce 7835:4d7ce6c03fda
1410 #ifdef FEAT_TERMRESPONSE 1410 #ifdef FEAT_TERMRESPONSE
1411 static int check_for_codes = FALSE; /* check for key code response */ 1411 static int check_for_codes = FALSE; /* check for key code response */
1412 #endif 1412 #endif
1413 1413
1414 static struct builtin_term * 1414 static struct builtin_term *
1415 find_builtin_term(term) 1415 find_builtin_term(char_u *term)
1416 char_u *term;
1417 { 1416 {
1418 struct builtin_term *p; 1417 struct builtin_term *p;
1419 1418
1420 p = builtin_termcaps; 1419 p = builtin_termcaps;
1421 while (p->bt_string != NULL) 1420 while (p->bt_string != NULL)
1446 * Parsing of the builtin termcap entries. 1445 * Parsing of the builtin termcap entries.
1447 * Caller should check if 'name' is a valid builtin term. 1446 * Caller should check if 'name' is a valid builtin term.
1448 * The terminal's name is not set, as this is already done in termcapinit(). 1447 * The terminal's name is not set, as this is already done in termcapinit().
1449 */ 1448 */
1450 static void 1449 static void
1451 parse_builtin_tcap(term) 1450 parse_builtin_tcap(char_u *term)
1452 char_u *term;
1453 { 1451 {
1454 struct builtin_term *p; 1452 struct builtin_term *p;
1455 char_u name[2]; 1453 char_u name[2];
1456 int term_8bit; 1454 int term_8bit;
1457 1455
1508 * Set number of colors. 1506 * Set number of colors.
1509 * Store it as a number in t_colors. 1507 * Store it as a number in t_colors.
1510 * Store it as a string in T_CCO (using nr_colors[]). 1508 * Store it as a string in T_CCO (using nr_colors[]).
1511 */ 1509 */
1512 static void 1510 static void
1513 set_color_count(nr) 1511 set_color_count(int nr)
1514 int nr;
1515 { 1512 {
1516 char_u nr_colors[20]; /* string for number of colors */ 1513 char_u nr_colors[20]; /* string for number of colors */
1517 1514
1518 t_colors = nr; 1515 t_colors = nr;
1519 if (t_colors > 1) 1516 if (t_colors > 1)
1546 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. 1543 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise.
1547 * 1544 *
1548 * While doing this, until ttest(), some options may be NULL, be careful. 1545 * While doing this, until ttest(), some options may be NULL, be careful.
1549 */ 1546 */
1550 int 1547 int
1551 set_termname(term) 1548 set_termname(char_u *term)
1552 char_u *term;
1553 { 1549 {
1554 struct builtin_term *termp; 1550 struct builtin_term *termp;
1555 #ifdef HAVE_TGETENT 1551 #ifdef HAVE_TGETENT
1556 int builtin_first = p_tbi; 1552 int builtin_first = p_tbi;
1557 int try; 1553 int try;
2029 static int has_mouse_termcode = 0; 2025 static int has_mouse_termcode = 0;
2030 # endif 2026 # endif
2031 2027
2032 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) 2028 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO)
2033 void 2029 void
2034 set_mouse_termcode(n, s) 2030 set_mouse_termcode(
2035 int n; /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ 2031 int n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
2036 char_u *s; 2032 char_u *s)
2037 { 2033 {
2038 char_u name[2]; 2034 char_u name[2];
2039 2035
2040 name[0] = n; 2036 name[0] = n;
2041 name[1] = KE_FILLER; 2037 name[1] = KE_FILLER;
2077 # endif 2073 # endif
2078 2074
2079 # if ((defined(UNIX) || defined(VMS)) \ 2075 # if ((defined(UNIX) || defined(VMS)) \
2080 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) 2076 && defined(FEAT_MOUSE_TTY)) || defined(PROTO)
2081 void 2077 void
2082 del_mouse_termcode(n) 2078 del_mouse_termcode(
2083 int n; /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ 2079 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
2084 { 2080 {
2085 char_u name[2]; 2081 char_u name[2];
2086 2082
2087 name[0] = n; 2083 name[0] = n;
2088 name[1] = KE_FILLER; 2084 name[1] = KE_FILLER;
2128 /* 2124 /*
2129 * Call tgetent() 2125 * Call tgetent()
2130 * Return error message if it fails, NULL if it's OK. 2126 * Return error message if it fails, NULL if it's OK.
2131 */ 2127 */
2132 static char_u * 2128 static char_u *
2133 tgetent_error(tbuf, term) 2129 tgetent_error(char_u *tbuf, char_u *term)
2134 char_u *tbuf;
2135 char_u *term;
2136 { 2130 {
2137 int i; 2131 int i;
2138 2132
2139 i = TGETENT(tbuf, term); 2133 i = TGETENT(tbuf, term);
2140 if (i < 0 /* -1 is always an error */ 2134 if (i < 0 /* -1 is always an error */
2165 /* 2159 /*
2166 * Some versions of tgetstr() have been reported to return -1 instead of NULL. 2160 * Some versions of tgetstr() have been reported to return -1 instead of NULL.
2167 * Fix that here. 2161 * Fix that here.
2168 */ 2162 */
2169 static char_u * 2163 static char_u *
2170 vim_tgetstr(s, pp) 2164 vim_tgetstr(char *s, char_u **pp)
2171 char *s;
2172 char_u **pp;
2173 { 2165 {
2174 char *p; 2166 char *p;
2175 2167
2176 p = tgetstr(s, (char **)pp); 2168 p = tgetstr(s, (char **)pp);
2177 if (p == (char *)-1) 2169 if (p == (char *)-1)
2186 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" 2178 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co"
2187 * and "li" entries never change. But on some systems this works. 2179 * and "li" entries never change. But on some systems this works.
2188 * Errors while getting the entries are ignored. 2180 * Errors while getting the entries are ignored.
2189 */ 2181 */
2190 void 2182 void
2191 getlinecol(cp, rp) 2183 getlinecol(
2192 long *cp; /* pointer to columns */ 2184 long *cp, /* pointer to columns */
2193 long *rp; /* pointer to rows */ 2185 long *rp) /* pointer to rows */
2194 { 2186 {
2195 char_u tbuf[TBUFSZ]; 2187 char_u tbuf[TBUFSZ];
2196 2188
2197 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) 2189 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL)
2198 { 2190 {
2210 * Give an error message for failure when not sourcing. 2202 * Give an error message for failure when not sourcing.
2211 * If force given, replace an existing entry. 2203 * If force given, replace an existing entry.
2212 * Return FAIL if the entry was not found, OK if the entry was added. 2204 * Return FAIL if the entry was not found, OK if the entry was added.
2213 */ 2205 */
2214 int 2206 int
2215 add_termcap_entry(name, force) 2207 add_termcap_entry(char_u *name, int force)
2216 char_u *name;
2217 int force;
2218 { 2208 {
2219 char_u *term; 2209 char_u *term;
2220 int key; 2210 int key;
2221 struct builtin_term *termp; 2211 struct builtin_term *termp;
2222 #ifdef HAVE_TGETENT 2212 #ifdef HAVE_TGETENT
2319 } 2309 }
2320 return FAIL; 2310 return FAIL;
2321 } 2311 }
2322 2312
2323 static int 2313 static int
2324 term_is_builtin(name) 2314 term_is_builtin(char_u *name)
2325 char_u *name;
2326 { 2315 {
2327 return (STRNCMP(name, "builtin_", (size_t)8) == 0); 2316 return (STRNCMP(name, "builtin_", (size_t)8) == 0);
2328 } 2317 }
2329 2318
2330 /* 2319 /*
2331 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. 2320 * Return TRUE if terminal "name" uses CSI instead of <Esc>[.
2332 * Assume that the terminal is using 8-bit controls when the name contains 2321 * Assume that the terminal is using 8-bit controls when the name contains
2333 * "8bit", like in "xterm-8bit". 2322 * "8bit", like in "xterm-8bit".
2334 */ 2323 */
2335 int 2324 int
2336 term_is_8bit(name) 2325 term_is_8bit(char_u *name)
2337 char_u *name;
2338 { 2326 {
2339 return (detected_8bit || strstr((char *)name, "8bit") != NULL); 2327 return (detected_8bit || strstr((char *)name, "8bit") != NULL);
2340 } 2328 }
2341 2329
2342 /* 2330 /*
2344 * <Esc>[ -> CSI 2332 * <Esc>[ -> CSI
2345 * <Esc>] -> <M-C-]> 2333 * <Esc>] -> <M-C-]>
2346 * <Esc>O -> <M-C-O> 2334 * <Esc>O -> <M-C-O>
2347 */ 2335 */
2348 static int 2336 static int
2349 term_7to8bit(p) 2337 term_7to8bit(char_u *p)
2350 char_u *p;
2351 { 2338 {
2352 if (*p == ESC) 2339 if (*p == ESC)
2353 { 2340 {
2354 if (p[1] == '[') 2341 if (p[1] == '[')
2355 return CSI; 2342 return CSI;
2361 return 0; 2348 return 0;
2362 } 2349 }
2363 2350
2364 #ifdef FEAT_GUI 2351 #ifdef FEAT_GUI
2365 int 2352 int
2366 term_is_gui(name) 2353 term_is_gui(char_u *name)
2367 char_u *name;
2368 { 2354 {
2369 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); 2355 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0);
2370 } 2356 }
2371 #endif 2357 #endif
2372 2358
2373 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) 2359 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO)
2374 2360
2375 char_u * 2361 char_u *
2376 tltoa(i) 2362 tltoa(unsigned long i)
2377 unsigned long i;
2378 { 2363 {
2379 static char_u buf[16]; 2364 static char_u buf[16];
2380 char_u *p; 2365 char_u *p;
2381 2366
2382 p = buf + 15; 2367 p = buf + 15;
2399 * no padding and we only parse for %i %d and %+char 2384 * no padding and we only parse for %i %d and %+char
2400 */ 2385 */
2401 static char *tgoto(char *, int, int); 2386 static char *tgoto(char *, int, int);
2402 2387
2403 static char * 2388 static char *
2404 tgoto(cm, x, y) 2389 tgoto(char *cm, int x, int y)
2405 char *cm;
2406 int x, y;
2407 { 2390 {
2408 static char buf[30]; 2391 static char buf[30];
2409 char *p, *s, *e; 2392 char *p, *s, *e;
2410 2393
2411 if (!cm) 2394 if (!cm)
2451 * Set the terminal name and initialize the terminal options. 2434 * Set the terminal name and initialize the terminal options.
2452 * If "name" is NULL or empty, get the terminal name from the environment. 2435 * If "name" is NULL or empty, get the terminal name from the environment.
2453 * If that fails, use the default terminal name. 2436 * If that fails, use the default terminal name.
2454 */ 2437 */
2455 void 2438 void
2456 termcapinit(name) 2439 termcapinit(char_u *name)
2457 char_u *name;
2458 { 2440 {
2459 char_u *term; 2441 char_u *term;
2460 2442
2461 if (name != NULL && *name == NUL) 2443 if (name != NULL && *name == NUL)
2462 name = NULL; /* empty name is equal to no name */ 2444 name = NULL; /* empty name is equal to no name */
2509 2491
2510 /* 2492 /*
2511 * out_flush(): flush the output buffer 2493 * out_flush(): flush the output buffer
2512 */ 2494 */
2513 void 2495 void
2514 out_flush() 2496 out_flush(void)
2515 { 2497 {
2516 int len; 2498 int len;
2517 2499
2518 if (out_pos != 0) 2500 if (out_pos != 0)
2519 { 2501 {
2528 /* 2510 /*
2529 * Sometimes a byte out of a multi-byte character is written with out_char(). 2511 * Sometimes a byte out of a multi-byte character is written with out_char().
2530 * To avoid flushing half of the character, call this function first. 2512 * To avoid flushing half of the character, call this function first.
2531 */ 2513 */
2532 void 2514 void
2533 out_flush_check() 2515 out_flush_check(void)
2534 { 2516 {
2535 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) 2517 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES)
2536 out_flush(); 2518 out_flush();
2537 } 2519 }
2538 #endif 2520 #endif
2540 #ifdef FEAT_GUI 2522 #ifdef FEAT_GUI
2541 /* 2523 /*
2542 * out_trash(): Throw away the contents of the output buffer 2524 * out_trash(): Throw away the contents of the output buffer
2543 */ 2525 */
2544 void 2526 void
2545 out_trash() 2527 out_trash(void)
2546 { 2528 {
2547 out_pos = 0; 2529 out_pos = 0;
2548 } 2530 }
2549 #endif 2531 #endif
2550 2532
2553 * Flush it if it becomes full. 2535 * Flush it if it becomes full.
2554 * This should not be used for outputting text on the screen (use functions 2536 * This should not be used for outputting text on the screen (use functions
2555 * like msg_puts() and screen_putchar() for that). 2537 * like msg_puts() and screen_putchar() for that).
2556 */ 2538 */
2557 void 2539 void
2558 out_char(c) 2540 out_char(unsigned c)
2559 unsigned c;
2560 { 2541 {
2561 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) 2542 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX)
2562 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ 2543 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
2563 out_char('\r'); 2544 out_char('\r');
2564 #endif 2545 #endif
2574 2555
2575 /* 2556 /*
2576 * out_char_nf(c): like out_char(), but don't flush when p_wd is set 2557 * out_char_nf(c): like out_char(), but don't flush when p_wd is set
2577 */ 2558 */
2578 static void 2559 static void
2579 out_char_nf(c) 2560 out_char_nf(unsigned c)
2580 unsigned c;
2581 { 2561 {
2582 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) 2562 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX)
2583 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ 2563 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
2584 out_char_nf('\r'); 2564 out_char_nf('\r');
2585 #endif 2565 #endif
2600 * information, and "%i", "%d", etc. 2580 * information, and "%i", "%d", etc.
2601 * This should only be used for writing terminal codes, not for outputting 2581 * This should only be used for writing terminal codes, not for outputting
2602 * normal text (use functions like msg_puts() and screen_putchar() for that). 2582 * normal text (use functions like msg_puts() and screen_putchar() for that).
2603 */ 2583 */
2604 void 2584 void
2605 out_str_nf(s) 2585 out_str_nf(char_u *s)
2606 char_u *s;
2607 { 2586 {
2608 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ 2587 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */
2609 out_flush(); 2588 out_flush();
2610 while (*s) 2589 while (*s)
2611 out_char_nf(*s++); 2590 out_char_nf(*s++);
2621 * If HAVE_TGETENT is defined use the termcap parser. (jw) 2600 * If HAVE_TGETENT is defined use the termcap parser. (jw)
2622 * This should only be used for writing terminal codes, not for outputting 2601 * This should only be used for writing terminal codes, not for outputting
2623 * normal text (use functions like msg_puts() and screen_putchar() for that). 2602 * normal text (use functions like msg_puts() and screen_putchar() for that).
2624 */ 2603 */
2625 void 2604 void
2626 out_str(s) 2605 out_str(char_u *s)
2627 char_u *s;
2628 { 2606 {
2629 if (s != NULL && *s) 2607 if (s != NULL && *s)
2630 { 2608 {
2631 #ifdef FEAT_GUI 2609 #ifdef FEAT_GUI
2632 /* Don't use tputs() when GUI is used, ncurses crashes. */ 2610 /* Don't use tputs() when GUI is used, ncurses crashes. */
2654 2632
2655 /* 2633 /*
2656 * cursor positioning using termcap parser. (jw) 2634 * cursor positioning using termcap parser. (jw)
2657 */ 2635 */
2658 void 2636 void
2659 term_windgoto(row, col) 2637 term_windgoto(int row, int col)
2660 int row;
2661 int col;
2662 { 2638 {
2663 OUT_STR(tgoto((char *)T_CM, col, row)); 2639 OUT_STR(tgoto((char *)T_CM, col, row));
2664 } 2640 }
2665 2641
2666 void 2642 void
2667 term_cursor_right(i) 2643 term_cursor_right(int i)
2668 int i;
2669 { 2644 {
2670 OUT_STR(tgoto((char *)T_CRI, 0, i)); 2645 OUT_STR(tgoto((char *)T_CRI, 0, i));
2671 } 2646 }
2672 2647
2673 void 2648 void
2674 term_append_lines(line_count) 2649 term_append_lines(int line_count)
2675 int line_count;
2676 { 2650 {
2677 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); 2651 OUT_STR(tgoto((char *)T_CAL, 0, line_count));
2678 } 2652 }
2679 2653
2680 void 2654 void
2681 term_delete_lines(line_count) 2655 term_delete_lines(int line_count)
2682 int line_count;
2683 { 2656 {
2684 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); 2657 OUT_STR(tgoto((char *)T_CDL, 0, line_count));
2685 } 2658 }
2686 2659
2687 #if defined(HAVE_TGETENT) || defined(PROTO) 2660 #if defined(HAVE_TGETENT) || defined(PROTO)
2688 void 2661 void
2689 term_set_winpos(x, y) 2662 term_set_winpos(int x, int y)
2690 int x;
2691 int y;
2692 { 2663 {
2693 /* Can't handle a negative value here */ 2664 /* Can't handle a negative value here */
2694 if (x < 0) 2665 if (x < 0)
2695 x = 0; 2666 x = 0;
2696 if (y < 0) 2667 if (y < 0)
2697 y = 0; 2668 y = 0;
2698 OUT_STR(tgoto((char *)T_CWP, y, x)); 2669 OUT_STR(tgoto((char *)T_CWP, y, x));
2699 } 2670 }
2700 2671
2701 void 2672 void
2702 term_set_winsize(width, height) 2673 term_set_winsize(int width, int height)
2703 int width;
2704 int height;
2705 { 2674 {
2706 OUT_STR(tgoto((char *)T_CWS, height, width)); 2675 OUT_STR(tgoto((char *)T_CWS, height, width));
2707 } 2676 }
2708 #endif 2677 #endif
2709 2678
2710 void 2679 void
2711 term_fg_color(n) 2680 term_fg_color(int n)
2712 int n;
2713 { 2681 {
2714 /* Use "AF" termcap entry if present, "Sf" entry otherwise */ 2682 /* Use "AF" termcap entry if present, "Sf" entry otherwise */
2715 if (*T_CAF) 2683 if (*T_CAF)
2716 term_color(T_CAF, n); 2684 term_color(T_CAF, n);
2717 else if (*T_CSF) 2685 else if (*T_CSF)
2718 term_color(T_CSF, n); 2686 term_color(T_CSF, n);
2719 } 2687 }
2720 2688
2721 void 2689 void
2722 term_bg_color(n) 2690 term_bg_color(int n)
2723 int n;
2724 { 2691 {
2725 /* Use "AB" termcap entry if present, "Sb" entry otherwise */ 2692 /* Use "AB" termcap entry if present, "Sb" entry otherwise */
2726 if (*T_CAB) 2693 if (*T_CAB)
2727 term_color(T_CAB, n); 2694 term_color(T_CAB, n);
2728 else if (*T_CSB) 2695 else if (*T_CSB)
2729 term_color(T_CSB, n); 2696 term_color(T_CSB, n);
2730 } 2697 }
2731 2698
2732 static void 2699 static void
2733 term_color(s, n) 2700 term_color(char_u *s, int n)
2734 char_u *s;
2735 int n;
2736 { 2701 {
2737 char buf[20]; 2702 char buf[20];
2738 int i = 2; /* index in s[] just after <Esc>[ or CSI */ 2703 int i = 2; /* index in s[] just after <Esc>[ or CSI */
2739 2704
2740 /* Special handling of 16 colors, because termcap can't handle it */ 2705 /* Special handling of 16 colors, because termcap can't handle it */
2766 || defined(MACOS_X))) || defined(PROTO) 2731 || defined(MACOS_X))) || defined(PROTO)
2767 /* 2732 /*
2768 * Generic function to set window title, using t_ts and t_fs. 2733 * Generic function to set window title, using t_ts and t_fs.
2769 */ 2734 */
2770 void 2735 void
2771 term_settitle(title) 2736 term_settitle(char_u *title)
2772 char_u *title;
2773 { 2737 {
2774 /* t_ts takes one argument: column in status line */ 2738 /* t_ts takes one argument: column in status line */
2775 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ 2739 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */
2776 out_str_nf(title); 2740 out_str_nf(title);
2777 out_str(T_FS); /* set title end */ 2741 out_str(T_FS); /* set title end */
2782 /* 2746 /*
2783 * Make sure we have a valid set or terminal options. 2747 * Make sure we have a valid set or terminal options.
2784 * Replace all entries that are NULL by empty_option 2748 * Replace all entries that are NULL by empty_option
2785 */ 2749 */
2786 void 2750 void
2787 ttest(pairs) 2751 ttest(int pairs)
2788 int pairs;
2789 { 2752 {
2790 check_options(); /* make sure no options are NULL */ 2753 check_options(); /* make sure no options are NULL */
2791 2754
2792 /* 2755 /*
2793 * MUST have "cm": cursor motion. 2756 * MUST have "cm": cursor motion.
2882 /* 2845 /*
2883 * Represent the given long_u as individual bytes, with the most significant 2846 * Represent the given long_u as individual bytes, with the most significant
2884 * byte first, and store them in dst. 2847 * byte first, and store them in dst.
2885 */ 2848 */
2886 void 2849 void
2887 add_long_to_buf(val, dst) 2850 add_long_to_buf(long_u val, char_u *dst)
2888 long_u val;
2889 char_u *dst;
2890 { 2851 {
2891 int i; 2852 int i;
2892 int shift; 2853 int shift;
2893 2854
2894 for (i = 1; i <= (int)sizeof(long_u); i++) 2855 for (i = 1; i <= (int)sizeof(long_u); i++)
2907 * Puts result in val, and returns the number of bytes read from buf 2868 * Puts result in val, and returns the number of bytes read from buf
2908 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes 2869 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes
2909 * were present. 2870 * were present.
2910 */ 2871 */
2911 static int 2872 static int
2912 get_long_from_buf(buf, val) 2873 get_long_from_buf(char_u *buf, long_u *val)
2913 char_u *buf;
2914 long_u *val;
2915 { 2874 {
2916 int len; 2875 int len;
2917 char_u bytes[sizeof(long_u)]; 2876 char_u bytes[sizeof(long_u)];
2918 int i; 2877 int i;
2919 int shift; 2878 int shift;
2940 * that buf has been through inchar(). Returns the actual number of bytes used 2899 * that buf has been through inchar(). Returns the actual number of bytes used
2941 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were 2900 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were
2942 * available. 2901 * available.
2943 */ 2902 */
2944 static int 2903 static int
2945 get_bytes_from_buf(buf, bytes, num_bytes) 2904 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes)
2946 char_u *buf;
2947 char_u *bytes;
2948 int num_bytes;
2949 { 2905 {
2950 int len = 0; 2906 int len = 0;
2951 int i; 2907 int i;
2952 char_u c; 2908 char_u c;
2953 2909
2980 /* 2936 /*
2981 * Check if the new shell size is valid, correct it if it's too small or way 2937 * Check if the new shell size is valid, correct it if it's too small or way
2982 * too big. 2938 * too big.
2983 */ 2939 */
2984 void 2940 void
2985 check_shellsize() 2941 check_shellsize(void)
2986 { 2942 {
2987 if (Rows < min_rows()) /* need room for one window and command line */ 2943 if (Rows < min_rows()) /* need room for one window and command line */
2988 Rows = min_rows(); 2944 Rows = min_rows();
2989 limit_screen_size(); 2945 limit_screen_size();
2990 } 2946 }
2991 2947
2992 /* 2948 /*
2993 * Limit Rows and Columns to avoid an overflow in Rows * Columns. 2949 * Limit Rows and Columns to avoid an overflow in Rows * Columns.
2994 */ 2950 */
2995 void 2951 void
2996 limit_screen_size() 2952 limit_screen_size(void)
2997 { 2953 {
2998 if (Columns < MIN_COLUMNS) 2954 if (Columns < MIN_COLUMNS)
2999 Columns = MIN_COLUMNS; 2955 Columns = MIN_COLUMNS;
3000 else if (Columns > 10000) 2956 else if (Columns > 10000)
3001 Columns = 10000; 2957 Columns = 10000;
3005 2961
3006 /* 2962 /*
3007 * Invoked just before the screen structures are going to be (re)allocated. 2963 * Invoked just before the screen structures are going to be (re)allocated.
3008 */ 2964 */
3009 void 2965 void
3010 win_new_shellsize() 2966 win_new_shellsize(void)
3011 { 2967 {
3012 static int old_Rows = 0; 2968 static int old_Rows = 0;
3013 static int old_Columns = 0; 2969 static int old_Columns = 0;
3014 2970
3015 if (old_Rows != Rows || old_Columns != Columns) 2971 if (old_Rows != Rows || old_Columns != Columns)
3034 /* 2990 /*
3035 * Call this function when the Vim shell has been resized in any way. 2991 * Call this function when the Vim shell has been resized in any way.
3036 * Will obtain the current size and redraw (also when size didn't change). 2992 * Will obtain the current size and redraw (also when size didn't change).
3037 */ 2993 */
3038 void 2994 void
3039 shell_resized() 2995 shell_resized(void)
3040 { 2996 {
3041 set_shellsize(0, 0, FALSE); 2997 set_shellsize(0, 0, FALSE);
3042 } 2998 }
3043 2999
3044 /* 3000 /*
3045 * Check if the shell size changed. Handle a resize. 3001 * Check if the shell size changed. Handle a resize.
3046 * When the size didn't change, nothing happens. 3002 * When the size didn't change, nothing happens.
3047 */ 3003 */
3048 void 3004 void
3049 shell_resized_check() 3005 shell_resized_check(void)
3050 { 3006 {
3051 int old_Rows = Rows; 3007 int old_Rows = Rows;
3052 int old_Columns = Columns; 3008 int old_Columns = Columns;
3053 3009
3054 if (!exiting 3010 if (!exiting
3072 * window size (this is used for the :win command). 3028 * window size (this is used for the :win command).
3073 * If 'mustset' is FALSE, we may try to get the real window size and if 3029 * If 'mustset' is FALSE, we may try to get the real window size and if
3074 * it fails use 'width' and 'height'. 3030 * it fails use 'width' and 'height'.
3075 */ 3031 */
3076 void 3032 void
3077 set_shellsize(width, height, mustset) 3033 set_shellsize(int width, int height, int mustset)
3078 int width, height;
3079 int mustset;
3080 { 3034 {
3081 static int busy = FALSE; 3035 static int busy = FALSE;
3082 3036
3083 /* 3037 /*
3084 * Avoid recursiveness, can happen when setting the window size causes 3038 * Avoid recursiveness, can happen when setting the window size causes
3190 /* 3144 /*
3191 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external 3145 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external
3192 * commands and Ex mode). 3146 * commands and Ex mode).
3193 */ 3147 */
3194 void 3148 void
3195 settmode(tmode) 3149 settmode(int tmode)
3196 int tmode;
3197 { 3150 {
3198 #ifdef FEAT_GUI 3151 #ifdef FEAT_GUI
3199 /* don't set the term where gvim was started to any mode */ 3152 /* don't set the term where gvim was started to any mode */
3200 if (gui.in_use) 3153 if (gui.in_use)
3201 return; 3154 return;
3246 #endif 3199 #endif
3247 } 3200 }
3248 } 3201 }
3249 3202
3250 void 3203 void
3251 starttermcap() 3204 starttermcap(void)
3252 { 3205 {
3253 if (full_screen && !termcap_active) 3206 if (full_screen && !termcap_active)
3254 { 3207 {
3255 out_str(T_TI); /* start termcap mode */ 3208 out_str(T_TI); /* start termcap mode */
3256 out_str(T_KS); /* start "keypad transmit" mode */ 3209 out_str(T_KS); /* start "keypad transmit" mode */
3271 #endif 3224 #endif
3272 } 3225 }
3273 } 3226 }
3274 3227
3275 void 3228 void
3276 stoptermcap() 3229 stoptermcap(void)
3277 { 3230 {
3278 screen_stop_highlight(); 3231 screen_stop_highlight();
3279 reset_cterm_colors(); 3232 reset_cterm_colors();
3280 if (termcap_active) 3233 if (termcap_active)
3281 { 3234 {
3327 * On Unix only do it when both output and input are a tty (avoid writing 3280 * On Unix only do it when both output and input are a tty (avoid writing
3328 * request to terminal while reading from a file). 3281 * request to terminal while reading from a file).
3329 * The result is caught in check_termcode(). 3282 * The result is caught in check_termcode().
3330 */ 3283 */
3331 void 3284 void
3332 may_req_termresponse() 3285 may_req_termresponse(void)
3333 { 3286 {
3334 if (crv_status == CRV_GET 3287 if (crv_status == CRV_GET
3335 && cur_tmode == TMODE_RAW 3288 && cur_tmode == TMODE_RAW
3336 && starting == 0 3289 && starting == 0
3337 && termcap_active 3290 && termcap_active
3361 * or if it is treated as double width, that will be (1, 2). 3314 * or if it is treated as double width, that will be (1, 2).
3362 * This function has the side effect that changes cursor position, so 3315 * This function has the side effect that changes cursor position, so
3363 * it must be called immediately after entering termcap mode. 3316 * it must be called immediately after entering termcap mode.
3364 */ 3317 */
3365 void 3318 void
3366 may_req_ambiguous_char_width() 3319 may_req_ambiguous_char_width(void)
3367 { 3320 {
3368 if (u7_status == U7_GET 3321 if (u7_status == U7_GET
3369 && cur_tmode == TMODE_RAW 3322 && cur_tmode == TMODE_RAW
3370 && termcap_active 3323 && termcap_active
3371 && p_ek 3324 && p_ek
3402 /* 3355 /*
3403 * Similar to requesting the version string: Request the terminal background 3356 * Similar to requesting the version string: Request the terminal background
3404 * color when it is the right moment. 3357 * color when it is the right moment.
3405 */ 3358 */
3406 void 3359 void
3407 may_req_bg_color() 3360 may_req_bg_color(void)
3408 { 3361 {
3409 if (rbg_status == RBG_GET 3362 if (rbg_status == RBG_GET
3410 && cur_tmode == TMODE_RAW 3363 && cur_tmode == TMODE_RAW
3411 && termcap_active 3364 && termcap_active
3412 && p_ek 3365 && p_ek
3454 3407
3455 /* 3408 /*
3456 * Return TRUE when saving and restoring the screen. 3409 * Return TRUE when saving and restoring the screen.
3457 */ 3410 */
3458 int 3411 int
3459 swapping_screen() 3412 swapping_screen(void)
3460 { 3413 {
3461 return (full_screen && *T_TI != NUL); 3414 return (full_screen && *T_TI != NUL);
3462 } 3415 }
3463 3416
3464 #ifdef FEAT_MOUSE 3417 #ifdef FEAT_MOUSE
3465 /* 3418 /*
3466 * setmouse() - switch mouse on/off depending on current mode and 'mouse' 3419 * setmouse() - switch mouse on/off depending on current mode and 'mouse'
3467 */ 3420 */
3468 void 3421 void
3469 setmouse() 3422 setmouse(void)
3470 { 3423 {
3471 # ifdef FEAT_MOUSE_TTY 3424 # ifdef FEAT_MOUSE_TTY
3472 int checkfor; 3425 int checkfor;
3473 # endif 3426 # endif
3474 3427
3519 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or 3472 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or
3520 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a 3473 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a
3521 * normal editing mode (not at hit-return message). 3474 * normal editing mode (not at hit-return message).
3522 */ 3475 */
3523 int 3476 int
3524 mouse_has(c) 3477 mouse_has(int c)
3525 int c;
3526 { 3478 {
3527 char_u *p; 3479 char_u *p;
3528 3480
3529 for (p = p_mouse; *p; ++p) 3481 for (p = p_mouse; *p; ++p)
3530 switch (*p) 3482 switch (*p)
3542 3494
3543 /* 3495 /*
3544 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". 3496 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
3545 */ 3497 */
3546 int 3498 int
3547 mouse_model_popup() 3499 mouse_model_popup(void)
3548 { 3500 {
3549 return (p_mousem[0] == 'p'); 3501 return (p_mousem[0] == 'p');
3550 } 3502 }
3551 #endif 3503 #endif
3552 3504
3554 * By outputting the 'cursor very visible' termcap code, for some windowed 3506 * By outputting the 'cursor very visible' termcap code, for some windowed
3555 * terminals this makes the screen scrolled to the correct position. 3507 * terminals this makes the screen scrolled to the correct position.
3556 * Used when starting Vim or returning from a shell. 3508 * Used when starting Vim or returning from a shell.
3557 */ 3509 */
3558 void 3510 void
3559 scroll_start() 3511 scroll_start(void)
3560 { 3512 {
3561 if (*T_VS != NUL) 3513 if (*T_VS != NUL)
3562 { 3514 {
3563 out_str(T_VS); 3515 out_str(T_VS);
3564 out_str(T_VE); 3516 out_str(T_VE);
3570 3522
3571 /* 3523 /*
3572 * Enable the cursor. 3524 * Enable the cursor.
3573 */ 3525 */
3574 void 3526 void
3575 cursor_on() 3527 cursor_on(void)
3576 { 3528 {
3577 if (cursor_is_off) 3529 if (cursor_is_off)
3578 { 3530 {
3579 out_str(T_VE); 3531 out_str(T_VE);
3580 cursor_is_off = FALSE; 3532 cursor_is_off = FALSE;
3583 3535
3584 /* 3536 /*
3585 * Disable the cursor. 3537 * Disable the cursor.
3586 */ 3538 */
3587 void 3539 void
3588 cursor_off() 3540 cursor_off(void)
3589 { 3541 {
3590 if (full_screen) 3542 if (full_screen)
3591 { 3543 {
3592 if (!cursor_is_off) 3544 if (!cursor_is_off)
3593 out_str(T_VI); /* disable cursor */ 3545 out_str(T_VI); /* disable cursor */
3598 #if defined(CURSOR_SHAPE) || defined(PROTO) 3550 #if defined(CURSOR_SHAPE) || defined(PROTO)
3599 /* 3551 /*
3600 * Set cursor shape to match Insert or Replace mode. 3552 * Set cursor shape to match Insert or Replace mode.
3601 */ 3553 */
3602 void 3554 void
3603 term_cursor_shape() 3555 term_cursor_shape(void)
3604 { 3556 {
3605 static int showing_mode = NORMAL; 3557 static int showing_mode = NORMAL;
3606 char_u *p; 3558 char_u *p;
3607 3559
3608 /* Only do something when redrawing the screen and we can restore the 3560 /* Only do something when redrawing the screen and we can restore the
3646 * The region starts 'off' lines from the start of the window. 3598 * The region starts 'off' lines from the start of the window.
3647 * Also set the vertical scroll region for a vertically split window. Always 3599 * Also set the vertical scroll region for a vertically split window. Always
3648 * the full width of the window, excluding the vertical separator. 3600 * the full width of the window, excluding the vertical separator.
3649 */ 3601 */
3650 void 3602 void
3651 scroll_region_set(wp, off) 3603 scroll_region_set(win_T *wp, int off)
3652 win_T *wp;
3653 int off;
3654 { 3604 {
3655 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, 3605 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1,
3656 W_WINROW(wp) + off)); 3606 W_WINROW(wp) + off));
3657 #ifdef FEAT_VERTSPLIT 3607 #ifdef FEAT_VERTSPLIT
3658 if (*T_CSV != NUL && wp->w_width != Columns) 3608 if (*T_CSV != NUL && wp->w_width != Columns)
3664 3614
3665 /* 3615 /*
3666 * Reset scrolling region to the whole screen. 3616 * Reset scrolling region to the whole screen.
3667 */ 3617 */
3668 void 3618 void
3669 scroll_region_reset() 3619 scroll_region_reset(void)
3670 { 3620 {
3671 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); 3621 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0));
3672 #ifdef FEAT_VERTSPLIT 3622 #ifdef FEAT_VERTSPLIT
3673 if (*T_CSV != NUL) 3623 if (*T_CSV != NUL)
3674 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); 3624 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0));
3693 static int tc_len = 0; /* current number of entries in termcodes[] */ 3643 static int tc_len = 0; /* current number of entries in termcodes[] */
3694 3644
3695 static int termcode_star(char_u *code, int len); 3645 static int termcode_star(char_u *code, int len);
3696 3646
3697 void 3647 void
3698 clear_termcodes() 3648 clear_termcodes(void)
3699 { 3649 {
3700 while (tc_len > 0) 3650 while (tc_len > 0)
3701 vim_free(termcodes[--tc_len].code); 3651 vim_free(termcodes[--tc_len].code);
3702 vim_free(termcodes); 3652 vim_free(termcodes);
3703 termcodes = NULL; 3653 termcodes = NULL;
3720 * The list is kept alphabetical for ":set termcap" 3670 * The list is kept alphabetical for ":set termcap"
3721 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. 3671 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired.
3722 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). 3672 * "flags" can also be ATC_FROM_TERM for got_code_from_term().
3723 */ 3673 */
3724 void 3674 void
3725 add_termcode(name, string, flags) 3675 add_termcode(char_u *name, char_u *string, int flags)
3726 char_u *name;
3727 char_u *string;
3728 int flags;
3729 { 3676 {
3730 struct termcode *new_tc; 3677 struct termcode *new_tc;
3731 int i, j; 3678 int i, j;
3732 char_u *s; 3679 char_u *s;
3733 int len; 3680 int len;
3852 * Check termcode "code[len]" for ending in ;*X, <Esc>O*X or <M-O>*X. 3799 * Check termcode "code[len]" for ending in ;*X, <Esc>O*X or <M-O>*X.
3853 * The "X" can be any character. 3800 * The "X" can be any character.
3854 * Return 0 if not found, 2 for ;*X and 1 for O*X and <M-O>*X. 3801 * Return 0 if not found, 2 for ;*X and 1 for O*X and <M-O>*X.
3855 */ 3802 */
3856 static int 3803 static int
3857 termcode_star(code, len) 3804 termcode_star(char_u *code, int len)
3858 char_u *code;
3859 int len;
3860 { 3805 {
3861 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ 3806 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */
3862 if (len >= 3 && code[len - 2] == '*') 3807 if (len >= 3 && code[len - 2] == '*')
3863 { 3808 {
3864 if (len >= 5 && code[len - 3] == ';') 3809 if (len >= 5 && code[len - 3] == ';')
3868 } 3813 }
3869 return 0; 3814 return 0;
3870 } 3815 }
3871 3816
3872 char_u * 3817 char_u *
3873 find_termcode(name) 3818 find_termcode(char_u *name)
3874 char_u *name;
3875 { 3819 {
3876 int i; 3820 int i;
3877 3821
3878 for (i = 0; i < tc_len; ++i) 3822 for (i = 0; i < tc_len; ++i)
3879 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) 3823 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1])
3881 return NULL; 3825 return NULL;
3882 } 3826 }
3883 3827
3884 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 3828 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
3885 char_u * 3829 char_u *
3886 get_termcode(i) 3830 get_termcode(int i)
3887 int i;
3888 { 3831 {
3889 if (i >= tc_len) 3832 if (i >= tc_len)
3890 return NULL; 3833 return NULL;
3891 return &termcodes[i].name[0]; 3834 return &termcodes[i].name[0];
3892 } 3835 }
3893 #endif 3836 #endif
3894 3837
3895 void 3838 void
3896 del_termcode(name) 3839 del_termcode(char_u *name)
3897 char_u *name;
3898 { 3840 {
3899 int i; 3841 int i;
3900 3842
3901 if (termcodes == NULL) /* nothing there yet */ 3843 if (termcodes == NULL) /* nothing there yet */
3902 return; 3844 return;
3911 } 3853 }
3912 /* not found. Give error message? */ 3854 /* not found. Give error message? */
3913 } 3855 }
3914 3856
3915 static void 3857 static void
3916 del_termcode_idx(idx) 3858 del_termcode_idx(int idx)
3917 int idx;
3918 { 3859 {
3919 int i; 3860 int i;
3920 3861
3921 vim_free(termcodes[idx].code); 3862 vim_free(termcodes[idx].code);
3922 --tc_len; 3863 --tc_len;
3928 /* 3869 /*
3929 * Called when detected that the terminal sends 8-bit codes. 3870 * Called when detected that the terminal sends 8-bit codes.
3930 * Convert all 7-bit codes to their 8-bit equivalent. 3871 * Convert all 7-bit codes to their 8-bit equivalent.
3931 */ 3872 */
3932 static void 3873 static void
3933 switch_to_8bit() 3874 switch_to_8bit(void)
3934 { 3875 {
3935 int i; 3876 int i;
3936 int c; 3877 int c;
3937 3878
3938 /* Only need to do something when not already using 8-bit codes. */ 3879 /* Only need to do something when not already using 8-bit codes. */
3969 /* 3910 /*
3970 * Set orig_topline. Used when jumping to another window, so that a double 3911 * Set orig_topline. Used when jumping to another window, so that a double
3971 * click still works. 3912 * click still works.
3972 */ 3913 */
3973 void 3914 void
3974 set_mouse_topline(wp) 3915 set_mouse_topline(win_T *wp)
3975 win_T *wp;
3976 { 3916 {
3977 orig_topline = wp->w_topline; 3917 orig_topline = wp->w_topline;
3978 # ifdef FEAT_DIFF 3918 # ifdef FEAT_DIFF
3979 orig_topfill = wp->w_topfill; 3919 orig_topfill = wp->w_topfill;
3980 # endif 3920 # endif
3993 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. 3933 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[].
3994 * "buflen" is then the length of the string in buf[] and is updated for 3934 * "buflen" is then the length of the string in buf[] and is updated for
3995 * inserts and deletes. 3935 * inserts and deletes.
3996 */ 3936 */
3997 int 3937 int
3998 check_termcode(max_offset, buf, bufsize, buflen) 3938 check_termcode(
3999 int max_offset; 3939 int max_offset,
4000 char_u *buf; 3940 char_u *buf,
4001 int bufsize; 3941 int bufsize,
4002 int *buflen; 3942 int *buflen)
4003 { 3943 {
4004 char_u *tp; 3944 char_u *tp;
4005 char_u *p; 3945 char_u *p;
4006 int slen = 0; /* init for GCC */ 3946 int slen = 0; /* init for GCC */
4007 int modslen; 3947 int modslen;
5457 * is included, otherwise it is removed (for ":map xx ^V", maps xx to 5397 * is included, otherwise it is removed (for ":map xx ^V", maps xx to
5458 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used 5398 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used
5459 * instead of a CTRL-V. 5399 * instead of a CTRL-V.
5460 */ 5400 */
5461 char_u * 5401 char_u *
5462 replace_termcodes(from, bufp, from_part, do_lt, special) 5402 replace_termcodes(
5463 char_u *from; 5403 char_u *from,
5464 char_u **bufp; 5404 char_u **bufp,
5465 int from_part; 5405 int from_part,
5466 int do_lt; /* also translate <lt> */ 5406 int do_lt, /* also translate <lt> */
5467 int special; /* always accept <key> notation */ 5407 int special) /* always accept <key> notation */
5468 { 5408 {
5469 int i; 5409 int i;
5470 int slen; 5410 int slen;
5471 int key; 5411 int key;
5472 int dlen = 0; 5412 int dlen = 0;
5671 /* 5611 /*
5672 * Find a termcode with keys 'src' (must be NUL terminated). 5612 * Find a termcode with keys 'src' (must be NUL terminated).
5673 * Return the index in termcodes[], or -1 if not found. 5613 * Return the index in termcodes[], or -1 if not found.
5674 */ 5614 */
5675 int 5615 int
5676 find_term_bykeys(src) 5616 find_term_bykeys(char_u *src)
5677 char_u *src;
5678 { 5617 {
5679 int i; 5618 int i;
5680 int slen = (int)STRLEN(src); 5619 int slen = (int)STRLEN(src);
5681 5620
5682 for (i = 0; i < tc_len; ++i) 5621 for (i = 0; i < tc_len; ++i)
5691 /* 5630 /*
5692 * Gather the first characters in the terminal key codes into a string. 5631 * Gather the first characters in the terminal key codes into a string.
5693 * Used to speed up check_termcode(). 5632 * Used to speed up check_termcode().
5694 */ 5633 */
5695 static void 5634 static void
5696 gather_termleader() 5635 gather_termleader(void)
5697 { 5636 {
5698 int i; 5637 int i;
5699 int len = 0; 5638 int len = 0;
5700 5639
5701 #ifdef FEAT_GUI 5640 #ifdef FEAT_GUI
5722 /* 5661 /*
5723 * Show all termcodes (for ":set termcap") 5662 * Show all termcodes (for ":set termcap")
5724 * This code looks a lot like showoptions(), but is different. 5663 * This code looks a lot like showoptions(), but is different.
5725 */ 5664 */
5726 void 5665 void
5727 show_termcodes() 5666 show_termcodes(void)
5728 { 5667 {
5729 int col; 5668 int col;
5730 int *items; 5669 int *items;
5731 int item_count; 5670 int item_count;
5732 int run; 5671 int run;
5808 /* 5747 /*
5809 * Show one termcode entry. 5748 * Show one termcode entry.
5810 * Output goes into IObuff[] 5749 * Output goes into IObuff[]
5811 */ 5750 */
5812 int 5751 int
5813 show_one_termcode(name, code, printit) 5752 show_one_termcode(char_u *name, char_u *code, int printit)
5814 char_u *name;
5815 char_u *code;
5816 int printit;
5817 { 5753 {
5818 char_u *p; 5754 char_u *p;
5819 int len; 5755 int len;
5820 5756
5821 if (name[0] > '~') 5757 if (name[0] > '~')
5868 */ 5804 */
5869 static int xt_index_in = 0; 5805 static int xt_index_in = 0;
5870 static int xt_index_out = 0; 5806 static int xt_index_out = 0;
5871 5807
5872 static void 5808 static void
5873 req_codes_from_term() 5809 req_codes_from_term(void)
5874 { 5810 {
5875 xt_index_out = 0; 5811 xt_index_out = 0;
5876 xt_index_in = 0; 5812 xt_index_in = 0;
5877 req_more_codes_from_term(); 5813 req_more_codes_from_term();
5878 } 5814 }
5879 5815
5880 static void 5816 static void
5881 req_more_codes_from_term() 5817 req_more_codes_from_term(void)
5882 { 5818 {
5883 char buf[11]; 5819 char buf[11];
5884 int old_idx = xt_index_out; 5820 int old_idx = xt_index_out;
5885 5821
5886 /* Don't do anything when going to exit. */ 5822 /* Don't do anything when going to exit. */
5914 * A "0" instead of the "1" indicates a code that isn't supported. 5850 * A "0" instead of the "1" indicates a code that isn't supported.
5915 * Both <name> and <string> are encoded in hex. 5851 * Both <name> and <string> are encoded in hex.
5916 * "code" points to the "0" or "1". 5852 * "code" points to the "0" or "1".
5917 */ 5853 */
5918 static void 5854 static void
5919 got_code_from_term(code, len) 5855 got_code_from_term(char_u *code, int len)
5920 char_u *code;
5921 int len;
5922 { 5856 {
5923 #define XT_LEN 100 5857 #define XT_LEN 100
5924 char_u name[3]; 5858 char_u name[3];
5925 char_u str[XT_LEN]; 5859 char_u str[XT_LEN];
5926 int i; 5860 int i;
6004 * This is called before starting an external program or getting direct 5938 * This is called before starting an external program or getting direct
6005 * keyboard input. We don't want responses to be send to that program or 5939 * keyboard input. We don't want responses to be send to that program or
6006 * handled as typed text. 5940 * handled as typed text.
6007 */ 5941 */
6008 static void 5942 static void
6009 check_for_codes_from_term() 5943 check_for_codes_from_term(void)
6010 { 5944 {
6011 int c; 5945 int c;
6012 5946
6013 /* If no codes requested or all are answered, no need to wait. */ 5947 /* If no codes requested or all are answered, no need to wait. */
6014 if (xt_index_out == 0 || xt_index_out == xt_index_in) 5948 if (xt_index_out == 0 || xt_index_out == xt_index_in)
6056 * free the string afterwards. 5990 * free the string afterwards.
6057 * 5991 *
6058 * Returns NULL when there is a problem. 5992 * Returns NULL when there is a problem.
6059 */ 5993 */
6060 char_u * 5994 char_u *
6061 translate_mapping(str, expmap) 5995 translate_mapping(
6062 char_u *str; 5996 char_u *str,
6063 int expmap; /* TRUE when expanding mappings on command-line */ 5997 int expmap) /* TRUE when expanding mappings on command-line */
6064 { 5998 {
6065 garray_T ga; 5999 garray_T ga;
6066 int c; 6000 int c;
6067 int modifiers; 6001 int modifiers;
6068 int cpo_bslash; 6002 int cpo_bslash;
6146 6080
6147 /* 6081 /*
6148 * For Win32 console: update termcap codes for existing console attributes. 6082 * For Win32 console: update termcap codes for existing console attributes.
6149 */ 6083 */
6150 void 6084 void
6151 update_tcap(attr) 6085 update_tcap(int attr)
6152 int attr;
6153 { 6086 {
6154 struct builtin_term *p; 6087 struct builtin_term *p;
6155 6088
6156 p = find_builtin_term(DEFAULT_TERM); 6089 p = find_builtin_term(DEFAULT_TERM);
6157 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); 6090 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr);