diff options
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index eb836b9005..a374406716 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -144,10 +144,9 @@ static int KeyNoremap = 0; // remapping flags #define RM_SCRIPT 2 // tb_noremap: remap local script mappings #define RM_ABBR 4 // tb_noremap: don't remap, do abbrev. -/* typebuf.tb_buf has three parts: room in front (for result of mappings), the - * middle for typeahead and room for new characters (which needs to be 3 * - * MAXMAPLEN) for the Amiga). - */ +// typebuf.tb_buf has three parts: room in front (for result of mappings), the +// 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 @@ -265,7 +264,7 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle buf->bh_space = 0; buf->bh_curr = &(buf->bh_first); } else if (buf->bh_curr == NULL) { // buffer has already been read - IEMSG(_("E222: Add to read buffer")); + iemsg(_("E222: Add to read buffer")); return; } else if (buf->bh_index != 0) { memmove(buf->bh_first.b_next->b_str, @@ -682,7 +681,7 @@ static int read_redo(bool init, bool old_redo) if ((c = *p) == NUL) { return c; } - // Reverse the conversion done by add_char_buff() */ + // Reverse the conversion done by add_char_buff() // For a multi-byte character get all the bytes and return the // converted character. if (c != K_SPECIAL || p[1] == KS_SPECIAL) { @@ -900,7 +899,7 @@ int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent newoff = MAXMAPLEN + 4; newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); if (newlen < 0) { // string is getting too long - EMSG(_(e_toocompl)); // also calls flush_buffers + emsg(_(e_toocompl)); // also calls flush_buffers setcursor(); return FAIL; } @@ -966,9 +965,9 @@ int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent (char_u)((--nrm >= 0) ? val : RM_YES); } - /* tb_maplen and tb_silent only remember the length of mapped and/or - * silent mappings at the start of the buffer, assuming that a mapped - * sequence doesn't result in typed characters. */ + // tb_maplen and tb_silent only remember the length of mapped and/or + // silent mappings at the start of the buffer, assuming that a mapped + // sequence doesn't result in typed characters. if (nottyped || typebuf.tb_maplen > offset) { typebuf.tb_maplen += addlen; } @@ -1116,8 +1115,8 @@ void del_typebuf(int len, int offset) } } - /* Reset the flag that text received from a client or from feedkeys() - * was inserted in the typeahead buffer. */ + // Reset the flag that text received from a client or from feedkeys() + // was inserted in the typeahead buffer. typebuf_was_filled = false; if (++typebuf.tb_change_cnt == 0) { typebuf.tb_change_cnt = 1; @@ -1167,9 +1166,9 @@ static void gotchars(const char_u *chars, size_t len) // output "debug mode" message next time in debug mode debug_did_msg = false; - /* Since characters have been typed, consider the following to be in - * another mapping. Search string will be kept in history. */ - ++maptick; + // Since characters have been typed, consider the following to be in + // another mapping. Search string will be kept in history. + maptick++; } /* @@ -1287,7 +1286,7 @@ void restore_typeahead(tasave_T *tp) void openscript(char_u *name, bool directly) { if (curscript + 1 == NSCRIPT) { - EMSG(_(e_nesting)); + emsg(_(e_nesting)); return; } @@ -1310,7 +1309,7 @@ void openscript(char_u *name, bool directly) int error; if ((scriptin[curscript] = file_open_new(&error, (char *)NameBuff, kFileReadOnly, 0)) == NULL) { - emsgf(_(e_notopen_2), name, os_strerror(error)); + semsg(_(e_notopen_2), name, os_strerror(error)); if (curscript) { curscript--; } @@ -1561,8 +1560,7 @@ int vgetc(void) buf[0] = (char_u)c; for (i = 1; i < n; i++) { buf[i] = (char_u)vgetorpeek(true); - if (buf[i] == K_SPECIAL - ) { + if (buf[i] == K_SPECIAL) { // Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER sequence, // which represents a K_SPECIAL (0x80), // or a CSI - KS_EXTRA - KE_CSI sequence, which represents @@ -1691,7 +1689,7 @@ void vungetc(int c) old_mouse_col = mouse_col; } -/// Gets a character: +/// Gets a byte: /// 1. from the stuffbuffer /// This is used for abbreviated commands like "D" -> "d$". /// Also used to redo a command for ".". @@ -1823,8 +1821,8 @@ static int vgetorpeek(bool advance) flush_buffers(FLUSH_INPUT); // flush all typeahead if (advance) { - /* Also record this character, it might be needed to - * get out of Insert mode. */ + // Also record this character, it might be needed to + // get out of Insert mode. *typebuf.tb_buf = (char_u)c; gotchars(typebuf.tb_buf, 1); } @@ -2076,7 +2074,7 @@ static int vgetorpeek(bool advance) * The depth check catches ":map x y" and ":map y x". */ if (++mapdepth >= p_mmd) { - EMSG(_("E223: recursive mapping")); + emsg(_("E223: recursive mapping")); if (State & CMDLINE) { redrawcmdline(); } else { @@ -2311,13 +2309,13 @@ static int vgetorpeek(bool advance) /* * get a character: 3. from the user - update display */ - /* In insert mode a screen update is skipped when characters - * are still available. But when those available characters - * are part of a mapping, and we are going to do a blocking - * wait here. Need to update the screen to display the - * changed text so far. Also for when 'lazyredraw' is set and - * redrawing was postponed because there was something in the - * input buffer (e.g., termresponse). */ + // In insert mode a screen update is skipped when characters + // are still available. But when those available characters + // are part of a mapping, and we are going to do a blocking + // wait here. Need to update the screen to display the + // changed text so far. Also for when 'lazyredraw' is set and + // redrawing was postponed because there was something in the + // input buffer (e.g., termresponse). if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0 && advance && must_redraw != 0 && !need_wait_return) { update_screen(0); @@ -2932,10 +2930,10 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T && args->unique && STRNCMP(mp->m_keys, lhs, (size_t)len) == 0) { if (is_abbrev) { - EMSG2(_("E224: global abbreviation already exists for %s"), + semsg(_("E224: global abbreviation already exists for %s"), mp->m_keys); } else { - EMSG2(_("E225: global mapping already exists for %s"), mp->m_keys); + semsg(_("E225: global mapping already exists for %s"), mp->m_keys); } retval = 5; goto theend; @@ -3031,9 +3029,9 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T continue; } else if (args->unique) { if (is_abbrev) { - EMSG2(_("E226: abbreviation already exists for %s"), p); + semsg(_("E226: abbreviation already exists for %s"), p); } else { - EMSG2(_("E227: mapping already exists for %s"), p); + semsg(_("E227: mapping already exists for %s"), p); } retval = 5; goto theend; @@ -3092,9 +3090,9 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T if (!has_lhs || !has_rhs) { // print entries if (!did_it && !did_local) { if (is_abbrev) { - MSG(_("No abbreviation found")); + msg(_("No abbreviation found")); } else { - MSG(_("No mapping found")); + msg(_("No mapping found")); } } goto theend; // listing finished @@ -3293,7 +3291,7 @@ void map_clear_mode(char_u *cmdp, char_u *arg, int forceit, int abbr) local = (STRCMP(arg, "<buffer>") == 0); if (!local && *arg != NUL) { - EMSG(_(e_invarg)); + emsg(_(e_invarg)); return; } @@ -4169,7 +4167,7 @@ int makemap(FILE *fd, buf_T *buf) c1 = 't'; break; default: - IEMSG(_("E228: makemap: Illegal mode")); + iemsg(_("E228: makemap: Illegal mode")); return FAIL; } do { @@ -4532,7 +4530,7 @@ char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) if (vgetorpeek(false) == NUL) { // incomplete <Cmd> is an error, because there is not much the user // could do in this state. - EMSG(e_cmdmap_err); + emsg(e_cmdmap_err); aborted = true; break; } @@ -4559,13 +4557,13 @@ char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) aborted = true; } else if (c1 == K_COMMAND) { // special case to give nicer error message - EMSG(e_cmdmap_repeated); + emsg(e_cmdmap_repeated); aborted = true; } else if (IS_SPECIAL(c1)) { if (c1 == K_SNR) { ga_concat(&line_ga, "<SNR>"); } else { - EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod)); + semsg(e_cmdmap_key, get_special_key_name(c1, cmod)); aborted = true; } } else { |