diff options
Diffstat (limited to 'src/term.c')
-rw-r--r-- | src/term.c | 100 |
1 files changed, 63 insertions, 37 deletions
diff --git a/src/term.c b/src/term.c index 398df0af79..90611a9a30 100644 --- a/src/term.c +++ b/src/term.c @@ -1227,7 +1227,7 @@ static void parse_builtin_tcap(char_u *term) } else term_strings[p->bt_entry] = (char_u *)p->bt_string; } - } else { + } else { name[0] = KEY2TERMCAP0((int)p->bt_entry); name[1] = KEY2TERMCAP1((int)p->bt_entry); if (find_termcode(name) == NULL) @@ -2048,7 +2048,8 @@ static int out_pos = 0; /* number of chars in out_buf */ /* * out_flush(): flush the output buffer */ -void out_flush(void) { +void out_flush(void) +{ int len; if (out_pos != 0) { @@ -2063,7 +2064,8 @@ void out_flush(void) { * 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) { +void out_flush_check(void) +{ if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) out_flush(); } @@ -2436,7 +2438,8 @@ static int get_bytes_from_buf(char_u *buf, char_u *bytes, 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) { +void check_shellsize(void) +{ if (Rows < min_rows()) /* need room for one window and command line */ Rows = min_rows(); limit_screen_size(); @@ -2445,7 +2448,8 @@ void check_shellsize(void) { /* * Limit Rows and Columns to avoid an overflow in Rows * Columns. */ -void limit_screen_size(void) { +void limit_screen_size(void) +{ if (Columns < MIN_COLUMNS) Columns = MIN_COLUMNS; else if (Columns > 10000) @@ -2457,7 +2461,8 @@ void limit_screen_size(void) { /* * Invoked just before the screen structures are going to be (re)allocated. */ -void win_new_shellsize(void) { +void win_new_shellsize(void) +{ static int old_Rows = 0; static int old_Columns = 0; @@ -2480,7 +2485,8 @@ void win_new_shellsize(void) { * 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) { +void shell_resized(void) +{ set_shellsize(0, 0, FALSE); } @@ -2488,7 +2494,8 @@ void shell_resized(void) { * Check if the shell size changed. Handle a resize. * When the size didn't change, nothing happens. */ -void shell_resized_check(void) { +void shell_resized_check(void) +{ int old_Rows = Rows; int old_Columns = Columns; @@ -2574,13 +2581,13 @@ void set_shellsize(int width, int height, int mustset) || exmode_active) { screenalloc(FALSE); repeat_message(); - } else { + } else { if (curwin->w_p_scb) do_check_scrollbind(TRUE); if (State & CMDLINE) { update_screen(NOT_VALID); redrawcmdline(); - } else { + } else { update_topline(); if (pum_visible()) { redraw_later(NOT_VALID); @@ -2636,7 +2643,8 @@ void settmode(int tmode) } } -void starttermcap(void) { +void starttermcap(void) +{ if (full_screen && !termcap_active) { out_str(T_TI); /* start termcap mode */ out_str(T_KS); /* start "keypad transmit" mode */ @@ -2653,7 +2661,8 @@ void starttermcap(void) { } } -void stoptermcap(void) { +void stoptermcap(void) +{ screen_stop_highlight(); reset_cterm_colors(); if (termcap_active) { @@ -2698,7 +2707,8 @@ void stoptermcap(void) { * request to terminal while reading from a file). * The result is caught in check_termcode(). */ -void may_req_termresponse(void) { +void may_req_termresponse(void) +{ if (crv_status == CRV_GET && cur_tmode == TMODE_RAW && starting == 0 @@ -2728,7 +2738,8 @@ void may_req_termresponse(void) { * 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) { +void may_req_ambiguous_char_width(void) +{ if (u7_status == U7_GET && cur_tmode == TMODE_RAW && termcap_active @@ -2783,14 +2794,16 @@ static void log_tr(char *msg) { /* * Return TRUE when saving and restoring the screen. */ -int swapping_screen(void) { +int swapping_screen(void) +{ return full_screen && *T_TI != NUL; } /* * setmouse() - switch mouse on/off depending on current mode and 'mouse' */ -void setmouse(void) { +void setmouse(void) +{ int checkfor; @@ -2850,7 +2863,8 @@ int mouse_has(int c) /* * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". */ -int mouse_model_popup(void) { +int mouse_model_popup(void) +{ return p_mousem[0] == 'p'; } @@ -2859,7 +2873,8 @@ int mouse_model_popup(void) { * terminals this makes the screen scrolled to the correct position. * Used when starting Vim or returning from a shell. */ -void scroll_start(void) { +void scroll_start(void) +{ if (*T_VS != NUL) { out_str(T_VS); out_str(T_VE); @@ -2872,7 +2887,8 @@ static int cursor_is_off = FALSE; /* * Enable the cursor. */ -void cursor_on(void) { +void cursor_on(void) +{ if (cursor_is_off) { out_str(T_VE); cursor_is_off = FALSE; @@ -2882,7 +2898,8 @@ void cursor_on(void) { /* * Disable the cursor. */ -void cursor_off(void) { +void cursor_off(void) +{ if (full_screen) { if (!cursor_is_off) out_str(T_VI); /* disable cursor */ @@ -2893,7 +2910,8 @@ void cursor_off(void) { /* * Set cursor shape to match Insert mode. */ -void term_cursor_shape(void) { +void term_cursor_shape(void) +{ static int showing_insert_mode = MAYBE; if (!full_screen || *T_CSI == NUL || *T_CEI == NUL) @@ -2903,7 +2921,7 @@ void term_cursor_shape(void) { if (showing_insert_mode != TRUE) out_str(T_CSI); /* Insert mode cursor */ showing_insert_mode = TRUE; - } else { + } else { if (showing_insert_mode != FALSE) out_str(T_CEI); /* non-Insert mode cursor */ showing_insert_mode = FALSE; @@ -2929,7 +2947,8 @@ void scroll_region_set(win_T *wp, int off) /* * Reset scrolling region to the whole screen. */ -void scroll_region_reset(void) { +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)); @@ -2952,7 +2971,8 @@ static int tc_len = 0; /* current number of entries in termcodes[] */ static int termcode_star(char_u *code, int len); -void clear_termcodes(void) { +void clear_termcodes(void) +{ while (tc_len > 0) vim_free(termcodes[--tc_len].code); vim_free(termcodes); @@ -3047,7 +3067,7 @@ void add_termcode(char_u *name, char_u *string, int flags) vim_free(s); return; } - } else { + } else { /* Replace old code. */ vim_free(termcodes[i].code); --tc_len; @@ -3142,7 +3162,8 @@ static void del_termcode_idx(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(void) { +static void switch_to_8bit(void) +{ int i; int c; @@ -3256,7 +3277,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) break; tp = typebuf.tb_buf + typebuf.tb_off + offset; len = typebuf.tb_len - offset; /* length of the input */ - } else { + } else { if (offset >= *buflen) break; tp = buf + offset; @@ -4097,7 +4118,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED * to indicate what happened. */ retval = KEYLEN_REMOVED; - } else { + } else { string[new_slen++] = K_SPECIAL; string[new_slen++] = key_name[0]; string[new_slen++] = key_name[1]; @@ -4118,7 +4139,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) */ mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, (size_t)new_slen); - } else { + } else { if (extra < 0) /* remove matched characters */ mch_memmove(buf + offset, buf + offset - extra, @@ -4275,7 +4296,7 @@ replace_termcodes ( } else if (STRNICMP(src, "<LocalLeader>", 13) == 0) { len = 13; p = get_var_value((char_u *)"g:maplocalleader"); - } else { + } else { len = 0; p = NULL; } @@ -4357,7 +4378,8 @@ int find_term_bykeys(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(void) { +static void gather_termleader(void) +{ int i; int len = 0; @@ -4379,7 +4401,8 @@ static void gather_termleader(void) { * Show all termcodes (for ":set termcap") * This code looks a lot like showoptions(), but is different. */ -void show_termcodes(void) { +void show_termcodes(void) +{ int col; int *items; int item_count; @@ -4467,7 +4490,7 @@ int show_one_termcode(char_u *name, char_u *code, int printit) IObuff[1] = ' '; IObuff[2] = ' '; IObuff[3] = ' '; - } else { + } else { IObuff[0] = 't'; IObuff[1] = '_'; IObuff[2] = name[0]; @@ -4508,13 +4531,15 @@ int show_one_termcode(char_u *name, char_u *code, int printit) static int xt_index_in = 0; static int xt_index_out = 0; -static void req_codes_from_term(void) { +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(void) { +static void req_more_codes_from_term(void) +{ char buf[11]; int old_idx = xt_index_out; @@ -4607,7 +4632,7 @@ static void got_code_from_term(char_u *code, int len) redraw_asap(CLEAR); #endif } - } else { + } else { /* First delete any existing entry with the same code. */ i = find_term_bykeys(str); if (i >= 0) @@ -4628,7 +4653,8 @@ static void got_code_from_term(char_u *code, 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(void) { +static void check_for_codes_from_term(void) +{ int c; /* If no codes requested or all are answered, no need to wait. */ |