aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r--src/nvim/message.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index aecb46c6bd..98ef6e5cba 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -216,13 +216,13 @@ void msg_grid_validate(void)
/// When terminal not initialized (yet) os_errmsg(..) is used.
///
/// @return true if wait_return() not called
-int msg(char *s)
+int msg(const char *s)
{
return msg_attr_keep(s, 0, false, false);
}
/// Like msg() but keep it silent when 'verbosefile' is set.
-int verb_msg(char *s)
+int verb_msg(const char *s)
{
verbose_enter();
int n = msg_attr_keep(s, 0, false, false);
@@ -278,8 +278,7 @@ void msg_multiattr(HlMessage hl_msg, const char *kind, bool history)
msg_ext_set_kind(kind);
for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
HlMessageChunk chunk = kv_A(hl_msg, i);
- msg_multiline_attr((const char *)chunk.text.data, chunk.attr,
- true, &need_clear);
+ msg_multiline_attr(chunk.text.data, chunk.attr, true, &need_clear);
}
if (history && kv_size(hl_msg)) {
add_msg_hist_multiattr(NULL, 0, 0, true, hl_msg);
@@ -305,7 +304,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Skip messages not match ":filter pattern".
// Don't filter when there is an error.
- if (!emsg_on_display && message_filtered((char *)s)) {
+ if (!emsg_on_display && message_filtered(s)) {
return true;
}
@@ -333,7 +332,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Truncate the message if needed.
msg_start();
- buf = msg_strtrunc((char *)s, false);
+ buf = msg_strtrunc(s, false);
if (buf != NULL) {
s = buf;
}
@@ -349,8 +348,8 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
}
retval = msg_end();
- if (keep && retval && vim_strsize((char *)s) < (Rows - cmdline_row - 1) * Columns + sc_col) {
- set_keep_msg((char *)s, 0);
+ if (keep && retval && vim_strsize(s) < (Rows - cmdline_row - 1) * Columns + sc_col) {
+ set_keep_msg(s, 0);
}
need_fileinfo = false;
@@ -365,7 +364,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
/// @return an allocated string or NULL when no truncating is done.
///
/// @param force always truncate
-char *msg_strtrunc(char *s, int force)
+char *msg_strtrunc(const char *s, int force)
{
char *buf = NULL;
@@ -395,7 +394,7 @@ char *msg_strtrunc(char *s, int force)
/// Truncate a string "s" to "buf" with cell width "room".
/// "s" and "buf" may be equal.
-void trunc_string(char *s, char *buf, int room_in, int buflen)
+void trunc_string(const char *s, char *buf, int room_in, int buflen)
{
int room = room_in - 3; // "..." takes 3 chars
int half;
@@ -503,7 +502,7 @@ int smsg_attr(int attr, const char *s, ...)
va_start(arglist, s);
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
va_end(arglist);
- return msg_attr((const char *)IObuff, attr);
+ return msg_attr(IObuff, attr);
}
int smsg_attr_keep(int attr, const char *s, ...)
@@ -514,7 +513,7 @@ int smsg_attr_keep(int attr, const char *s, ...)
va_start(arglist, s);
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
va_end(arglist);
- return msg_attr_keep((const char *)IObuff, attr, true, false);
+ return msg_attr_keep(IObuff, attr, true, false);
}
// Remember the last sourcing name/lnum used in an error message, so that it
@@ -862,7 +861,7 @@ void siemsg(const char *s, ...)
}
/// Give an "Internal error" message.
-void internal_error(char *where)
+void internal_error(const char *where)
{
siemsg(_(e_intern2), where);
}
@@ -1327,7 +1326,7 @@ static void hit_return_msg(void)
}
/// Set "keep_msg" to "s". Free the old value and check for NULL pointer.
-void set_keep_msg(char *s, int attr)
+void set_keep_msg(const char *s, int attr)
{
xfree(keep_msg);
if (s != NULL && msg_silent == 0) {
@@ -1562,7 +1561,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
// If the string starts with a composing character first draw a space on
// which the composing char can be drawn.
- if (utf_iscomposing(utf_ptr2char((char *)msgstr))) {
+ if (utf_iscomposing(utf_ptr2char(msgstr))) {
msg_puts_attr(" ", attr);
}
@@ -1598,7 +1597,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
msg_puts_attr_len(plain_start, str - plain_start, attr);
}
plain_start = str + 1;
- msg_puts_attr((const char *)s, attr == 0 ? HL_ATTR(HLF_8) : attr);
+ msg_puts_attr(s, attr == 0 ? HL_ATTR(HLF_8) : attr);
retval += (int)strlen(s);
} else {
retval++;
@@ -1674,7 +1673,7 @@ int msg_outtrans_special(const char *strstart, bool from, int maxlen)
// single-byte character or illegal byte
text = (char *)transchar_byte_buf(NULL, (uint8_t)text[0]);
}
- const int len = vim_strsize((char *)text);
+ const int len = vim_strsize(text);
if (maxlen > 0 && retval + len >= maxlen) {
break;
}
@@ -1966,7 +1965,7 @@ void msg_prt_line(char *s, int list)
/// Use grid_puts() to output one multi-byte character.
///
/// @return the pointer "s" advanced to the next character.
-static char *screen_puts_mbyte(char *s, int l, int attr)
+static const char *screen_puts_mbyte(const char *s, int l, int attr)
{
int cw;
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
@@ -2212,7 +2211,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
} else {
l = utfc_ptr2len(s);
}
- s = screen_puts_mbyte((char *)s, l, attr);
+ s = screen_puts_mbyte(s, l, attr);
did_last_char = true;
} else {
did_last_char = false;
@@ -2229,7 +2228,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
if (p_more) {
// Store text for scrolling back.
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
+ store_sb_text(&sb_str, s, attr, &sb_col, true);
}
inc_msg_scrolled();
@@ -2274,7 +2273,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
if (wrap && p_more && !recurse) {
// Store text for scrolling back.
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
+ store_sb_text(&sb_str, s, attr, &sb_col, true);
}
if (*s == '\n') { // go to next line
@@ -2312,7 +2311,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
// characters and draw them all at once later.
if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) {
if (l > 1) {
- s = screen_puts_mbyte((char *)s, l, attr) - 1;
+ s = screen_puts_mbyte(s, l, attr) - 1;
} else {
msg_screen_putchar(*s, attr);
}
@@ -2333,7 +2332,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
t_puts(&t_col, t_s, s, attr);
}
if (p_more && !recurse && !(s == sb_str + 1 && *sb_str == '\n')) {
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false);
+ store_sb_text(&sb_str, s, attr, &sb_col, false);
}
msg_check();
@@ -2341,7 +2340,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
/// @return true when ":filter pattern" was used and "msg" does not match
/// "pattern".
-bool message_filtered(char *msg)
+bool message_filtered(const char *msg)
{
if (cmdmod.cmod_filter_regmatch.regprog == NULL) {
return false;
@@ -2507,7 +2506,7 @@ static sb_clear_T do_clear_sb_text = SB_CLEAR_NONE;
/// @param sb_str start of string
/// @param s just after string
/// @param finish line ends
-static void store_sb_text(char **sb_str, char *s, int attr, int *sb_col, int finish)
+static void store_sb_text(const char **sb_str, const char *s, int attr, int *sb_col, int finish)
{
msgchunk_T *mp;
@@ -2681,7 +2680,7 @@ static void t_puts(int *t_col, const char *t_s, const char *s, int attr)
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
// Output postponed text.
msg_didout = true; // Remember that line is not empty.
- grid_puts_len(&msg_grid_adj, (char *)t_s, (int)(s - t_s), msg_row, msg_col, attr);
+ grid_puts_len(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr);
msg_col += *t_col;
*t_col = 0;
// If the string starts with a composing character don't increment the
@@ -3308,7 +3307,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen)
write_reg_contents(redir_reg, s, (ssize_t)len, true);
}
if (redir_vname) {
- var_redir_str((char *)s, (int)maxlen);
+ var_redir_str(s, (int)maxlen);
}
// Write and adjust the current column.
@@ -3417,7 +3416,7 @@ int verbose_open(void)
/// Give a warning message (for searching).
/// Use 'w' highlighting and may repeat the message after redrawing
-void give_warning(char *message, bool hl)
+void give_warning(const char *message, bool hl)
FUNC_ATTR_NONNULL_ARG(1)
{
// Don't do this for ":silent".
@@ -3440,7 +3439,7 @@ void give_warning(char *message, bool hl)
msg_ext_set_kind("wmsg");
}
- if (msg_attr((const char *)message, keep_msg_attr) && msg_scrolled == 0) {
+ if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0) {
set_keep_msg(message, keep_msg_attr);
}
msg_didout = false; // Overwrite this message.
@@ -3450,7 +3449,7 @@ void give_warning(char *message, bool hl)
no_wait_return--;
}
-void give_warning2(char *const message, char *const a1, bool hl)
+void give_warning2(const char *const message, const char *const a1, bool hl)
{
vim_snprintf(IObuff, IOSIZE, message, a1);
give_warning(IObuff, hl);