aboutsummaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c257
1 files changed, 99 insertions, 158 deletions
diff --git a/src/term.c b/src/term.c
index 7525244ca1..a15e281de5 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1143,8 +1143,7 @@ static int need_gather = FALSE; /* need to fill termleader[] */
static char_u termleader[256 + 1]; /* for check_termcode() */
static int check_for_codes = FALSE; /* check for key code response */
-static struct builtin_term * find_builtin_term(term)
-char_u *term;
+static struct builtin_term *find_builtin_term(char_u *term)
{
struct builtin_term *p;
@@ -1171,8 +1170,7 @@ char_u *term;
* Caller should check if 'name' is a valid builtin term.
* The terminal's name is not set, as this is already done in termcapinit().
*/
-static void parse_builtin_tcap(term)
-char_u *term;
+static void parse_builtin_tcap(char_u *term)
{
struct builtin_term *p;
char_u name[2];
@@ -1222,8 +1220,7 @@ static void set_color_count __ARGS((int nr));
* Store it as a number in t_colors.
* Store it as a string in T_CCO (using nr_colors[]).
*/
-static void set_color_count(nr)
-int nr;
+static void set_color_count(int nr)
{
char_u nr_colors[20]; /* string for number of colors */
@@ -1259,8 +1256,7 @@ static char *(key_names[]) =
*
* While doing this, until ttest(), some options may be NULL, be careful.
*/
-int set_termname(term)
-char_u *term;
+int set_termname(char_u *term)
{
struct builtin_term *termp;
#ifdef HAVE_TGETENT
@@ -1655,9 +1651,11 @@ char_u *term;
# define HMT_SGR 64
static int has_mouse_termcode = 0;
-void set_mouse_termcode(n, s)
-int n; /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
-char_u *s;
+void
+set_mouse_termcode (
+ int n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
+ char_u *s
+)
{
char_u name[2];
@@ -1683,8 +1681,10 @@ char_u *s;
# if ((defined(UNIX) || defined(VMS) || defined(OS2)) \
&& defined(FEAT_MOUSE_TTY)) || defined(PROTO)
-void del_mouse_termcode(n)
-int n; /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
+void
+del_mouse_termcode (
+ int n /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
+)
{
char_u name[2];
@@ -1714,9 +1714,7 @@ int n; /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
* Call tgetent()
* Return error message if it fails, NULL if it's OK.
*/
-static char_u * tgetent_error(tbuf, term)
-char_u *tbuf;
-char_u *term;
+static char_u *tgetent_error(char_u *tbuf, char_u *term)
{
int i;
@@ -1749,9 +1747,7 @@ char_u *term;
* Some versions of tgetstr() have been reported to return -1 instead of NULL.
* Fix that here.
*/
-static char_u * vim_tgetstr(s, pp)
-char *s;
-char_u **pp;
+static char_u *vim_tgetstr(char *s, char_u **pp)
{
char *p;
@@ -1770,9 +1766,11 @@ char_u **pp;
* and "li" entries never change. But on some systems this works.
* Errors while getting the entries are ignored.
*/
-void getlinecol(cp, rp)
-long *cp; /* pointer to columns */
-long *rp; /* pointer to rows */
+void
+getlinecol (
+ long *cp, /* pointer to columns */
+ long *rp /* pointer to rows */
+)
{
char_u tbuf[TBUFSZ];
@@ -1793,9 +1791,7 @@ long *rp; /* pointer to rows */
* If force given, replace an existing entry.
* Return FAIL if the entry was not found, OK if the entry was added.
*/
-int add_termcap_entry(name, force)
-char_u *name;
-int force;
+int add_termcap_entry(char_u *name, int force)
{
char_u *term;
int key;
@@ -1888,8 +1884,7 @@ int force;
return FAIL;
}
-static int term_is_builtin(name)
-char_u *name;
+static int term_is_builtin(char_u *name)
{
return STRNCMP(name, "builtin_", (size_t)8) == 0;
}
@@ -1899,8 +1894,7 @@ char_u *name;
* Assume that the terminal is using 8-bit controls when the name contains
* "8bit", like in "xterm-8bit".
*/
-int term_is_8bit(name)
-char_u *name;
+int term_is_8bit(char_u *name)
{
return detected_8bit || strstr((char *)name, "8bit") != NULL;
}
@@ -1911,8 +1905,7 @@ char_u *name;
* <Esc>] -> <M-C-]>
* <Esc>O -> <M-C-O>
*/
-static int term_7to8bit(p)
-char_u *p;
+static int term_7to8bit(char_u *p)
{
if (*p == ESC) {
if (p[1] == '[')
@@ -1928,8 +1921,7 @@ char_u *p;
#if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO)
-char_u * tltoa(i)
-unsigned long i;
+char_u *tltoa(unsigned long i)
{
static char_u buf[16];
char_u *p;
@@ -1953,9 +1945,7 @@ unsigned long i;
*/
static char *tgoto __ARGS((char *, int, int));
-static char * tgoto(cm, x, y)
-char *cm;
-int x, y;
+static char *tgoto(char *cm, int x, int y)
{
static char buf[30];
char *p, *s, *e;
@@ -2001,8 +1991,7 @@ int x, y;
* If "name" is NULL or empty, get the terminal name from the environment.
* If that fails, use the default terminal name.
*/
-void termcapinit(name)
-char_u *name;
+void termcapinit(char_u *name)
{
char_u *term;
@@ -2037,7 +2026,7 @@ static int out_pos = 0; /* number of chars in out_buf */
/*
* out_flush(): flush the output buffer
*/
-void out_flush() {
+void out_flush(void) {
int len;
if (out_pos != 0) {
@@ -2052,7 +2041,7 @@ void out_flush() {
* Sometimes a byte out of a multi-byte character is written with out_char().
* To avoid flushing half of the character, call this function first.
*/
-void out_flush_check() {
+void out_flush_check(void) {
if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES)
out_flush();
}
@@ -2063,8 +2052,7 @@ void out_flush_check() {
* This should not be used for outputting text on the screen (use functions
* like msg_puts() and screen_putchar() for that).
*/
-void out_char(c)
-unsigned c;
+void out_char(unsigned c)
{
#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX)
if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
@@ -2083,8 +2071,7 @@ static void out_char_nf __ARGS((unsigned));
/*
* out_char_nf(c): like out_char(), but don't flush when p_wd is set
*/
-static void out_char_nf(c)
-unsigned c;
+static void out_char_nf(unsigned c)
{
#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX)
if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
@@ -2108,8 +2095,7 @@ unsigned c;
* This should only be used for writing terminal codes, not for outputting
* normal text (use functions like msg_puts() and screen_putchar() for that).
*/
-void out_str_nf(s)
-char_u *s;
+void out_str_nf(char_u *s)
{
if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */
out_flush();
@@ -2128,8 +2114,7 @@ char_u *s;
* This should only be used for writing terminal codes, not for outputting
* normal text (use functions like msg_puts() and screen_putchar() for that).
*/
-void out_str(s)
-char_u *s;
+void out_str(char_u *s)
{
if (s != NULL && *s) {
/* avoid terminal strings being split up */
@@ -2151,35 +2136,28 @@ char_u *s;
/*
* cursor positioning using termcap parser. (jw)
*/
-void term_windgoto(row, col)
-int row;
-int col;
+void term_windgoto(int row, int col)
{
OUT_STR(tgoto((char *)T_CM, col, row));
}
-void term_cursor_right(i)
-int i;
+void term_cursor_right(int i)
{
OUT_STR(tgoto((char *)T_CRI, 0, i));
}
-void term_append_lines(line_count)
-int line_count;
+void term_append_lines(int line_count)
{
OUT_STR(tgoto((char *)T_CAL, 0, line_count));
}
-void term_delete_lines(line_count)
-int line_count;
+void term_delete_lines(int line_count)
{
OUT_STR(tgoto((char *)T_CDL, 0, line_count));
}
#if defined(HAVE_TGETENT) || defined(PROTO)
-void term_set_winpos(x, y)
-int x;
-int y;
+void term_set_winpos(int x, int y)
{
/* Can't handle a negative value here */
if (x < 0)
@@ -2189,16 +2167,13 @@ int y;
OUT_STR(tgoto((char *)T_CWP, y, x));
}
-void term_set_winsize(width, height)
-int width;
-int height;
+void term_set_winsize(int width, int height)
{
OUT_STR(tgoto((char *)T_CWS, height, width));
}
#endif
-void term_fg_color(n)
-int n;
+void term_fg_color(int n)
{
/* Use "AF" termcap entry if present, "Sf" entry otherwise */
if (*T_CAF)
@@ -2207,8 +2182,7 @@ int n;
term_color(T_CSF, n);
}
-void term_bg_color(n)
-int n;
+void term_bg_color(int n)
{
/* Use "AB" termcap entry if present, "Sb" entry otherwise */
if (*T_CAB)
@@ -2217,9 +2191,7 @@ int n;
term_color(T_CSB, n);
}
-static void term_color(s, n)
-char_u *s;
-int n;
+static void term_color(char_u *s, int n)
{
char buf[20];
int i = 2; /* index in s[] just after <Esc>[ or CSI */
@@ -2252,8 +2224,7 @@ int n;
/*
* Generic function to set window title, using t_ts and t_fs.
*/
-void term_settitle(title)
-char_u *title;
+void term_settitle(char_u *title)
{
/* t_ts takes one argument: column in status line */
OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */
@@ -2267,8 +2238,7 @@ char_u *title;
* Make sure we have a valid set or terminal options.
* Replace all entries that are NULL by empty_option
*/
-void ttest(pairs)
-int pairs;
+void ttest(int pairs)
{
check_options(); /* make sure no options are NULL */
@@ -2360,9 +2330,7 @@ int pairs;
* Represent the given long_u as individual bytes, with the most significant
* byte first, and store them in dst.
*/
-void add_long_to_buf(val, dst)
-long_u val;
-char_u *dst;
+void add_long_to_buf(long_u val, char_u *dst)
{
int i;
int shift;
@@ -2383,9 +2351,7 @@ static int get_long_from_buf __ARGS((char_u *buf, long_u *val));
* (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes
* were present.
*/
-static int get_long_from_buf(buf, val)
-char_u *buf;
-long_u *val;
+static int get_long_from_buf(char_u *buf, long_u *val)
{
int len;
char_u bytes[sizeof(long_u)];
@@ -2413,10 +2379,7 @@ long_u *val;
* from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were
* available.
*/
-static int get_bytes_from_buf(buf, bytes, num_bytes)
-char_u *buf;
-char_u *bytes;
-int num_bytes;
+static int get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes)
{
int len = 0;
int i;
@@ -2449,7 +2412,7 @@ int num_bytes;
* Check if the new shell size is valid, correct it if it's too small or way
* too big.
*/
-void check_shellsize() {
+void check_shellsize(void) {
if (Rows < min_rows()) /* need room for one window and command line */
Rows = min_rows();
limit_screen_size();
@@ -2458,7 +2421,7 @@ void check_shellsize() {
/*
* Limit Rows and Columns to avoid an overflow in Rows * Columns.
*/
-void limit_screen_size() {
+void limit_screen_size(void) {
if (Columns < MIN_COLUMNS)
Columns = MIN_COLUMNS;
else if (Columns > 10000)
@@ -2470,7 +2433,7 @@ void limit_screen_size() {
/*
* Invoked just before the screen structures are going to be (re)allocated.
*/
-void win_new_shellsize() {
+void win_new_shellsize(void) {
static int old_Rows = 0;
static int old_Columns = 0;
@@ -2493,7 +2456,7 @@ void win_new_shellsize() {
* Call this function when the Vim shell has been resized in any way.
* Will obtain the current size and redraw (also when size didn't change).
*/
-void shell_resized() {
+void shell_resized(void) {
set_shellsize(0, 0, FALSE);
}
@@ -2501,7 +2464,7 @@ void shell_resized() {
* Check if the shell size changed. Handle a resize.
* When the size didn't change, nothing happens.
*/
-void shell_resized_check() {
+void shell_resized_check(void) {
int old_Rows = Rows;
int old_Columns = Columns;
@@ -2521,9 +2484,7 @@ void shell_resized_check() {
* If 'mustset' is FALSE, we may try to get the real window size and if
* it fails use 'width' and 'height'.
*/
-void set_shellsize(width, height, mustset)
-int width, height;
-int mustset;
+void set_shellsize(int width, int height, int mustset)
{
static int busy = FALSE;
@@ -2616,8 +2577,7 @@ int mustset;
* Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external
* commands and Ex mode).
*/
-void settmode(tmode)
-int tmode;
+void settmode(int tmode)
{
if (full_screen) {
@@ -2652,7 +2612,7 @@ int tmode;
}
}
-void starttermcap() {
+void starttermcap(void) {
if (full_screen && !termcap_active) {
out_str(T_TI); /* start termcap mode */
out_str(T_KS); /* start "keypad transmit" mode */
@@ -2669,7 +2629,7 @@ void starttermcap() {
}
}
-void stoptermcap() {
+void stoptermcap(void) {
screen_stop_highlight();
reset_cterm_colors();
if (termcap_active) {
@@ -2714,7 +2674,7 @@ void stoptermcap() {
* request to terminal while reading from a file).
* The result is caught in check_termcode().
*/
-void may_req_termresponse() {
+void may_req_termresponse(void) {
if (crv_status == CRV_GET
&& cur_tmode == TMODE_RAW
&& starting == 0
@@ -2744,7 +2704,7 @@ void may_req_termresponse() {
* This function has the side effect that changes cursor position, so
* it must be called immediately after entering termcap mode.
*/
-void may_req_ambiguous_char_width() {
+void may_req_ambiguous_char_width(void) {
if (u7_status == U7_GET
&& cur_tmode == TMODE_RAW
&& termcap_active
@@ -2799,14 +2759,14 @@ static void log_tr(char *msg) {
/*
* Return TRUE when saving and restoring the screen.
*/
-int swapping_screen() {
+int swapping_screen(void) {
return full_screen && *T_TI != NUL;
}
/*
* setmouse() - switch mouse on/off depending on current mode and 'mouse'
*/
-void setmouse() {
+void setmouse(void) {
int checkfor;
@@ -2846,8 +2806,7 @@ void setmouse() {
* - the current buffer is a help file and 'h' is in 'mouse' and we are in a
* normal editing mode (not at hit-return message).
*/
-int mouse_has(c)
-int c;
+int mouse_has(int c)
{
char_u *p;
@@ -2867,7 +2826,7 @@ int c;
/*
* Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
*/
-int mouse_model_popup() {
+int mouse_model_popup(void) {
return p_mousem[0] == 'p';
}
@@ -2876,7 +2835,7 @@ int mouse_model_popup() {
* terminals this makes the screen scrolled to the correct position.
* Used when starting Vim or returning from a shell.
*/
-void scroll_start() {
+void scroll_start(void) {
if (*T_VS != NUL) {
out_str(T_VS);
out_str(T_VE);
@@ -2889,7 +2848,7 @@ static int cursor_is_off = FALSE;
/*
* Enable the cursor.
*/
-void cursor_on() {
+void cursor_on(void) {
if (cursor_is_off) {
out_str(T_VE);
cursor_is_off = FALSE;
@@ -2899,7 +2858,7 @@ void cursor_on() {
/*
* Disable the cursor.
*/
-void cursor_off() {
+void cursor_off(void) {
if (full_screen) {
if (!cursor_is_off)
out_str(T_VI); /* disable cursor */
@@ -2911,7 +2870,7 @@ void cursor_off() {
/*
* Set cursor shape to match Insert mode.
*/
-void term_cursor_shape() {
+void term_cursor_shape(void) {
static int showing_insert_mode = MAYBE;
if (!full_screen || *T_CSI == NUL || *T_CEI == NUL)
@@ -2936,9 +2895,7 @@ void term_cursor_shape() {
* Also set the vertical scroll region for a vertically split window. Always
* the full width of the window, excluding the vertical separator.
*/
-void scroll_region_set(wp, off)
-win_T *wp;
-int off;
+void scroll_region_set(win_T *wp, int off)
{
OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1,
W_WINROW(wp) + off));
@@ -2951,7 +2908,7 @@ int off;
/*
* Reset scrolling region to the whole screen.
*/
-void scroll_region_reset() {
+void scroll_region_reset(void) {
OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0));
if (*T_CSV != NUL)
OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0));
@@ -2974,7 +2931,7 @@ static int tc_len = 0; /* current number of entries in termcodes[] */
static int termcode_star __ARGS((char_u *code, int len));
-void clear_termcodes() {
+void clear_termcodes(void) {
while (tc_len > 0)
vim_free(termcodes[--tc_len].code);
vim_free(termcodes);
@@ -2999,10 +2956,7 @@ void clear_termcodes() {
* "flags" is TRUE when replacing 7-bit by 8-bit controls is desired.
* "flags" can also be ATC_FROM_TERM for got_code_from_term().
*/
-void add_termcode(name, string, flags)
-char_u *name;
-char_u *string;
-int flags;
+void add_termcode(char_u *name, char_u *string, int flags)
{
struct termcode *new_tc;
int i, j;
@@ -3107,9 +3061,7 @@ int flags;
* The "X" can be any character.
* Return 0 if not found, 2 for ;*X and 1 for O*X and <M-O>*X.
*/
-static int termcode_star(code, len)
-char_u *code;
-int len;
+static int termcode_star(char_u *code, int len)
{
/* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */
if (len >= 3 && code[len - 2] == '*') {
@@ -3121,8 +3073,7 @@ int len;
return 0;
}
-char_u * find_termcode(name)
-char_u *name;
+char_u *find_termcode(char_u *name)
{
int i;
@@ -3132,16 +3083,14 @@ char_u *name;
return NULL;
}
-char_u * get_termcode(i)
-int i;
+char_u *get_termcode(int i)
{
if (i >= tc_len)
return NULL;
return &termcodes[i].name[0];
}
-void del_termcode(name)
-char_u *name;
+void del_termcode(char_u *name)
{
int i;
@@ -3158,8 +3107,7 @@ char_u *name;
/* not found. Give error message? */
}
-static void del_termcode_idx(idx)
-int idx;
+static void del_termcode_idx(int idx)
{
int i;
@@ -3173,7 +3121,7 @@ int idx;
* Called when detected that the terminal sends 8-bit codes.
* Convert all 7-bit codes to their 8-bit equivalent.
*/
-static void switch_to_8bit() {
+static void switch_to_8bit(void) {
int i;
int c;
@@ -3206,8 +3154,7 @@ static int orig_topfill = 0;
* Set orig_topline. Used when jumping to another window, so that a double
* click still works.
*/
-void set_mouse_topline(wp)
-win_T *wp;
+void set_mouse_topline(win_T *wp)
{
orig_topline = wp->w_topline;
orig_topfill = wp->w_topfill;
@@ -3227,11 +3174,7 @@ win_T *wp;
* "buflen" is then the length of the string in buf[] and is updated for
* inserts and deletes.
*/
-int check_termcode(max_offset, buf, bufsize, buflen)
-int max_offset;
-char_u *buf;
-int bufsize;
-int *buflen;
+int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
{
char_u *tp;
char_u *p;
@@ -4196,12 +4139,14 @@ int *buflen;
* nothing). When 'cpoptions' does not contain 'B', a backslash can be used
* instead of a CTRL-V.
*/
-char_u * replace_termcodes(from, bufp, from_part, do_lt, special)
-char_u *from;
-char_u **bufp;
-int from_part;
-int do_lt; /* also translate <lt> */
-int special; /* always accept <key> notation */
+char_u *
+replace_termcodes (
+ char_u *from,
+ char_u **bufp,
+ int from_part,
+ int do_lt, /* also translate <lt> */
+ int special /* always accept <key> notation */
+)
{
int i;
int slen;
@@ -4374,8 +4319,7 @@ int special; /* always accept <key> notation */
* Find a termcode with keys 'src' (must be NUL terminated).
* Return the index in termcodes[], or -1 if not found.
*/
-int find_term_bykeys(src)
-char_u *src;
+int find_term_bykeys(char_u *src)
{
int i;
int slen = (int)STRLEN(src);
@@ -4392,7 +4336,7 @@ char_u *src;
* Gather the first characters in the terminal key codes into a string.
* Used to speed up check_termcode().
*/
-static void gather_termleader() {
+static void gather_termleader(void) {
int i;
int len = 0;
@@ -4414,7 +4358,7 @@ static void gather_termleader() {
* Show all termcodes (for ":set termcap")
* This code looks a lot like showoptions(), but is different.
*/
-void show_termcodes() {
+void show_termcodes(void) {
int col;
int *items;
int item_count;
@@ -4492,10 +4436,7 @@ void show_termcodes() {
* Show one termcode entry.
* Output goes into IObuff[]
*/
-int show_one_termcode(name, code, printit)
-char_u *name;
-char_u *code;
-int printit;
+int show_one_termcode(char_u *name, char_u *code, int printit)
{
char_u *p;
int len;
@@ -4546,13 +4487,13 @@ int printit;
static int xt_index_in = 0;
static int xt_index_out = 0;
-static void req_codes_from_term() {
+static void req_codes_from_term(void) {
xt_index_out = 0;
xt_index_in = 0;
req_more_codes_from_term();
}
-static void req_more_codes_from_term() {
+static void req_more_codes_from_term(void) {
char buf[11];
int old_idx = xt_index_out;
@@ -4587,9 +4528,7 @@ static void req_more_codes_from_term() {
* Both <name> and <string> are encoded in hex.
* "code" points to the "0" or "1".
*/
-static void got_code_from_term(code, len)
-char_u *code;
-int len;
+static void got_code_from_term(char_u *code, int len)
{
#define XT_LEN 100
char_u name[3];
@@ -4668,7 +4607,7 @@ int len;
* keyboard input. We don't want responses to be send to that program or
* handled as typed text.
*/
-static void check_for_codes_from_term() {
+static void check_for_codes_from_term(void) {
int c;
/* If no codes requested or all are answered, no need to wait. */
@@ -4714,9 +4653,11 @@ static void check_for_codes_from_term() {
*
* Returns NULL when there is a problem.
*/
-char_u * translate_mapping(str, expmap)
-char_u *str;
-int expmap; /* TRUE when expanding mappings on command-line */
+char_u *
+translate_mapping (
+ char_u *str,
+ int expmap /* TRUE when expanding mappings on command-line */
+)
{
garray_T ga;
int c;