diff options
-rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
-rw-r--r-- | src/nvim/getchar.c | 97 | ||||
-rw-r--r-- | src/nvim/globals.h | 4 | ||||
-rw-r--r-- | src/nvim/input.c | 16 | ||||
-rw-r--r-- | src/nvim/mapping.c | 10 |
5 files changed, 63 insertions, 66 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a7f488458e..a3e0e650fa 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2693,7 +2693,7 @@ char *getcmdline_prompt(const int firstc, const char *const prompt, const int at /// Read the 'wildmode' option, fill wim_flags[]. int check_opt_wim(void) { - char_u new_wim_flags[4]; + uint8_t new_wim_flags[4]; int i; int idx = 0; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 37840f8875..183fd5e19f 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -125,8 +125,8 @@ static int KeyNoremap = 0; // remapping flags // middle for typeahead and room for new characters (which needs to be 3 * // MAXMAPLEN for the Amiga). #define TYPELEN_INIT (5 * (MAXMAPLEN + 3)) -static char_u typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf -static char_u noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap +static uint8_t typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf +static uint8_t noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap static size_t last_recorded_len = 0; // number of last recorded chars @@ -337,14 +337,12 @@ static int read_readbuffers(int advance) static int read_readbuf(buffheader_T *buf, int advance) { - char_u c; - if (buf->bh_first.b_next == NULL) { // buffer is empty return NUL; } buffblock_T *const curr = buf->bh_first.b_next; - c = (char_u)curr->b_str[buf->bh_index]; + uint8_t c = (uint8_t)curr->b_str[buf->bh_index]; if (advance) { if (curr->b_str[++buf->bh_index] == NUL) { @@ -657,17 +655,17 @@ void stuffescaped(const char *arg, bool literally) static int read_redo(bool init, bool old_redo) { static buffblock_T *bp; - static char_u *p; + static uint8_t *p; int c; int n; - char_u buf[MB_MAXBYTES + 1]; + uint8_t buf[MB_MAXBYTES + 1]; if (init) { bp = old_redo ? old_redobuff.bh_first.b_next : redobuff.bh_first.b_next; if (bp == NULL) { return FAIL; } - p = (char_u *)bp->b_str; + p = (uint8_t *)bp->b_str; return OK; } if ((c = *p) == NUL) { @@ -688,9 +686,9 @@ static int read_redo(bool init, bool old_redo) } if (*++p == NUL && bp->b_next != NULL) { bp = bp->b_next; - p = (char_u *)bp->b_str; + p = (uint8_t *)bp->b_str; } - buf[i] = (char_u)c; + buf[i] = (uint8_t)c; if (i == n - 1) { // last byte of a character if (n != 1) { c = utf_ptr2char((char *)buf); @@ -854,7 +852,7 @@ bool noremap_keys(void) // return FAIL for failure, OK otherwise int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent) { - char_u *s1, *s2; + uint8_t *s1, *s2; int addlen; int val; int nrm; @@ -975,11 +973,11 @@ int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent) /// @return the length of what was inserted int ins_char_typebuf(int c, int modifiers) { - char_u buf[MB_MAXBYTES * 3 + 4]; - unsigned int len = special_to_buf(c, modifiers, true, (char *)buf); + char buf[MB_MAXBYTES * 3 + 4]; + unsigned int len = special_to_buf(c, modifiers, true, buf); assert(len < sizeof(buf)); buf[len] = NUL; - (void)ins_typebuf((char *)buf, KeyNoremap, 0, !KeyTyped, cmd_silent); + (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); return (int)len; } @@ -1081,11 +1079,11 @@ void del_typebuf(int len, int offset) // Write typed characters to script file. // If recording is on put the character in the recordbuffer. -static void gotchars(const char_u *chars, size_t len) +static void gotchars(const uint8_t *chars, size_t len) FUNC_ATTR_NONNULL_ALL { - const char_u *s = chars; - static char_u buf[4] = { 0 }; + const uint8_t *s = chars; + static uint8_t buf[4] = { 0 }; static size_t buflen = 0; size_t todo = len; @@ -1404,7 +1402,7 @@ int merge_modifiers(int c_arg, int *modifiers) int vgetc(void) { int c; - char_u buf[MB_MAXBYTES + 1]; + uint8_t buf[MB_MAXBYTES + 1]; // Do garbage collection when garbagecollect() was called previously and // we are now at the toplevel. @@ -1548,9 +1546,9 @@ int vgetc(void) // Note: This will loop until enough bytes are received! if ((n = MB_BYTE2LEN_CHECK(c)) > 1) { no_mapping++; - buf[0] = (char_u)c; + buf[0] = (uint8_t)c; for (int i = 1; i < n; i++) { - buf[i] = (char_u)vgetorpeek(true); + buf[i] = (uint8_t)vgetorpeek(true); if (buf[i] == K_SPECIAL) { // Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER sequence, // which represents a K_SPECIAL (0x80). @@ -1815,7 +1813,7 @@ typedef enum { /// Put "string[new_slen]" in typebuf. /// Remove "slen" bytes. /// @return FAIL for error, OK otherwise. -static int put_string_in_typebuf(int offset, int slen, char_u *string, int new_slen) +static int put_string_in_typebuf(int offset, int slen, uint8_t *string, int new_slen) { int extra = new_slen - slen; string[new_slen] = NUL; @@ -1838,7 +1836,7 @@ static int put_string_in_typebuf(int offset, int slen, char_u *string, int new_s /// in Insert mode completion. This includes the form with a CTRL modifier. static bool at_ins_compl_key(void) { - char_u *p = typebuf.tb_buf + typebuf.tb_off; + uint8_t *p = typebuf.tb_buf + typebuf.tb_off; int c = *p; if (typebuf.tb_len > 3 && c == K_SPECIAL && p[1] == KS_MODIFIER && (p[2] & MOD_MASK_CTRL)) { @@ -1858,7 +1856,7 @@ static int check_simplify_modifier(int max_offset) if (offset + 3 >= typebuf.tb_len) { break; } - char_u *tp = typebuf.tb_buf + typebuf.tb_off + offset; + uint8_t *tp = typebuf.tb_buf + typebuf.tb_off + offset; if (tp[0] == K_SPECIAL && tp[1] == KS_MODIFIER) { // A modifier was not used for a mapping, apply it to ASCII // keys. Shift would already have been applied. @@ -1874,12 +1872,12 @@ static int check_simplify_modifier(int max_offset) vgetc_char = c; vgetc_mod_mask = tp[2]; } - char_u new_string[MB_MAXBYTES]; + uint8_t new_string[MB_MAXBYTES]; int len; if (IS_SPECIAL(new_c)) { new_string[0] = K_SPECIAL; - new_string[1] = (char_u)K_SECOND(new_c); - new_string[2] = (char_u)K_THIRD(new_c); + new_string[1] = (uint8_t)K_SECOND(new_c); + new_string[2] = (uint8_t)K_THIRD(new_c); len = 3; } else { len = utf_char2bytes(new_c, (char *)new_string); @@ -1889,7 +1887,7 @@ static int check_simplify_modifier(int max_offset) return -1; } } else { - tp[2] = (char_u)modifier; + tp[2] = (uint8_t)modifier; if (put_string_in_typebuf(offset + 3, 1, new_string, len) == FAIL) { return -1; } @@ -2010,10 +2008,10 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // Don't allow mapping the first byte(s) of a multi-byte char. // Happens when mapping <M-a> and then changing 'encoding'. // Beware that 0x80 is escaped. - char_u *p1 = (char_u *)mp->m_keys; - char_u *p2 = (char_u *)mb_unescape((const char **)&p1); + char *p1 = mp->m_keys; + char *p2 = (char *)mb_unescape((const char **)&p1); - if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len((char *)p2)) { + if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len(p2)) { mlen = 0; } @@ -2077,7 +2075,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // Check for match with 'pastetoggle' if (*p_pt != NUL && mp == NULL && (State & (MODE_INSERT | MODE_NORMAL))) { - bool match = typebuf_match_len((char_u *)p_pt, &mlen); + bool match = typebuf_match_len((uint8_t *)p_pt, &mlen); if (match) { // write chars to script file(s) if (mlen > typebuf.tb_maplen) { @@ -2267,7 +2265,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth) // If this is a LANGMAP mapping, then we didn't record the keys // at the start of the function and have to record them now. if (keylen > typebuf.tb_maplen && (mp->m_mode & MODE_LANGMAP) != 0) { - gotchars((char_u *)map_str, strlen(map_str)); + gotchars((uint8_t *)map_str, strlen(map_str)); } if (save_m_noremap != REMAP_YES) { @@ -2442,7 +2440,7 @@ static int vgetorpeek(bool advance) if (advance) { // Also record this character, it might be needed to // get out of Insert mode. - *typebuf.tb_buf = (char_u)c; + *typebuf.tb_buf = (uint8_t)c; gotchars(typebuf.tb_buf, 1); } cmd_silent = false; @@ -2515,7 +2513,7 @@ static int vgetorpeek(bool advance) // move cursor left, if possible if (curwin->w_cursor.col != 0) { colnr_T col = 0; - char_u *ptr; + char *ptr; if (curwin->w_wcol > 0) { // After auto-indenting and no text is following, // we are expecting to truncate the trailing @@ -2524,11 +2522,10 @@ static int vgetorpeek(bool advance) if (did_ai && *skipwhite(get_cursor_line_ptr() + curwin->w_cursor.col) == NUL) { curwin->w_wcol = 0; - ptr = (char_u *)get_cursor_line_ptr(); + ptr = get_cursor_line_ptr(); chartabsize_T cts; - init_chartabsize_arg(&cts, curwin, - curwin->w_cursor.lnum, 0, (char *)ptr, (char *)ptr); - while ((char_u *)cts.cts_ptr < ptr + curwin->w_cursor.col) { + init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0, ptr, ptr); + while (cts.cts_ptr < ptr + curwin->w_cursor.col) { if (!ascii_iswhite(*cts.cts_ptr)) { curwin->w_wcol = cts.cts_vcol; } @@ -2554,9 +2551,9 @@ static int vgetorpeek(bool advance) if (col > 0 && curwin->w_wcol > 0) { // Correct when the cursor is on the right halve // of a double-wide character. - ptr = (char_u *)get_cursor_line_ptr(); - col -= utf_head_off((char *)ptr, (char *)ptr + col); - if (utf_ptr2cells((char *)ptr + col) > 1) { + ptr = get_cursor_line_ptr(); + col -= utf_head_off(ptr, ptr + col); + if (utf_ptr2cells(ptr + col) > 1) { curwin->w_wcol--; } } @@ -2760,7 +2757,7 @@ static int vgetorpeek(bool advance) } if (timedout && c == ESC) { - char_u nop_buf[3]; + uint8_t nop_buf[3]; // When recording there will be no timeout. Add a <Nop> after the ESC // to avoid that it forms a key code with following characters. @@ -2798,7 +2795,7 @@ static int vgetorpeek(bool advance) /// Return -1 when end of input script reached. /// /// @param wait_time milliseconds -int inchar(char_u *buf, int maxlen, long wait_time) +int inchar(uint8_t *buf, int maxlen, long wait_time) { int len = 0; // Init for GCC. int retesc = false; // Return ESC with gotint. @@ -2837,7 +2834,7 @@ int inchar(char_u *buf, int maxlen, long wait_time) return -1; } } else { - buf[0] = (char_u)script_char; + buf[0] = (uint8_t)script_char; len = 1; } } @@ -2851,7 +2848,7 @@ int inchar(char_u *buf, int maxlen, long wait_time) // and buf may be pointing inside typebuf.tb_buf[]. if (got_int) { #define DUM_LEN (MAXMAPLEN * 3 + 3) - char_u dum[DUM_LEN + 1]; + uint8_t dum[DUM_LEN + 1]; for (;;) { len = os_inchar(dum, DUM_LEN, 0L, 0, NULL); @@ -2884,13 +2881,13 @@ int inchar(char_u *buf, int maxlen, long wait_time) typebuf.tb_change_cnt = 1; } - return fix_input_buffer((char *)buf, len); + return fix_input_buffer(buf, len); } // Fix typed characters for use by vgetc() and check_termcode(). // "buf[]" must have room to triple the number of bytes! // Returns the new length. -int fix_input_buffer(char *buf, int len) +int fix_input_buffer(uint8_t *buf, int len) FUNC_ATTR_NONNULL_ALL { if (!using_script()) { @@ -2901,7 +2898,7 @@ int fix_input_buffer(char *buf, int len) } // Reading from script, need to process special bytes - char_u *p = (char_u *)buf; + uint8_t *p = buf; // Two characters are special: NUL and K_SPECIAL. // Replace NUL by K_SPECIAL KS_ZERO KE_FILLER @@ -2911,8 +2908,8 @@ int fix_input_buffer(char *buf, int len) || (p[0] == K_SPECIAL && (i < 2 || p[1] != KS_EXTRA))) { memmove(p + 3, p + 1, (size_t)i); - p[2] = (char_u)K_THIRD(p[0]); - p[1] = (char_u)K_SECOND(p[0]); + p[2] = (uint8_t)K_THIRD(p[0]); + p[1] = (uint8_t)K_SECOND(p[0]); p[0] = K_SPECIAL; p += 2; len += 2; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 94448eb7d7..f3bfbdabf6 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -789,7 +789,7 @@ EXTERN int redir_reg INIT(= 0); // message redirection register EXTERN int redir_vname INIT(= 0); // message redirection variable EXTERN garray_T *capture_ga INIT(= NULL); // captured output for execute() -EXTERN char_u langmap_mapchar[256]; // mapping for language keys +EXTERN uint8_t langmap_mapchar[256]; // mapping for language keys EXTERN int save_p_ls INIT(= -1); // Save 'laststatus' setting EXTERN int save_p_wmh INIT(= -1); // Save 'winminheight' setting @@ -832,7 +832,7 @@ EXTERN long sub_nsubs; // total number of substitutions EXTERN linenr_T sub_nlines; // total number of lines changed // table to store parsed 'wildmode' -EXTERN char_u wim_flags[4]; +EXTERN uint8_t wim_flags[4]; // whether titlestring and iconstring contains statusline syntax #define STL_IN_ICON 1 diff --git a/src/nvim/input.c b/src/nvim/input.c index 5b9b866778..fa55c02a24 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -86,7 +86,7 @@ int ask_yesno(const char *const str, const bool direct) /// Translates the interrupt character for unix to ESC. int get_keystroke(MultiQueue *events) { - char *buf = NULL; + uint8_t *buf = NULL; int buflen = 150; int len = 0; int n; @@ -112,7 +112,7 @@ int get_keystroke(MultiQueue *events) // First time: blocking wait. Second time: wait up to 100ms for a // terminal code to complete. - n = os_inchar((uint8_t *)buf + len, maxlen, len == 0 ? -1L : 100L, 0, events); + n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0, events); if (n > 0) { // Replace zero and K_SPECIAL by a special key code. n = fix_input_buffer(buf + len, n); @@ -127,14 +127,14 @@ int get_keystroke(MultiQueue *events) } // Handle modifier and/or special key code. - n = (uint8_t)buf[0]; + n = buf[0]; if (n == K_SPECIAL) { - n = TO_SPECIAL((uint8_t)buf[1], (uint8_t)buf[2]); - if ((uint8_t)buf[1] == KS_MODIFIER + n = TO_SPECIAL(buf[1], buf[2]); + if (buf[1] == KS_MODIFIER || n == K_IGNORE || (is_mouse_key(n) && n != K_LEFTMOUSE)) { - if ((uint8_t)buf[1] == KS_MODIFIER) { - mod_mask = (uint8_t)buf[2]; + if (buf[1] == KS_MODIFIER) { + mod_mask = buf[2]; } len -= 3; if (len > 0) { @@ -149,7 +149,7 @@ int get_keystroke(MultiQueue *events) continue; } buf[len >= buflen ? buflen - 1 : len] = NUL; - n = utf_ptr2char(buf); + n = utf_ptr2char((char *)buf); break; } xfree(buf); diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 3840a00981..60524b9fb7 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -323,7 +323,7 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len mapargs->orig_rhs_len = 0; // stores <lua>ref_no<cr> in map_str mapargs->rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "%c%c%c%d\r", K_SPECIAL, - (char_u)KS_EXTRA, KE_LUA, rhs_lua); + KS_EXTRA, KE_LUA, rhs_lua); mapargs->rhs = xstrdup(tmp_buf); } } @@ -1879,7 +1879,7 @@ int makemap(FILE *fd, buf_T *buf) // return FAIL for failure, OK otherwise int put_escstr(FILE *fd, char *strstart, int what) { - char_u *str = (char_u *)strstart; + uint8_t *str = (uint8_t *)strstart; int c; // :map xx <Nop> @@ -1956,7 +1956,7 @@ int put_escstr(FILE *fd, char *strstart, int what) } } else if (c < ' ' || c > '~' || c == '|' || (what == 0 && c == ' ') - || (what == 1 && str == (char_u *)strstart && c == ' ') + || (what == 1 && str == (uint8_t *)strstart && c == ' ') || (what != 2 && c == '<')) { if (putc(Ctrl_V, fd) < 0) { return FAIL; @@ -2383,7 +2383,7 @@ int langmap_adjust_mb(int c) void langmap_init(void) { for (int i = 0; i < 256; i++) { - langmap_mapchar[i] = (char_u)i; // we init with a one-to-one map + langmap_mapchar[i] = (uint8_t)i; // we init with a one-to-one map } ga_init(&langmap_mapga, sizeof(langmap_entry_T), 8); } @@ -2447,7 +2447,7 @@ void langmap_set(void) langmap_set_entry(from, to); } else { assert(to <= UCHAR_MAX); - langmap_mapchar[from & 255] = (char_u)to; + langmap_mapchar[from & 255] = (uint8_t)to; } // Advance to next pair |