diff options
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 149 |
1 files changed, 75 insertions, 74 deletions
diff --git a/src/message.c b/src/message.c index 9969632dd1..448173c0b9 100644 --- a/src/message.c +++ b/src/message.c @@ -19,7 +19,7 @@ static void add_msg_hist(char_u *s, int len, int attr); static void hit_return_msg(void); static void msg_home_replace_attr(char_u *fname, int attr); -static void msg_puts_attr_len(char_u *str, int maxlen, int attr); +static void msg_puts_attr_len(char *str, int maxlen, int attr); static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse); static void msg_scroll_up(void); static void inc_msg_scrolled(void); @@ -96,7 +96,7 @@ static int verbose_did_open = FALSE; * return TRUE if wait_return not called */ int -msg(char_u *s) +msg(char *s) { return msg_attr_keep(s, 0, FALSE); } @@ -107,7 +107,7 @@ msg(char_u *s) * Like msg() but keep it silent when 'verbosefile' is set. */ int -verb_msg(char_u *s) +verb_msg(char *s) { int n; @@ -120,14 +120,14 @@ verb_msg(char_u *s) #endif int -msg_attr(char_u *s, int attr) +msg_attr(char *s, int attr) { return msg_attr_keep(s, attr, FALSE); } int msg_attr_keep( - char_u *s, + char *s, int attr, int keep) /* TRUE: set keep_msg if it doesn't scroll */ { @@ -137,12 +137,12 @@ msg_attr_keep( /* Skip messages not matching ":filter pattern". * Don't filter when there is an error. */ - if (!emsg_on_display && message_filtered(s)) + if (!emsg_on_display && message_filtered((char_u *)s)) return TRUE; #ifdef FEAT_EVAL if (attr == 0) - set_vim_var_string(VV_STATUSMSG, s, -1); + set_vim_var_string(VV_STATUSMSG, (char_u *)s, -1); #endif /* @@ -156,12 +156,12 @@ msg_attr_keep( /* Add message to history (unless it's a repeated kept message or a * truncated message) */ - if (s != keep_msg + if ((char_u *)s != keep_msg || (*s != '<' && last_msg_hist != NULL && last_msg_hist->msg != NULL && STRCMP(s, last_msg_hist->msg))) - add_msg_hist(s, -1, attr); + add_msg_hist((char_u *)s, -1, attr); #ifdef FEAT_JOB_CHANNEL if (emsg_to_channel_log) @@ -171,22 +171,22 @@ msg_attr_keep( /* When displaying keep_msg, don't let msg_start() free it, caller must do * that. */ - if (s == keep_msg) + if ((char_u *)s == keep_msg) keep_msg = NULL; /* Truncate the message if needed. */ msg_start(); - buf = msg_strtrunc(s, FALSE); + buf = msg_strtrunc((char_u *)s, FALSE); if (buf != NULL) - s = buf; + s = (char *)buf; - msg_outtrans_attr(s, attr); + msg_outtrans_attr((char_u *)s, attr); msg_clr_eos(); retval = msg_end(); - if (keep && retval && vim_strsize(s) < (int)(Rows - cmdline_row - 1) - * Columns + sc_col) - set_keep_msg(s, 0); + if (keep && retval && vim_strsize((char_u *)s) + < (int)(Rows - cmdline_row - 1) * Columns + sc_col) + set_keep_msg((char_u *)s, 0); vim_free(buf); --entered; @@ -376,7 +376,7 @@ smsg(const char *s, ...) va_start(arglist, s); vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg(IObuff); + return msg((char *)IObuff); } int @@ -390,7 +390,7 @@ smsg_attr(int attr, const char *s, ...) va_start(arglist, s); vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg_attr(IObuff, attr); + return msg_attr((char *)IObuff, attr); } int @@ -404,7 +404,7 @@ smsg_attr_keep(int attr, const char *s, ...) va_start(arglist, s); vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg_attr_keep(IObuff, attr, TRUE); + return msg_attr_keep((char *)IObuff, attr, TRUE); } #endif @@ -502,13 +502,13 @@ msg_source(int attr) p = get_emsg_source(); if (p != NULL) { - msg_attr(p, attr); + msg_attr((char *)p, attr); vim_free(p); } p = get_emsg_lnum(); if (p != NULL) { - msg_attr(p, HL_ATTR(HLF_N)); + msg_attr((char *)p, HL_ATTR(HLF_N)); vim_free(p); last_sourcing_lnum = sourcing_lnum; /* only once for each line */ } @@ -611,7 +611,7 @@ emsg_core(char_u *s) /* When testing some errors are turned into a normal message. */ if (ignore_error(s)) /* don't call msg() if it results in a dialog */ - return msg_use_printf() ? FALSE : msg(s); + return msg_use_printf() ? FALSE : msg((char *)s); #endif called_emsg = TRUE; @@ -716,7 +716,7 @@ emsg_core(char_u *s) * Display the error message itself. */ msg_nowait = FALSE; /* wait for this msg */ - r = msg_attr(s, attr); + r = msg_attr((char *)s, attr); #ifdef FEAT_JOB_CHANNEL emsg_to_channel_log = FALSE; @@ -817,22 +817,23 @@ emsg_invreg(int name) * Careful: The string may be changed by msg_may_trunc()! * Returns a pointer to the printed message, if wait_return() not called. */ - char_u * -msg_trunc_attr(char_u *s, int force, int attr) + char * +msg_trunc_attr(char *s, int force, int attr) { int n; + char *ts; /* Add message to history before truncating */ - add_msg_hist(s, -1, attr); + add_msg_hist((char_u *)s, -1, attr); - s = msg_may_trunc(force, s); + ts = (char *)msg_may_trunc(force, (char_u *)s); msg_hist_off = TRUE; - n = msg_attr(s, attr); + n = msg_attr(ts, attr); msg_hist_off = FALSE; if (n) - return s; + return ts; return NULL; } @@ -983,7 +984,7 @@ ex_messages(exarg_T *eap) if (s != NULL && *s != NUL) // The next comment is extracted by xgettext and put in po file for // translators to read. - msg_attr((char_u *) + msg_attr( // Translator: Please replace the name and email address // with the appropriate text for your translation. _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"), @@ -993,7 +994,7 @@ ex_messages(exarg_T *eap) /* Display what was not skipped. */ for (; p != NULL && !got_int; p = p->next) if (p->msg != NULL) - msg_attr(p->msg, p->attr); + msg_attr((char *)p->msg, p->attr); msg_hist_off = FALSE; } @@ -1016,10 +1017,10 @@ msg_end_prompt(void) #endif /* - * wait for the user to hit a key (normally a return) - * if 'redraw' is TRUE, clear and redraw the screen - * if 'redraw' is FALSE, just redraw the screen - * if 'redraw' is -1, don't redraw at all + * Wait for the user to hit a key (normally Enter). + * If "redraw" is TRUE, clear and redraw the screen. + * If "redraw" is FALSE, just redraw the screen. + * If "redraw" is -1, don't redraw at all. */ void wait_return(int redraw) @@ -1065,7 +1066,7 @@ wait_return(int redraw) } else if (exmode_active) { - MSG_PUTS(" "); /* make sure the cursor is on the right line */ + msg_puts(" "); /* make sure the cursor is on the right line */ c = CAR; /* no need for a return in ex mode */ got_int = FALSE; } @@ -1281,9 +1282,9 @@ hit_return_msg(void) if (msg_didout) /* start on a new line */ msg_putchar('\n'); if (got_int) - MSG_PUTS(_("Interrupt: ")); + msg_puts(_("Interrupt: ")); - MSG_PUTS_ATTR(_("Press ENTER or type command to continue"), HL_ATTR(HLF_R)); + msg_puts_attr(_("Press ENTER or type command to continue"), HL_ATTR(HLF_R)); if (!msg_use_printf()) msg_clr_eos(); p_more = save_p_more; @@ -1388,9 +1389,9 @@ msg_putchar(int c) msg_putchar_attr(int c, int attr) { #ifdef FEAT_MBYTE - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; #else - char_u buf[4]; + char buf[4]; #endif if (IS_SPECIAL(c)) @@ -1403,7 +1404,7 @@ msg_putchar_attr(int c, int attr) else { #ifdef FEAT_MBYTE - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, (char_u *)buf)] = NUL; #else buf[0] = c; buf[1] = NUL; @@ -1415,9 +1416,9 @@ msg_putchar_attr(int c, int attr) void msg_outnum(long n) { - char_u buf[20]; + char buf[20]; - sprintf((char *)buf, "%ld", n); + sprintf(buf, "%ld", n); msg_puts(buf); } @@ -1486,7 +1487,7 @@ msg_outtrans_one(char_u *p, int attr) return p + l; } #endif - msg_puts_attr(transchar_byte(*p), attr); + msg_puts_attr((char *)transchar_byte(*p), attr); return p + 1; } @@ -1513,7 +1514,7 @@ msg_outtrans_len_attr(char_u *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 (enc_utf8 && utf_iscomposing(utf_ptr2char(msgstr))) - msg_puts_attr((char_u *)" ", attr); + msg_puts_attr(" ", attr); #endif /* @@ -1541,10 +1542,11 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr) /* unprintable multi-byte char: print the printable chars so * far and the translation of the unprintable char. */ if (str > plain_start) - msg_puts_attr_len(plain_start, (int)(str - plain_start), - attr); + msg_puts_attr_len((char *)plain_start, + (int)(str - plain_start), attr); plain_start = str + mb_l; - msg_puts_attr(transchar(c), attr == 0 ? HL_ATTR(HLF_8) : attr); + msg_puts_attr((char *)transchar(c), + attr == 0 ? HL_ATTR(HLF_8) : attr); retval += char2cells(c); } len -= mb_l - 1; @@ -1559,10 +1561,10 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr) /* unprintable char: print the printable chars so far and the * translation of the unprintable char. */ if (str > plain_start) - msg_puts_attr_len(plain_start, (int)(str - plain_start), - attr); + msg_puts_attr_len((char *)plain_start, + (int)(str - plain_start), attr); plain_start = str + 1; - msg_puts_attr(s, attr == 0 ? HL_ATTR(HLF_8) : attr); + msg_puts_attr((char *)s, attr == 0 ? HL_ATTR(HLF_8) : attr); retval += (int)STRLEN(s); } else @@ -1573,7 +1575,7 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr) if (str > plain_start) /* print the printable chars at the end */ - msg_puts_attr_len(plain_start, (int)(str - plain_start), attr); + msg_puts_attr_len((char *)plain_start, (int)(str - plain_start), attr); return retval; } @@ -1619,7 +1621,7 @@ msg_outtrans_special( { char_u *str = strstart; int retval = 0; - char_u *string; + char *text; int attr; int len; @@ -1629,16 +1631,16 @@ msg_outtrans_special( /* Leading and trailing spaces need to be displayed in <> form. */ if ((str == strstart || str[1] == NUL) && *str == ' ') { - string = (char_u *)"<Space>"; + text = "<Space>"; ++str; } else - string = str2special(&str, from); - len = vim_strsize(string); + text = (char *)str2special(&str, from); + len = vim_strsize((char_u *)text); /* Highlight special keys */ - msg_puts_attr(string, len > 1 + msg_puts_attr(text, len > 1 #ifdef FEAT_MBYTE - && (*mb_ptr2len)(string) <= 1 + && (*mb_ptr2len)((char_u *)text) <= 1 #endif ? attr : 0); retval += len; @@ -1825,7 +1827,7 @@ msg_prt_line(char_u *s, int list) mch_memmove(buf, s, (size_t)l); buf[l] = NUL; } - msg_puts(buf); + msg_puts((char *)buf); s += l; continue; } @@ -1957,14 +1959,13 @@ screen_puts_mbyte(char_u *s, int l, int attr) * Update msg_row and msg_col for the next message. */ void -msg_puts(char_u *s) +msg_puts(char *s) { msg_puts_attr(s, 0); } void -msg_puts_title( - char_u *s) +msg_puts_title(char *s) { msg_puts_attr(s, HL_ATTR(HLF_T)); } @@ -1975,13 +1976,13 @@ msg_puts_title( * Does not handle multi-byte characters! */ void -msg_puts_long_attr(char_u *longstr, int attr) +msg_outtrans_long_attr(char_u *longstr, int attr) { - msg_puts_long_len_attr(longstr, (int)STRLEN(longstr), attr); + msg_outtrans_long_len_attr(longstr, (int)STRLEN(longstr), attr); } void -msg_puts_long_len_attr(char_u *longstr, int len, int attr) +msg_outtrans_long_len_attr(char_u *longstr, int len, int attr) { int slen = len; int room; @@ -1991,7 +1992,7 @@ msg_puts_long_len_attr(char_u *longstr, int len, int attr) { slen = (room - 3) / 2; msg_outtrans_len_attr(longstr, slen, attr); - msg_puts_attr((char_u *)"...", HL_ATTR(HLF_8)); + msg_puts_attr("...", HL_ATTR(HLF_8)); } msg_outtrans_len_attr(longstr + len - slen, slen, attr); } @@ -2000,7 +2001,7 @@ msg_puts_long_len_attr(char_u *longstr, int len, int attr) * Basic function for writing a message with highlight attributes. */ void -msg_puts_attr(char_u *s, int attr) +msg_puts_attr(char *s, int attr) { msg_puts_attr_len(s, -1, attr); } @@ -2011,12 +2012,12 @@ msg_puts_attr(char_u *s, int attr) * When "maxlen" is >= 0 the message is not put in the history. */ static void -msg_puts_attr_len(char_u *str, int maxlen, int attr) +msg_puts_attr_len(char *str, int maxlen, int attr) { /* * If redirection is on, also write to the redirection file. */ - redir_write(str, maxlen); + redir_write((char_u *)str, maxlen); /* * Don't print anything when using ":silent cmd". @@ -2027,7 +2028,7 @@ msg_puts_attr_len(char_u *str, int maxlen, int attr) /* if MSG_HIST flag set, add message to history */ if ((attr & MSG_HIST) && maxlen < 0) { - add_msg_hist(str, -1, attr); + add_msg_hist((char_u *)str, -1, attr); attr &= ~MSG_HIST; } @@ -2049,9 +2050,9 @@ msg_puts_attr_len(char_u *str, int maxlen, int attr) * cursor is. */ if (msg_use_printf()) - msg_puts_printf(str, maxlen); + msg_puts_printf((char_u *)str, maxlen); else - msg_puts_display(str, maxlen, attr, FALSE); + msg_puts_display((char_u *)str, maxlen, attr, FALSE); } /* @@ -3497,7 +3498,7 @@ give_warning(char_u *message, int hl) keep_msg_attr = HL_ATTR(HLF_W); else keep_msg_attr = 0; - if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0) + if (msg_attr((char *)message, keep_msg_attr) && msg_scrolled == 0) set_keep_msg(message, keep_msg_attr); msg_didout = FALSE; /* overwrite this message */ msg_nowait = TRUE; /* don't wait for this message */ @@ -3891,7 +3892,7 @@ display_confirm_msg(void) /* avoid that 'q' at the more prompt truncates the message here */ ++confirm_msg_used; if (confirm_msg != NULL) - msg_puts_attr(confirm_msg, HL_ATTR(HLF_M)); + msg_puts_attr((char *)confirm_msg, HL_ATTR(HLF_M)); --confirm_msg_used; } |