comparison src/message.c @ 7827:41789f16d6b2 v7.4.1210

commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 30 18:51:09 2016 +0100 patch 7.4.1210 Problem: Using old style function declarations. Solution: Change to new style function declarations. (script by Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Sat, 30 Jan 2016 19:00:05 +0100
parents 37c929c4a073
children 58505cbea7e5
comparison
equal deleted inserted replaced
7826:df34d45f38d4 7827:41789f16d6b2
100 * msg(s) - displays the string 's' on the status line 100 * msg(s) - displays the string 's' on the status line
101 * When terminal not initialized (yet) mch_errmsg(..) is used. 101 * When terminal not initialized (yet) mch_errmsg(..) is used.
102 * return TRUE if wait_return not called 102 * return TRUE if wait_return not called
103 */ 103 */
104 int 104 int
105 msg(s) 105 msg(char_u *s)
106 char_u *s;
107 { 106 {
108 return msg_attr_keep(s, 0, FALSE); 107 return msg_attr_keep(s, 0, FALSE);
109 } 108 }
110 109
111 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \ 110 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
112 || defined(FEAT_GUI_GTK) || defined(PROTO) 111 || defined(FEAT_GUI_GTK) || defined(PROTO)
113 /* 112 /*
114 * Like msg() but keep it silent when 'verbosefile' is set. 113 * Like msg() but keep it silent when 'verbosefile' is set.
115 */ 114 */
116 int 115 int
117 verb_msg(s) 116 verb_msg(char_u *s)
118 char_u *s;
119 { 117 {
120 int n; 118 int n;
121 119
122 verbose_enter(); 120 verbose_enter();
123 n = msg_attr_keep(s, 0, FALSE); 121 n = msg_attr_keep(s, 0, FALSE);
126 return n; 124 return n;
127 } 125 }
128 #endif 126 #endif
129 127
130 int 128 int
131 msg_attr(s, attr) 129 msg_attr(char_u *s, int attr)
132 char_u *s;
133 int attr;
134 { 130 {
135 return msg_attr_keep(s, attr, FALSE); 131 return msg_attr_keep(s, attr, FALSE);
136 } 132 }
137 133
138 int 134 int
139 msg_attr_keep(s, attr, keep) 135 msg_attr_keep(
140 char_u *s; 136 char_u *s,
141 int attr; 137 int attr,
142 int keep; /* TRUE: set keep_msg if it doesn't scroll */ 138 int keep) /* TRUE: set keep_msg if it doesn't scroll */
143 { 139 {
144 static int entered = 0; 140 static int entered = 0;
145 int retval; 141 int retval;
146 char_u *buf = NULL; 142 char_u *buf = NULL;
147 143
195 /* 191 /*
196 * Truncate a string such that it can be printed without causing a scroll. 192 * Truncate a string such that it can be printed without causing a scroll.
197 * Returns an allocated string or NULL when no truncating is done. 193 * Returns an allocated string or NULL when no truncating is done.
198 */ 194 */
199 char_u * 195 char_u *
200 msg_strtrunc(s, force) 196 msg_strtrunc(
201 char_u *s; 197 char_u *s,
202 int force; /* always truncate */ 198 int force) /* always truncate */
203 { 199 {
204 char_u *buf = NULL; 200 char_u *buf = NULL;
205 int len; 201 int len;
206 int room; 202 int room;
207 203
240 /* 236 /*
241 * Truncate a string "s" to "buf" with cell width "room". 237 * Truncate a string "s" to "buf" with cell width "room".
242 * "s" and "buf" may be equal. 238 * "s" and "buf" may be equal.
243 */ 239 */
244 void 240 void
245 trunc_string(s, buf, room, buflen) 241 trunc_string(
246 char_u *s; 242 char_u *s,
247 char_u *buf; 243 char_u *buf,
248 int room; 244 int room,
249 int buflen; 245 int buflen)
250 { 246 {
251 int half; 247 int half;
252 int len; 248 int len;
253 int e; 249 int e;
254 int i; 250 int i;
386 /* 382 /*
387 * Reset the last used sourcing name/lnum. Makes sure it is displayed again 383 * Reset the last used sourcing name/lnum. Makes sure it is displayed again
388 * for the next error message; 384 * for the next error message;
389 */ 385 */
390 void 386 void
391 reset_last_sourcing() 387 reset_last_sourcing(void)
392 { 388 {
393 vim_free(last_sourcing_name); 389 vim_free(last_sourcing_name);
394 last_sourcing_name = NULL; 390 last_sourcing_name = NULL;
395 last_sourcing_lnum = 0; 391 last_sourcing_lnum = 0;
396 } 392 }
397 393
398 /* 394 /*
399 * Return TRUE if "sourcing_name" differs from "last_sourcing_name". 395 * Return TRUE if "sourcing_name" differs from "last_sourcing_name".
400 */ 396 */
401 static int 397 static int
402 other_sourcing_name() 398 other_sourcing_name(void)
403 { 399 {
404 if (sourcing_name != NULL) 400 if (sourcing_name != NULL)
405 { 401 {
406 if (last_sourcing_name != NULL) 402 if (last_sourcing_name != NULL)
407 return STRCMP(sourcing_name, last_sourcing_name) != 0; 403 return STRCMP(sourcing_name, last_sourcing_name) != 0;
414 * Get the message about the source, as used for an error message. 410 * Get the message about the source, as used for an error message.
415 * Returns an allocated string with room for one more character. 411 * Returns an allocated string with room for one more character.
416 * Returns NULL when no message is to be given. 412 * Returns NULL when no message is to be given.
417 */ 413 */
418 static char_u * 414 static char_u *
419 get_emsg_source() 415 get_emsg_source(void)
420 { 416 {
421 char_u *Buf, *p; 417 char_u *Buf, *p;
422 418
423 if (sourcing_name != NULL && other_sourcing_name()) 419 if (sourcing_name != NULL && other_sourcing_name())
424 { 420 {
435 * Get the message about the source lnum, as used for an error message. 431 * Get the message about the source lnum, as used for an error message.
436 * Returns an allocated string with room for one more character. 432 * Returns an allocated string with room for one more character.
437 * Returns NULL when no message is to be given. 433 * Returns NULL when no message is to be given.
438 */ 434 */
439 static char_u * 435 static char_u *
440 get_emsg_lnum() 436 get_emsg_lnum(void)
441 { 437 {
442 char_u *Buf, *p; 438 char_u *Buf, *p;
443 439
444 /* lnum is 0 when executing a command from the command line 440 /* lnum is 0 when executing a command from the command line
445 * argument, we don't want a line number then */ 441 * argument, we don't want a line number then */
460 * Display name and line number for the source of an error. 456 * Display name and line number for the source of an error.
461 * Remember the file name and line number, so that for the next error the info 457 * Remember the file name and line number, so that for the next error the info
462 * is only displayed if it changed. 458 * is only displayed if it changed.
463 */ 459 */
464 void 460 void
465 msg_source(attr) 461 msg_source(int attr)
466 int attr;
467 { 462 {
468 char_u *p; 463 char_u *p;
469 464
470 ++no_wait_return; 465 ++no_wait_return;
471 p = get_emsg_source(); 466 p = get_emsg_source();
499 * If "emsg_off" is set: no error messages at the moment. 494 * If "emsg_off" is set: no error messages at the moment.
500 * If "msg" is in 'debug': do error message but without side effects. 495 * If "msg" is in 'debug': do error message but without side effects.
501 * If "emsg_skip" is set: never do error messages. 496 * If "emsg_skip" is set: never do error messages.
502 */ 497 */
503 int 498 int
504 emsg_not_now() 499 emsg_not_now(void)
505 { 500 {
506 if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL 501 if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
507 && vim_strchr(p_debug, 't') == NULL) 502 && vim_strchr(p_debug, 't') == NULL)
508 #ifdef FEAT_EVAL 503 #ifdef FEAT_EVAL
509 || emsg_skip > 0 504 || emsg_skip > 0
520 * When terminal not initialized (yet) mch_errmsg(..) is used. 515 * When terminal not initialized (yet) mch_errmsg(..) is used.
521 * 516 *
522 * return TRUE if wait_return not called 517 * return TRUE if wait_return not called
523 */ 518 */
524 int 519 int
525 emsg(s) 520 emsg(char_u *s)
526 char_u *s;
527 { 521 {
528 int attr; 522 int attr;
529 char_u *p; 523 char_u *p;
530 #ifdef FEAT_EVAL 524 #ifdef FEAT_EVAL
531 int ignore = FALSE; 525 int ignore = FALSE;
631 625
632 /* 626 /*
633 * Print an error message with one "%s" and one string argument. 627 * Print an error message with one "%s" and one string argument.
634 */ 628 */
635 int 629 int
636 emsg2(s, a1) 630 emsg2(char_u *s, char_u *a1)
637 char_u *s, *a1;
638 { 631 {
639 return emsg3(s, a1, NULL); 632 return emsg3(s, a1, NULL);
640 } 633 }
641 634
642 /* emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. */ 635 /* emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. */
643 636
644 void 637 void
645 emsg_invreg(name) 638 emsg_invreg(int name)
646 int name;
647 { 639 {
648 EMSG2(_("E354: Invalid register name: '%s'"), transchar(name)); 640 EMSG2(_("E354: Invalid register name: '%s'"), transchar(name));
649 } 641 }
650 642
651 /* 643 /*
653 * "force" is TRUE. This truncates in another way as for normal messages. 645 * "force" is TRUE. This truncates in another way as for normal messages.
654 * Careful: The string may be changed by msg_may_trunc()! 646 * Careful: The string may be changed by msg_may_trunc()!
655 * Returns a pointer to the printed message, if wait_return() not called. 647 * Returns a pointer to the printed message, if wait_return() not called.
656 */ 648 */
657 char_u * 649 char_u *
658 msg_trunc_attr(s, force, attr) 650 msg_trunc_attr(char_u *s, int force, int attr)
659 char_u *s;
660 int force;
661 int attr;
662 { 651 {
663 int n; 652 int n;
664 653
665 /* Add message to history before truncating */ 654 /* Add message to history before truncating */
666 add_msg_hist(s, -1, attr); 655 add_msg_hist(s, -1, attr);
680 * Check if message "s" should be truncated at the start (for filenames). 669 * Check if message "s" should be truncated at the start (for filenames).
681 * Return a pointer to where the truncated message starts. 670 * Return a pointer to where the truncated message starts.
682 * Note: May change the message by replacing a character with '<'. 671 * Note: May change the message by replacing a character with '<'.
683 */ 672 */
684 char_u * 673 char_u *
685 msg_may_trunc(force, s) 674 msg_may_trunc(int force, char_u *s)
686 int force;
687 char_u *s;
688 { 675 {
689 int n; 676 int n;
690 int room; 677 int room;
691 678
692 room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1; 679 room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
715 } 702 }
716 return s; 703 return s;
717 } 704 }
718 705
719 static void 706 static void
720 add_msg_hist(s, len, attr) 707 add_msg_hist(
721 char_u *s; 708 char_u *s,
722 int len; /* -1 for undetermined length */ 709 int len, /* -1 for undetermined length */
723 int attr; 710 int attr)
724 { 711 {
725 struct msg_hist *p; 712 struct msg_hist *p;
726 713
727 if (msg_hist_off || msg_silent != 0) 714 if (msg_hist_off || msg_silent != 0)
728 return; 715 return;
760 /* 747 /*
761 * Delete the first (oldest) message from the history. 748 * Delete the first (oldest) message from the history.
762 * Returns FAIL if there are no messages. 749 * Returns FAIL if there are no messages.
763 */ 750 */
764 int 751 int
765 delete_first_msg() 752 delete_first_msg(void)
766 { 753 {
767 struct msg_hist *p; 754 struct msg_hist *p;
768 755
769 if (msg_hist_len <= 0) 756 if (msg_hist_len <= 0)
770 return FAIL; 757 return FAIL;
780 767
781 /* 768 /*
782 * ":messages" command. 769 * ":messages" command.
783 */ 770 */
784 void 771 void
785 ex_messages(eap) 772 ex_messages(exarg_T *eap UNUSED)
786 exarg_T *eap UNUSED;
787 { 773 {
788 struct msg_hist *p; 774 struct msg_hist *p;
789 char_u *s; 775 char_u *s;
790 776
791 msg_hist_off = TRUE; 777 msg_hist_off = TRUE;
807 /* 793 /*
808 * Call this after prompting the user. This will avoid a hit-return message 794 * Call this after prompting the user. This will avoid a hit-return message
809 * and a delay. 795 * and a delay.
810 */ 796 */
811 void 797 void
812 msg_end_prompt() 798 msg_end_prompt(void)
813 { 799 {
814 need_wait_return = FALSE; 800 need_wait_return = FALSE;
815 emsg_on_display = FALSE; 801 emsg_on_display = FALSE;
816 cmdline_row = msg_row; 802 cmdline_row = msg_row;
817 msg_col = 0; 803 msg_col = 0;
825 * if 'redraw' is TRUE, clear and redraw the screen 811 * if 'redraw' is TRUE, clear and redraw the screen
826 * if 'redraw' is FALSE, just redraw the screen 812 * if 'redraw' is FALSE, just redraw the screen
827 * if 'redraw' is -1, don't redraw at all 813 * if 'redraw' is -1, don't redraw at all
828 */ 814 */
829 void 815 void
830 wait_return(redraw) 816 wait_return(int redraw)
831 int redraw;
832 { 817 {
833 int c; 818 int c;
834 int oldState; 819 int oldState;
835 int tmpState; 820 int tmpState;
836 int had_got_int; 821 int had_got_int;
1074 1059
1075 /* 1060 /*
1076 * Write the hit-return prompt. 1061 * Write the hit-return prompt.
1077 */ 1062 */
1078 static void 1063 static void
1079 hit_return_msg() 1064 hit_return_msg(void)
1080 { 1065 {
1081 int save_p_more = p_more; 1066 int save_p_more = p_more;
1082 1067
1083 p_more = FALSE; /* don't want see this message when scrolling back */ 1068 p_more = FALSE; /* don't want see this message when scrolling back */
1084 if (msg_didout) /* start on a new line */ 1069 if (msg_didout) /* start on a new line */
1094 1079
1095 /* 1080 /*
1096 * Set "keep_msg" to "s". Free the old value and check for NULL pointer. 1081 * Set "keep_msg" to "s". Free the old value and check for NULL pointer.
1097 */ 1082 */
1098 void 1083 void
1099 set_keep_msg(s, attr) 1084 set_keep_msg(char_u *s, int attr)
1100 char_u *s;
1101 int attr;
1102 { 1085 {
1103 vim_free(keep_msg); 1086 vim_free(keep_msg);
1104 if (s != NULL && msg_silent == 0) 1087 if (s != NULL && msg_silent == 0)
1105 keep_msg = vim_strsave(s); 1088 keep_msg = vim_strsave(s);
1106 else 1089 else
1113 /* 1096 /*
1114 * If there currently is a message being displayed, set "keep_msg" to it, so 1097 * If there currently is a message being displayed, set "keep_msg" to it, so
1115 * that it will be displayed again after redraw. 1098 * that it will be displayed again after redraw.
1116 */ 1099 */
1117 void 1100 void
1118 set_keep_msg_from_hist() 1101 set_keep_msg_from_hist(void)
1119 { 1102 {
1120 if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0 1103 if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0
1121 && (State & NORMAL)) 1104 && (State & NORMAL))
1122 set_keep_msg(last_msg_hist->msg, last_msg_hist->attr); 1105 set_keep_msg(last_msg_hist->msg, last_msg_hist->attr);
1123 } 1106 }
1125 1108
1126 /* 1109 /*
1127 * Prepare for outputting characters in the command line. 1110 * Prepare for outputting characters in the command line.
1128 */ 1111 */
1129 void 1112 void
1130 msg_start() 1113 msg_start(void)
1131 { 1114 {
1132 int did_return = FALSE; 1115 int did_return = FALSE;
1133 1116
1134 if (!msg_silent) 1117 if (!msg_silent)
1135 { 1118 {
1178 1161
1179 /* 1162 /*
1180 * Note that the current msg position is where messages start. 1163 * Note that the current msg position is where messages start.
1181 */ 1164 */
1182 void 1165 void
1183 msg_starthere() 1166 msg_starthere(void)
1184 { 1167 {
1185 lines_left = cmdline_row; 1168 lines_left = cmdline_row;
1186 msg_didany = FALSE; 1169 msg_didany = FALSE;
1187 } 1170 }
1188 1171
1189 void 1172 void
1190 msg_putchar(c) 1173 msg_putchar(int c)
1191 int c;
1192 { 1174 {
1193 msg_putchar_attr(c, 0); 1175 msg_putchar_attr(c, 0);
1194 } 1176 }
1195 1177
1196 void 1178 void
1197 msg_putchar_attr(c, attr) 1179 msg_putchar_attr(int c, int attr)
1198 int c;
1199 int attr;
1200 { 1180 {
1201 #ifdef FEAT_MBYTE 1181 #ifdef FEAT_MBYTE
1202 char_u buf[MB_MAXBYTES + 1]; 1182 char_u buf[MB_MAXBYTES + 1];
1203 #else 1183 #else
1204 char_u buf[4]; 1184 char_u buf[4];
1222 } 1202 }
1223 msg_puts_attr(buf, attr); 1203 msg_puts_attr(buf, attr);
1224 } 1204 }
1225 1205
1226 void 1206 void
1227 msg_outnum(n) 1207 msg_outnum(long n)
1228 long n;
1229 { 1208 {
1230 char_u buf[20]; 1209 char_u buf[20];
1231 1210
1232 sprintf((char *)buf, "%ld", n); 1211 sprintf((char *)buf, "%ld", n);
1233 msg_puts(buf); 1212 msg_puts(buf);
1234 } 1213 }
1235 1214
1236 void 1215 void
1237 msg_home_replace(fname) 1216 msg_home_replace(char_u *fname)
1238 char_u *fname;
1239 { 1217 {
1240 msg_home_replace_attr(fname, 0); 1218 msg_home_replace_attr(fname, 0);
1241 } 1219 }
1242 1220
1243 #if defined(FEAT_FIND_ID) || defined(PROTO) 1221 #if defined(FEAT_FIND_ID) || defined(PROTO)
1244 void 1222 void
1245 msg_home_replace_hl(fname) 1223 msg_home_replace_hl(char_u *fname)
1246 char_u *fname;
1247 { 1224 {
1248 msg_home_replace_attr(fname, hl_attr(HLF_D)); 1225 msg_home_replace_attr(fname, hl_attr(HLF_D));
1249 } 1226 }
1250 #endif 1227 #endif
1251 1228
1252 static void 1229 static void
1253 msg_home_replace_attr(fname, attr) 1230 msg_home_replace_attr(char_u *fname, int attr)
1254 char_u *fname;
1255 int attr;
1256 { 1231 {
1257 char_u *name; 1232 char_u *name;
1258 1233
1259 name = home_replace_save(NULL, fname); 1234 name = home_replace_save(NULL, fname);
1260 if (name != NULL) 1235 if (name != NULL)
1267 * if 'len' is -1, output upto a NUL character. 1242 * if 'len' is -1, output upto a NUL character.
1268 * Use attributes 'attr'. 1243 * Use attributes 'attr'.
1269 * Return the number of characters it takes on the screen. 1244 * Return the number of characters it takes on the screen.
1270 */ 1245 */
1271 int 1246 int
1272 msg_outtrans(str) 1247 msg_outtrans(char_u *str)
1273 char_u *str;
1274 { 1248 {
1275 return msg_outtrans_attr(str, 0); 1249 return msg_outtrans_attr(str, 0);
1276 } 1250 }
1277 1251
1278 int 1252 int
1279 msg_outtrans_attr(str, attr) 1253 msg_outtrans_attr(char_u *str, int attr)
1280 char_u *str;
1281 int attr;
1282 { 1254 {
1283 return msg_outtrans_len_attr(str, (int)STRLEN(str), attr); 1255 return msg_outtrans_len_attr(str, (int)STRLEN(str), attr);
1284 } 1256 }
1285 1257
1286 int 1258 int
1287 msg_outtrans_len(str, len) 1259 msg_outtrans_len(char_u *str, int len)
1288 char_u *str;
1289 int len;
1290 { 1260 {
1291 return msg_outtrans_len_attr(str, len, 0); 1261 return msg_outtrans_len_attr(str, len, 0);
1292 } 1262 }
1293 1263
1294 /* 1264 /*
1295 * Output one character at "p". Return pointer to the next character. 1265 * Output one character at "p". Return pointer to the next character.
1296 * Handles multi-byte characters. 1266 * Handles multi-byte characters.
1297 */ 1267 */
1298 char_u * 1268 char_u *
1299 msg_outtrans_one(p, attr) 1269 msg_outtrans_one(char_u *p, int attr)
1300 char_u *p;
1301 int attr;
1302 { 1270 {
1303 #ifdef FEAT_MBYTE 1271 #ifdef FEAT_MBYTE
1304 int l; 1272 int l;
1305 1273
1306 if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) 1274 if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
1312 msg_puts_attr(transchar_byte(*p), attr); 1280 msg_puts_attr(transchar_byte(*p), attr);
1313 return p + 1; 1281 return p + 1;
1314 } 1282 }
1315 1283
1316 int 1284 int
1317 msg_outtrans_len_attr(msgstr, len, attr) 1285 msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
1318 char_u *msgstr;
1319 int len;
1320 int attr;
1321 { 1286 {
1322 int retval = 0; 1287 int retval = 0;
1323 char_u *str = msgstr; 1288 char_u *str = msgstr;
1324 char_u *plain_start = msgstr; 1289 char_u *plain_start = msgstr;
1325 char_u *s; 1290 char_u *s;
1404 return retval; 1369 return retval;
1405 } 1370 }
1406 1371
1407 #if defined(FEAT_QUICKFIX) || defined(PROTO) 1372 #if defined(FEAT_QUICKFIX) || defined(PROTO)
1408 void 1373 void
1409 msg_make(arg) 1374 msg_make(char_u *arg)
1410 char_u *arg;
1411 { 1375 {
1412 int i; 1376 int i;
1413 static char_u *str = (char_u *)"eeffoc", *rs = (char_u *)"Plon#dqg#vxjduB"; 1377 static char_u *str = (char_u *)"eeffoc", *rs = (char_u *)"Plon#dqg#vxjduB";
1414 1378
1415 arg = skipwhite(arg); 1379 arg = skipwhite(arg);
1438 * Otherwise characters are not highlighted. 1402 * Otherwise characters are not highlighted.
1439 * This function is used to show mappings, where we want to see how to type 1403 * This function is used to show mappings, where we want to see how to type
1440 * the character/string -- webb 1404 * the character/string -- webb
1441 */ 1405 */
1442 int 1406 int
1443 msg_outtrans_special(strstart, from) 1407 msg_outtrans_special(
1444 char_u *strstart; 1408 char_u *strstart,
1445 int from; /* TRUE for lhs of a mapping */ 1409 int from) /* TRUE for lhs of a mapping */
1446 { 1410 {
1447 char_u *str = strstart; 1411 char_u *str = strstart;
1448 int retval = 0; 1412 int retval = 0;
1449 char_u *string; 1413 char_u *string;
1450 int attr; 1414 int attr;
1477 /* 1441 /*
1478 * Return the lhs or rhs of a mapping, with the key codes turned into printable 1442 * Return the lhs or rhs of a mapping, with the key codes turned into printable
1479 * strings, in an allocated string. 1443 * strings, in an allocated string.
1480 */ 1444 */
1481 char_u * 1445 char_u *
1482 str2special_save(str, is_lhs) 1446 str2special_save(
1483 char_u *str; 1447 char_u *str,
1484 int is_lhs; /* TRUE for lhs, FALSE for rhs */ 1448 int is_lhs) /* TRUE for lhs, FALSE for rhs */
1485 { 1449 {
1486 garray_T ga; 1450 garray_T ga;
1487 char_u *p = str; 1451 char_u *p = str;
1488 1452
1489 ga_init2(&ga, 1, 40); 1453 ga_init2(&ga, 1, 40);
1498 * Return the printable string for the key codes at "*sp". 1462 * Return the printable string for the key codes at "*sp".
1499 * Used for translating the lhs or rhs of a mapping to printable chars. 1463 * Used for translating the lhs or rhs of a mapping to printable chars.
1500 * Advances "sp" to the next code. 1464 * Advances "sp" to the next code.
1501 */ 1465 */
1502 char_u * 1466 char_u *
1503 str2special(sp, from) 1467 str2special(
1504 char_u **sp; 1468 char_u **sp,
1505 int from; /* TRUE for lhs of mapping */ 1469 int from) /* TRUE for lhs of mapping */
1506 { 1470 {
1507 int c; 1471 int c;
1508 static char_u buf[7]; 1472 static char_u buf[7];
1509 char_u *str = *sp; 1473 char_u *str = *sp;
1510 int modifiers = 0; 1474 int modifiers = 0;
1575 1539
1576 /* 1540 /*
1577 * Translate a key sequence into special key names. 1541 * Translate a key sequence into special key names.
1578 */ 1542 */
1579 void 1543 void
1580 str2specialbuf(sp, buf, len) 1544 str2specialbuf(char_u *sp, char_u *buf, int len)
1581 char_u *sp;
1582 char_u *buf;
1583 int len;
1584 { 1545 {
1585 char_u *s; 1546 char_u *s;
1586 1547
1587 *buf = NUL; 1548 *buf = NUL;
1588 while (*sp) 1549 while (*sp)
1595 1556
1596 /* 1557 /*
1597 * print line for :print or :list command 1558 * print line for :print or :list command
1598 */ 1559 */
1599 void 1560 void
1600 msg_prt_line(s, list) 1561 msg_prt_line(char_u *s, int list)
1601 char_u *s;
1602 int list;
1603 { 1562 {
1604 int c; 1563 int c;
1605 int col = 0; 1564 int col = 0;
1606 int n_extra = 0; 1565 int n_extra = 0;
1607 int c_extra = 0; 1566 int c_extra = 0;
1730 /* 1689 /*
1731 * Use screen_puts() to output one multi-byte character. 1690 * Use screen_puts() to output one multi-byte character.
1732 * Return the pointer "s" advanced to the next character. 1691 * Return the pointer "s" advanced to the next character.
1733 */ 1692 */
1734 static char_u * 1693 static char_u *
1735 screen_puts_mbyte(s, l, attr) 1694 screen_puts_mbyte(char_u *s, int l, int attr)
1736 char_u *s;
1737 int l;
1738 int attr;
1739 { 1695 {
1740 int cw; 1696 int cw;
1741 1697
1742 msg_didout = TRUE; /* remember that line is not empty */ 1698 msg_didout = TRUE; /* remember that line is not empty */
1743 cw = (*mb_ptr2cells)(s); 1699 cw = (*mb_ptr2cells)(s);
1780 /* 1736 /*
1781 * Output a string to the screen at position msg_row, msg_col. 1737 * Output a string to the screen at position msg_row, msg_col.
1782 * Update msg_row and msg_col for the next message. 1738 * Update msg_row and msg_col for the next message.
1783 */ 1739 */
1784 void 1740 void
1785 msg_puts(s) 1741 msg_puts(char_u *s)
1786 char_u *s; 1742 {
1787 { 1743 msg_puts_attr(s, 0);
1788 msg_puts_attr(s, 0);
1789 } 1744 }
1790 1745
1791 void 1746 void
1792 msg_puts_title(s) 1747 msg_puts_title(
1793 char_u *s; 1748 char_u *s)
1794 { 1749 {
1795 msg_puts_attr(s, hl_attr(HLF_T)); 1750 msg_puts_attr(s, hl_attr(HLF_T));
1796 } 1751 }
1797 1752
1798 /* 1753 /*
1799 * Show a message in such a way that it always fits in the line. Cut out a 1754 * Show a message in such a way that it always fits in the line. Cut out a
1800 * part in the middle and replace it with "..." when necessary. 1755 * part in the middle and replace it with "..." when necessary.
1801 * Does not handle multi-byte characters! 1756 * Does not handle multi-byte characters!
1802 */ 1757 */
1803 void 1758 void
1804 msg_puts_long_attr(longstr, attr) 1759 msg_puts_long_attr(char_u *longstr, int attr)
1805 char_u *longstr;
1806 int attr;
1807 { 1760 {
1808 msg_puts_long_len_attr(longstr, (int)STRLEN(longstr), attr); 1761 msg_puts_long_len_attr(longstr, (int)STRLEN(longstr), attr);
1809 } 1762 }
1810 1763
1811 void 1764 void
1812 msg_puts_long_len_attr(longstr, len, attr) 1765 msg_puts_long_len_attr(char_u *longstr, int len, int attr)
1813 char_u *longstr;
1814 int len;
1815 int attr;
1816 { 1766 {
1817 int slen = len; 1767 int slen = len;
1818 int room; 1768 int room;
1819 1769
1820 room = Columns - msg_col; 1770 room = Columns - msg_col;
1829 1779
1830 /* 1780 /*
1831 * Basic function for writing a message with highlight attributes. 1781 * Basic function for writing a message with highlight attributes.
1832 */ 1782 */
1833 void 1783 void
1834 msg_puts_attr(s, attr) 1784 msg_puts_attr(char_u *s, int attr)
1835 char_u *s;
1836 int attr;
1837 { 1785 {
1838 msg_puts_attr_len(s, -1, attr); 1786 msg_puts_attr_len(s, -1, attr);
1839 } 1787 }
1840 1788
1841 /* 1789 /*
1842 * Like msg_puts_attr(), but with a maximum length "maxlen" (in bytes). 1790 * Like msg_puts_attr(), but with a maximum length "maxlen" (in bytes).
1843 * When "maxlen" is -1 there is no maximum length. 1791 * When "maxlen" is -1 there is no maximum length.
1844 * When "maxlen" is >= 0 the message is not put in the history. 1792 * When "maxlen" is >= 0 the message is not put in the history.
1845 */ 1793 */
1846 static void 1794 static void
1847 msg_puts_attr_len(str, maxlen, attr) 1795 msg_puts_attr_len(char_u *str, int maxlen, int attr)
1848 char_u *str;
1849 int maxlen;
1850 int attr;
1851 { 1796 {
1852 /* 1797 /*
1853 * If redirection is on, also write to the redirection file. 1798 * If redirection is on, also write to the redirection file.
1854 */ 1799 */
1855 redir_write(str, maxlen); 1800 redir_write(str, maxlen);
1893 /* 1838 /*
1894 * The display part of msg_puts_attr_len(). 1839 * The display part of msg_puts_attr_len().
1895 * May be called recursively to display scroll-back text. 1840 * May be called recursively to display scroll-back text.
1896 */ 1841 */
1897 static void 1842 static void
1898 msg_puts_display(str, maxlen, attr, recurse) 1843 msg_puts_display(
1899 char_u *str; 1844 char_u *str,
1900 int maxlen; 1845 int maxlen,
1901 int attr; 1846 int attr,
1902 int recurse; 1847 int recurse)
1903 { 1848 {
1904 char_u *s = str; 1849 char_u *s = str;
1905 char_u *t_s = str; /* string from "t_s" to "s" is still todo */ 1850 char_u *t_s = str; /* string from "t_s" to "s" is still todo */
1906 int t_col = 0; /* screen cells todo, 0 when "t_s" not used */ 1851 int t_col = 0; /* screen cells todo, 0 when "t_s" not used */
1907 #ifdef FEAT_MBYTE 1852 #ifdef FEAT_MBYTE
2137 2082
2138 /* 2083 /*
2139 * Scroll the screen up one line for displaying the next message line. 2084 * Scroll the screen up one line for displaying the next message line.
2140 */ 2085 */
2141 static void 2086 static void
2142 msg_scroll_up() 2087 msg_scroll_up(void)
2143 { 2088 {
2144 #ifdef FEAT_GUI 2089 #ifdef FEAT_GUI
2145 /* Remove the cursor before scrolling, ScreenLines[] is going 2090 /* Remove the cursor before scrolling, ScreenLines[] is going
2146 * to become invalid. */ 2091 * to become invalid. */
2147 if (gui.in_use) 2092 if (gui.in_use)
2167 2112
2168 /* 2113 /*
2169 * Increment "msg_scrolled". 2114 * Increment "msg_scrolled".
2170 */ 2115 */
2171 static void 2116 static void
2172 inc_msg_scrolled() 2117 inc_msg_scrolled(void)
2173 { 2118 {
2174 #ifdef FEAT_EVAL 2119 #ifdef FEAT_EVAL
2175 if (*get_vim_var_str(VV_SCROLLSTART) == NUL) 2120 if (*get_vim_var_str(VV_SCROLLSTART) == NUL)
2176 { 2121 {
2177 char_u *p = sourcing_name; 2122 char_u *p = sourcing_name;
2224 2169
2225 /* 2170 /*
2226 * Store part of a printed message for displaying when scrolling back. 2171 * Store part of a printed message for displaying when scrolling back.
2227 */ 2172 */
2228 static void 2173 static void
2229 store_sb_text(sb_str, s, attr, sb_col, finish) 2174 store_sb_text(
2230 char_u **sb_str; /* start of string */ 2175 char_u **sb_str, /* start of string */
2231 char_u *s; /* just after string */ 2176 char_u *s, /* just after string */
2232 int attr; 2177 int attr,
2233 int *sb_col; 2178 int *sb_col,
2234 int finish; /* line ends */ 2179 int finish) /* line ends */
2235 { 2180 {
2236 msgchunk_T *mp; 2181 msgchunk_T *mp;
2237 2182
2238 if (do_clear_sb_text) 2183 if (do_clear_sb_text)
2239 { 2184 {
2274 2219
2275 /* 2220 /*
2276 * Finished showing messages, clear the scroll-back text on the next message. 2221 * Finished showing messages, clear the scroll-back text on the next message.
2277 */ 2222 */
2278 void 2223 void
2279 may_clear_sb_text() 2224 may_clear_sb_text(void)
2280 { 2225 {
2281 do_clear_sb_text = TRUE; 2226 do_clear_sb_text = TRUE;
2282 } 2227 }
2283 2228
2284 /* 2229 /*
2285 * Clear any text remembered for scrolling back. 2230 * Clear any text remembered for scrolling back.
2286 * Called when redrawing the screen. 2231 * Called when redrawing the screen.
2287 */ 2232 */
2288 void 2233 void
2289 clear_sb_text() 2234 clear_sb_text(void)
2290 { 2235 {
2291 msgchunk_T *mp; 2236 msgchunk_T *mp;
2292 2237
2293 while (last_msgchunk != NULL) 2238 while (last_msgchunk != NULL)
2294 { 2239 {
2300 2245
2301 /* 2246 /*
2302 * "g<" command. 2247 * "g<" command.
2303 */ 2248 */
2304 void 2249 void
2305 show_sb_text() 2250 show_sb_text(void)
2306 { 2251 {
2307 msgchunk_T *mp; 2252 msgchunk_T *mp;
2308 2253
2309 /* Only show something if there is more than one line, otherwise it looks 2254 /* Only show something if there is more than one line, otherwise it looks
2310 * weird, typing a command without output results in one line. */ 2255 * weird, typing a command without output results in one line. */
2320 2265
2321 /* 2266 /*
2322 * Move to the start of screen line in already displayed text. 2267 * Move to the start of screen line in already displayed text.
2323 */ 2268 */
2324 static msgchunk_T * 2269 static msgchunk_T *
2325 msg_sb_start(mps) 2270 msg_sb_start(msgchunk_T *mps)
2326 msgchunk_T *mps;
2327 { 2271 {
2328 msgchunk_T *mp = mps; 2272 msgchunk_T *mp = mps;
2329 2273
2330 while (mp != NULL && mp->sb_prev != NULL && !mp->sb_prev->sb_eol) 2274 while (mp != NULL && mp->sb_prev != NULL && !mp->sb_prev->sb_eol)
2331 mp = mp->sb_prev; 2275 mp = mp->sb_prev;
2334 2278
2335 /* 2279 /*
2336 * Mark the last message chunk as finishing the line. 2280 * Mark the last message chunk as finishing the line.
2337 */ 2281 */
2338 void 2282 void
2339 msg_sb_eol() 2283 msg_sb_eol(void)
2340 { 2284 {
2341 if (last_msgchunk != NULL) 2285 if (last_msgchunk != NULL)
2342 last_msgchunk->sb_eol = TRUE; 2286 last_msgchunk->sb_eol = TRUE;
2343 } 2287 }
2344 2288
2345 /* 2289 /*
2346 * Display a screen line from previously displayed text at row "row". 2290 * Display a screen line from previously displayed text at row "row".
2347 * Returns a pointer to the text for the next line (can be NULL). 2291 * Returns a pointer to the text for the next line (can be NULL).
2348 */ 2292 */
2349 static msgchunk_T * 2293 static msgchunk_T *
2350 disp_sb_line(row, smp) 2294 disp_sb_line(int row, msgchunk_T *smp)
2351 int row;
2352 msgchunk_T *smp;
2353 { 2295 {
2354 msgchunk_T *mp = smp; 2296 msgchunk_T *mp = smp;
2355 char_u *p; 2297 char_u *p;
2356 2298
2357 for (;;) 2299 for (;;)
2371 2313
2372 /* 2314 /*
2373 * Output any postponed text for msg_puts_attr_len(). 2315 * Output any postponed text for msg_puts_attr_len().
2374 */ 2316 */
2375 static void 2317 static void
2376 t_puts(t_col, t_s, s, attr) 2318 t_puts(
2377 int *t_col; 2319 int *t_col,
2378 char_u *t_s; 2320 char_u *t_s,
2379 char_u *s; 2321 char_u *s,
2380 int attr; 2322 int attr)
2381 { 2323 {
2382 /* output postponed text */ 2324 /* output postponed text */
2383 msg_didout = TRUE; /* remember that line is not empty */ 2325 msg_didout = TRUE; /* remember that line is not empty */
2384 screen_puts_len(t_s, (int)(s - t_s), msg_row, msg_col, attr); 2326 screen_puts_len(t_s, (int)(s - t_s), msg_row, msg_col, attr);
2385 msg_col += *t_col; 2327 msg_col += *t_col;
2404 * window, cursor positioning may not work correctly (window size may be 2346 * window, cursor positioning may not work correctly (window size may be
2405 * different, e.g. for Win32 console) or we just don't know where the 2347 * different, e.g. for Win32 console) or we just don't know where the
2406 * cursor is. 2348 * cursor is.
2407 */ 2349 */
2408 int 2350 int
2409 msg_use_printf() 2351 msg_use_printf(void)
2410 { 2352 {
2411 return (!msg_check_screen() 2353 return (!msg_check_screen()
2412 #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN) 2354 #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN)
2413 || !termcap_active 2355 || !termcap_active
2414 #endif 2356 #endif
2418 2360
2419 /* 2361 /*
2420 * Print a message when there is no valid screen. 2362 * Print a message when there is no valid screen.
2421 */ 2363 */
2422 static void 2364 static void
2423 msg_puts_printf(str, maxlen) 2365 msg_puts_printf(char_u *str, int maxlen)
2424 char_u *str;
2425 int maxlen;
2426 { 2366 {
2427 char_u *s = str; 2367 char_u *s = str;
2428 char_u buf[4]; 2368 char_u buf[4];
2429 char_u *p; 2369 char_u *p;
2430 2370
2485 * When at hit-enter prompt "typed_char" is the already typed character, 2425 * When at hit-enter prompt "typed_char" is the already typed character,
2486 * otherwise it's NUL. 2426 * otherwise it's NUL.
2487 * Returns TRUE when jumping ahead to "confirm_msg_tail". 2427 * Returns TRUE when jumping ahead to "confirm_msg_tail".
2488 */ 2428 */
2489 static int 2429 static int
2490 do_more_prompt(typed_char) 2430 do_more_prompt(int typed_char)
2491 int typed_char;
2492 { 2431 {
2493 int used_typed_char = typed_char; 2432 int used_typed_char = typed_char;
2494 int oldState = State; 2433 int oldState = State;
2495 int c; 2434 int c;
2496 #ifdef FEAT_CON_DIALOG 2435 #ifdef FEAT_CON_DIALOG
2759 * Give an error message. To be used when the screen hasn't been initialized 2698 * Give an error message. To be used when the screen hasn't been initialized
2760 * yet. When stderr can't be used, collect error messages until the GUI has 2699 * yet. When stderr can't be used, collect error messages until the GUI has
2761 * started and they can be displayed in a message box. 2700 * started and they can be displayed in a message box.
2762 */ 2701 */
2763 void 2702 void
2764 mch_errmsg(str) 2703 mch_errmsg(char *str)
2765 char *str;
2766 { 2704 {
2767 int len; 2705 int len;
2768 2706
2769 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) 2707 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
2770 /* On Unix use stderr if it's a tty. 2708 /* On Unix use stderr if it's a tty.
2828 * Give a message. To be used when the screen hasn't been initialized yet. 2766 * Give a message. To be used when the screen hasn't been initialized yet.
2829 * When there is no tty, collect messages until the GUI has started and they 2767 * When there is no tty, collect messages until the GUI has started and they
2830 * can be displayed in a message box. 2768 * can be displayed in a message box.
2831 */ 2769 */
2832 void 2770 void
2833 mch_msg(str) 2771 mch_msg(char *str)
2834 char *str;
2835 { 2772 {
2836 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) 2773 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
2837 /* On Unix use stdout if we have a tty. This allows "vim -h | more" and 2774 /* On Unix use stdout if we have a tty. This allows "vim -h | more" and
2838 * uses mch_errmsg() when started from the desktop. 2775 * uses mch_errmsg() when started from the desktop.
2839 * When not going to start the GUI also use stdout. 2776 * When not going to start the GUI also use stdout.
2865 /* 2802 /*
2866 * Put a character on the screen at the current message position and advance 2803 * Put a character on the screen at the current message position and advance
2867 * to the next position. Only for printable ASCII! 2804 * to the next position. Only for printable ASCII!
2868 */ 2805 */
2869 static void 2806 static void
2870 msg_screen_putchar(c, attr) 2807 msg_screen_putchar(int c, int attr)
2871 int c;
2872 int attr;
2873 { 2808 {
2874 msg_didout = TRUE; /* remember that line is not empty */ 2809 msg_didout = TRUE; /* remember that line is not empty */
2875 screen_putchar(c, msg_row, msg_col, attr); 2810 screen_putchar(c, msg_row, msg_col, attr);
2876 #ifdef FEAT_RIGHTLEFT 2811 #ifdef FEAT_RIGHTLEFT
2877 if (cmdmsg_rl) 2812 if (cmdmsg_rl)
2892 } 2827 }
2893 } 2828 }
2894 } 2829 }
2895 2830
2896 void 2831 void
2897 msg_moremsg(full) 2832 msg_moremsg(int full)
2898 int full;
2899 { 2833 {
2900 int attr; 2834 int attr;
2901 char_u *s = (char_u *)_("-- More --"); 2835 char_u *s = (char_u *)_("-- More --");
2902 2836
2903 attr = hl_attr(HLF_M); 2837 attr = hl_attr(HLF_M);
2911 /* 2845 /*
2912 * Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or 2846 * Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or
2913 * exmode_active. 2847 * exmode_active.
2914 */ 2848 */
2915 void 2849 void
2916 repeat_message() 2850 repeat_message(void)
2917 { 2851 {
2918 if (State == ASKMORE) 2852 if (State == ASKMORE)
2919 { 2853 {
2920 msg_moremsg(TRUE); /* display --more-- message again */ 2854 msg_moremsg(TRUE); /* display --more-- message again */
2921 msg_row = Rows - 1; 2855 msg_row = Rows - 1;
2952 * Also check msg_row and msg_col, if they are too big it may cause a crash. 2886 * Also check msg_row and msg_col, if they are too big it may cause a crash.
2953 * While starting the GUI the terminal codes will be set for the GUI, but the 2887 * While starting the GUI the terminal codes will be set for the GUI, but the
2954 * output goes to the terminal. Don't use the terminal codes then. 2888 * output goes to the terminal. Don't use the terminal codes then.
2955 */ 2889 */
2956 static int 2890 static int
2957 msg_check_screen() 2891 msg_check_screen(void)
2958 { 2892 {
2959 if (!full_screen || !screen_valid(FALSE)) 2893 if (!full_screen || !screen_valid(FALSE))
2960 return FALSE; 2894 return FALSE;
2961 2895
2962 if (msg_row >= Rows) 2896 if (msg_row >= Rows)
2969 /* 2903 /*
2970 * Clear from current message position to end of screen. 2904 * Clear from current message position to end of screen.
2971 * Skip this when ":silent" was used, no need to clear for redirection. 2905 * Skip this when ":silent" was used, no need to clear for redirection.
2972 */ 2906 */
2973 void 2907 void
2974 msg_clr_eos() 2908 msg_clr_eos(void)
2975 { 2909 {
2976 if (msg_silent == 0) 2910 if (msg_silent == 0)
2977 msg_clr_eos_force(); 2911 msg_clr_eos_force();
2978 } 2912 }
2979 2913
2981 * Clear from current message position to end of screen. 2915 * Clear from current message position to end of screen.
2982 * Note: msg_col is not updated, so we remember the end of the message 2916 * Note: msg_col is not updated, so we remember the end of the message
2983 * for msg_check(). 2917 * for msg_check().
2984 */ 2918 */
2985 void 2919 void
2986 msg_clr_eos_force() 2920 msg_clr_eos_force(void)
2987 { 2921 {
2988 if (msg_use_printf()) 2922 if (msg_use_printf())
2989 { 2923 {
2990 if (full_screen) /* only when termcap codes are valid */ 2924 if (full_screen) /* only when termcap codes are valid */
2991 { 2925 {
3015 2949
3016 /* 2950 /*
3017 * Clear the command line. 2951 * Clear the command line.
3018 */ 2952 */
3019 void 2953 void
3020 msg_clr_cmdline() 2954 msg_clr_cmdline(void)
3021 { 2955 {
3022 msg_row = cmdline_row; 2956 msg_row = cmdline_row;
3023 msg_col = 0; 2957 msg_col = 0;
3024 msg_clr_eos_force(); 2958 msg_clr_eos_force();
3025 } 2959 }
3028 * end putting a message on the screen 2962 * end putting a message on the screen
3029 * call wait_return if the message does not fit in the available space 2963 * call wait_return if the message does not fit in the available space
3030 * return TRUE if wait_return not called. 2964 * return TRUE if wait_return not called.
3031 */ 2965 */
3032 int 2966 int
3033 msg_end() 2967 msg_end(void)
3034 { 2968 {
3035 /* 2969 /*
3036 * If the string is larger than the window, 2970 * If the string is larger than the window,
3037 * or the ruler option is set and we run into it, 2971 * or the ruler option is set and we run into it,
3038 * we have to redraw the window. 2972 * we have to redraw the window.
3050 /* 2984 /*
3051 * If the written message runs into the shown command or ruler, we have to 2985 * If the written message runs into the shown command or ruler, we have to
3052 * wait for hit-return and redraw the window later. 2986 * wait for hit-return and redraw the window later.
3053 */ 2987 */
3054 void 2988 void
3055 msg_check() 2989 msg_check(void)
3056 { 2990 {
3057 if (msg_row == Rows - 1 && msg_col >= sc_col) 2991 if (msg_row == Rows - 1 && msg_col >= sc_col)
3058 { 2992 {
3059 need_wait_return = TRUE; 2993 need_wait_return = TRUE;
3060 redraw_cmdline = TRUE; 2994 redraw_cmdline = TRUE;
3064 /* 2998 /*
3065 * May write a string to the redirection file. 2999 * May write a string to the redirection file.
3066 * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes. 3000 * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes.
3067 */ 3001 */
3068 static void 3002 static void
3069 redir_write(str, maxlen) 3003 redir_write(char_u *str, int maxlen)
3070 char_u *str;
3071 int maxlen;
3072 { 3004 {
3073 char_u *s = str; 3005 char_u *s = str;
3074 static int cur_col = 0; 3006 static int cur_col = 0;
3075 3007
3076 /* Don't do anything for displaying prompts and the like. */ 3008 /* Don't do anything for displaying prompts and the like. */
3133 msg_col = cur_col; 3065 msg_col = cur_col;
3134 } 3066 }
3135 } 3067 }
3136 3068
3137 int 3069 int
3138 redirecting() 3070 redirecting(void)
3139 { 3071 {
3140 return redir_fd != NULL || *p_vfile != NUL 3072 return redir_fd != NULL || *p_vfile != NUL
3141 #ifdef FEAT_EVAL 3073 #ifdef FEAT_EVAL
3142 || redir_reg || redir_vname 3074 || redir_reg || redir_vname
3143 #endif 3075 #endif
3147 /* 3079 /*
3148 * Before giving verbose message. 3080 * Before giving verbose message.
3149 * Must always be called paired with verbose_leave()! 3081 * Must always be called paired with verbose_leave()!
3150 */ 3082 */
3151 void 3083 void
3152 verbose_enter() 3084 verbose_enter(void)
3153 { 3085 {
3154 if (*p_vfile != NUL) 3086 if (*p_vfile != NUL)
3155 ++msg_silent; 3087 ++msg_silent;
3156 } 3088 }
3157 3089
3158 /* 3090 /*
3159 * After giving verbose message. 3091 * After giving verbose message.
3160 * Must always be called paired with verbose_enter()! 3092 * Must always be called paired with verbose_enter()!
3161 */ 3093 */
3162 void 3094 void
3163 verbose_leave() 3095 verbose_leave(void)
3164 { 3096 {
3165 if (*p_vfile != NUL) 3097 if (*p_vfile != NUL)
3166 if (--msg_silent < 0) 3098 if (--msg_silent < 0)
3167 msg_silent = 0; 3099 msg_silent = 0;
3168 } 3100 }
3169 3101
3170 /* 3102 /*
3171 * Like verbose_enter() and set msg_scroll when displaying the message. 3103 * Like verbose_enter() and set msg_scroll when displaying the message.
3172 */ 3104 */
3173 void 3105 void
3174 verbose_enter_scroll() 3106 verbose_enter_scroll(void)
3175 { 3107 {
3176 if (*p_vfile != NUL) 3108 if (*p_vfile != NUL)
3177 ++msg_silent; 3109 ++msg_silent;
3178 else 3110 else
3179 /* always scroll up, don't overwrite */ 3111 /* always scroll up, don't overwrite */
3182 3114
3183 /* 3115 /*
3184 * Like verbose_leave() and set cmdline_row when displaying the message. 3116 * Like verbose_leave() and set cmdline_row when displaying the message.
3185 */ 3117 */
3186 void 3118 void
3187 verbose_leave_scroll() 3119 verbose_leave_scroll(void)
3188 { 3120 {
3189 if (*p_vfile != NUL) 3121 if (*p_vfile != NUL)
3190 { 3122 {
3191 if (--msg_silent < 0) 3123 if (--msg_silent < 0)
3192 msg_silent = 0; 3124 msg_silent = 0;
3197 3129
3198 /* 3130 /*
3199 * Called when 'verbosefile' is set: stop writing to the file. 3131 * Called when 'verbosefile' is set: stop writing to the file.
3200 */ 3132 */
3201 void 3133 void
3202 verbose_stop() 3134 verbose_stop(void)
3203 { 3135 {
3204 if (verbose_fd != NULL) 3136 if (verbose_fd != NULL)
3205 { 3137 {
3206 fclose(verbose_fd); 3138 fclose(verbose_fd);
3207 verbose_fd = NULL; 3139 verbose_fd = NULL;
3212 /* 3144 /*
3213 * Open the file 'verbosefile'. 3145 * Open the file 'verbosefile'.
3214 * Return FAIL or OK. 3146 * Return FAIL or OK.
3215 */ 3147 */
3216 int 3148 int
3217 verbose_open() 3149 verbose_open(void)
3218 { 3150 {
3219 if (verbose_fd == NULL && !verbose_did_open) 3151 if (verbose_fd == NULL && !verbose_did_open)
3220 { 3152 {
3221 /* Only give the error message once. */ 3153 /* Only give the error message once. */
3222 verbose_did_open = TRUE; 3154 verbose_did_open = TRUE;
3234 /* 3166 /*
3235 * Give a warning message (for searching). 3167 * Give a warning message (for searching).
3236 * Use 'w' highlighting and may repeat the message after redrawing 3168 * Use 'w' highlighting and may repeat the message after redrawing
3237 */ 3169 */
3238 void 3170 void
3239 give_warning(message, hl) 3171 give_warning(char_u *message, int hl)
3240 char_u *message;
3241 int hl;
3242 { 3172 {
3243 /* Don't do this for ":silent". */ 3173 /* Don't do this for ":silent". */
3244 if (msg_silent != 0) 3174 if (msg_silent != 0)
3245 return; 3175 return;
3246 3176
3267 3197
3268 /* 3198 /*
3269 * Advance msg cursor to column "col". 3199 * Advance msg cursor to column "col".
3270 */ 3200 */
3271 void 3201 void
3272 msg_advance(col) 3202 msg_advance(int col)
3273 int col;
3274 { 3203 {
3275 if (msg_silent != 0) /* nothing to advance to */ 3204 if (msg_silent != 0) /* nothing to advance to */
3276 { 3205 {
3277 msg_col = col; /* for redirection, may fill it up later */ 3206 msg_col = col; /* for redirection, may fill it up later */
3278 return; 3207 return;
3307 * Other buttons- use your imagination! 3236 * Other buttons- use your imagination!
3308 * A '&' in a button name becomes a shortcut, so each '&' should be before a 3237 * A '&' in a button name becomes a shortcut, so each '&' should be before a
3309 * different letter. 3238 * different letter.
3310 */ 3239 */
3311 int 3240 int
3312 do_dialog(type, title, message, buttons, dfltbutton, textfield, ex_cmd) 3241 do_dialog(
3313 int type UNUSED; 3242 int type UNUSED,
3314 char_u *title UNUSED; 3243 char_u *title UNUSED,
3315 char_u *message; 3244 char_u *message,
3316 char_u *buttons; 3245 char_u *buttons,
3317 int dfltbutton; 3246 int dfltbutton,
3318 char_u *textfield UNUSED; /* IObuff for inputdialog(), NULL 3247 char_u *textfield UNUSED, /* IObuff for inputdialog(), NULL
3319 otherwise */ 3248 otherwise */
3320 int ex_cmd; /* when TRUE pressing : accepts default and starts 3249 int ex_cmd) /* when TRUE pressing : accepts default and starts
3321 Ex command */ 3250 Ex command */
3322 { 3251 {
3323 int oldState; 3252 int oldState;
3324 int retval = 0; 3253 int retval = 0;
3325 char_u *hotkeys; 3254 char_u *hotkeys;
3435 /* 3364 /*
3436 * Copy one character from "*from" to "*to", taking care of multi-byte 3365 * Copy one character from "*from" to "*to", taking care of multi-byte
3437 * characters. Return the length of the character in bytes. 3366 * characters. Return the length of the character in bytes.
3438 */ 3367 */
3439 static int 3368 static int
3440 copy_char(from, to, lowercase) 3369 copy_char(
3441 char_u *from; 3370 char_u *from,
3442 char_u *to; 3371 char_u *to,
3443 int lowercase; /* make character lower case */ 3372 int lowercase) /* make character lower case */
3444 { 3373 {
3445 #ifdef FEAT_MBYTE 3374 #ifdef FEAT_MBYTE
3446 int len; 3375 int len;
3447 int c; 3376 int c;
3448 3377
3479 * The hotkeys can be multi-byte characters, but without combining chars. 3408 * The hotkeys can be multi-byte characters, but without combining chars.
3480 * 3409 *
3481 * Returns an allocated string with hotkeys, or NULL for error. 3410 * Returns an allocated string with hotkeys, or NULL for error.
3482 */ 3411 */
3483 static char_u * 3412 static char_u *
3484 msg_show_console_dialog(message, buttons, dfltbutton) 3413 msg_show_console_dialog(
3485 char_u *message; 3414 char_u *message,
3486 char_u *buttons; 3415 char_u *buttons,
3487 int dfltbutton; 3416 int dfltbutton)
3488 { 3417 {
3489 int len = 0; 3418 int len = 0;
3490 #ifdef FEAT_MBYTE 3419 #ifdef FEAT_MBYTE
3491 # define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1) 3420 # define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1)
3492 #else 3421 #else
3639 3568
3640 /* 3569 /*
3641 * Display the ":confirm" message. Also called when screen resized. 3570 * Display the ":confirm" message. Also called when screen resized.
3642 */ 3571 */
3643 void 3572 void
3644 display_confirm_msg() 3573 display_confirm_msg(void)
3645 { 3574 {
3646 /* avoid that 'q' at the more prompt truncates the message here */ 3575 /* avoid that 'q' at the more prompt truncates the message here */
3647 ++confirm_msg_used; 3576 ++confirm_msg_used;
3648 if (confirm_msg != NULL) 3577 if (confirm_msg != NULL)
3649 msg_puts_attr(confirm_msg, hl_attr(HLF_M)); 3578 msg_puts_attr(confirm_msg, hl_attr(HLF_M));
3653 #endif /* FEAT_CON_DIALOG */ 3582 #endif /* FEAT_CON_DIALOG */
3654 3583
3655 #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG) 3584 #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
3656 3585
3657 int 3586 int
3658 vim_dialog_yesno(type, title, message, dflt) 3587 vim_dialog_yesno(
3659 int type; 3588 int type,
3660 char_u *title; 3589 char_u *title,
3661 char_u *message; 3590 char_u *message,
3662 int dflt; 3591 int dflt)
3663 { 3592 {
3664 if (do_dialog(type, 3593 if (do_dialog(type,
3665 title == NULL ? (char_u *)_("Question") : title, 3594 title == NULL ? (char_u *)_("Question") : title,
3666 message, 3595 message,
3667 (char_u *)_("&Yes\n&No"), dflt, NULL, FALSE) == 1) 3596 (char_u *)_("&Yes\n&No"), dflt, NULL, FALSE) == 1)
3668 return VIM_YES; 3597 return VIM_YES;
3669 return VIM_NO; 3598 return VIM_NO;
3670 } 3599 }
3671 3600
3672 int 3601 int
3673 vim_dialog_yesnocancel(type, title, message, dflt) 3602 vim_dialog_yesnocancel(
3674 int type; 3603 int type,
3675 char_u *title; 3604 char_u *title,
3676 char_u *message; 3605 char_u *message,
3677 int dflt; 3606 int dflt)
3678 { 3607 {
3679 switch (do_dialog(type, 3608 switch (do_dialog(type,
3680 title == NULL ? (char_u *)_("Question") : title, 3609 title == NULL ? (char_u *)_("Question") : title,
3681 message, 3610 message,
3682 (char_u *)_("&Yes\n&No\n&Cancel"), dflt, NULL, FALSE)) 3611 (char_u *)_("&Yes\n&No\n&Cancel"), dflt, NULL, FALSE))
3686 } 3615 }
3687 return VIM_CANCEL; 3616 return VIM_CANCEL;
3688 } 3617 }
3689 3618
3690 int 3619 int
3691 vim_dialog_yesnoallcancel(type, title, message, dflt) 3620 vim_dialog_yesnoallcancel(
3692 int type; 3621 int type,
3693 char_u *title; 3622 char_u *title,
3694 char_u *message; 3623 char_u *message,
3695 int dflt; 3624 int dflt)
3696 { 3625 {
3697 switch (do_dialog(type, 3626 switch (do_dialog(type,
3698 title == NULL ? (char_u *)"Question" : title, 3627 title == NULL ? (char_u *)"Question" : title,
3699 message, 3628 message,
3700 (char_u *)_("&Yes\n&No\nSave &All\n&Discard All\n&Cancel"), 3629 (char_u *)_("&Yes\n&No\nSave &All\n&Discard All\n&Cancel"),
3714 /* 3643 /*
3715 * Generic browse function. Calls gui_mch_browse() when possible. 3644 * Generic browse function. Calls gui_mch_browse() when possible.
3716 * Later this may pop-up a non-GUI file selector (external command?). 3645 * Later this may pop-up a non-GUI file selector (external command?).
3717 */ 3646 */
3718 char_u * 3647 char_u *
3719 do_browse(flags, title, dflt, ext, initdir, filter, buf) 3648 do_browse(
3720 int flags; /* BROWSE_SAVE and BROWSE_DIR */ 3649 int flags, /* BROWSE_SAVE and BROWSE_DIR */
3721 char_u *title; /* title for the window */ 3650 char_u *title, /* title for the window */
3722 char_u *dflt; /* default file name (may include directory) */ 3651 char_u *dflt, /* default file name (may include directory) */
3723 char_u *ext; /* extension added */ 3652 char_u *ext, /* extension added */
3724 char_u *initdir; /* initial directory, NULL for current dir or 3653 char_u *initdir, /* initial directory, NULL for current dir or
3725 when using path from "dflt" */ 3654 when using path from "dflt" */
3726 char_u *filter; /* file name filter */ 3655 char_u *filter, /* file name filter */
3727 buf_T *buf; /* buffer to read/write for */ 3656 buf_T *buf) /* buffer to read/write for */
3728 { 3657 {
3729 char_u *fname; 3658 char_u *fname;
3730 static char_u *last_dir = NULL; /* last used directory */ 3659 static char_u *last_dir = NULL; /* last used directory */
3731 char_u *tofree = NULL; 3660 char_u *tofree = NULL;
3732 int save_browse = cmdmod.browse; 3661 int save_browse = cmdmod.browse;
3883 3812
3884 /* 3813 /*
3885 * Get number argument from "idxp" entry in "tvs". First entry is 1. 3814 * Get number argument from "idxp" entry in "tvs". First entry is 1.
3886 */ 3815 */
3887 static long 3816 static long
3888 tv_nr(tvs, idxp) 3817 tv_nr(typval_T *tvs, int *idxp)
3889 typval_T *tvs;
3890 int *idxp;
3891 { 3818 {
3892 int idx = *idxp - 1; 3819 int idx = *idxp - 1;
3893 long n = 0; 3820 long n = 0;
3894 int err = FALSE; 3821 int err = FALSE;
3895 3822
3908 /* 3835 /*
3909 * Get string argument from "idxp" entry in "tvs". First entry is 1. 3836 * Get string argument from "idxp" entry in "tvs". First entry is 1.
3910 * Returns NULL for an error. 3837 * Returns NULL for an error.
3911 */ 3838 */
3912 static char * 3839 static char *
3913 tv_str(tvs, idxp) 3840 tv_str(typval_T *tvs, int *idxp)
3914 typval_T *tvs;
3915 int *idxp;
3916 { 3841 {
3917 int idx = *idxp - 1; 3842 int idx = *idxp - 1;
3918 char *s = NULL; 3843 char *s = NULL;
3919 3844
3920 if (tvs[idx].v_type == VAR_UNKNOWN) 3845 if (tvs[idx].v_type == VAR_UNKNOWN)
3930 # ifdef FEAT_FLOAT 3855 # ifdef FEAT_FLOAT
3931 /* 3856 /*
3932 * Get float argument from "idxp" entry in "tvs". First entry is 1. 3857 * Get float argument from "idxp" entry in "tvs". First entry is 1.
3933 */ 3858 */
3934 static double 3859 static double
3935 tv_float(tvs, idxp) 3860 tv_float(typval_T *tvs, int *idxp)
3936 typval_T *tvs;
3937 int *idxp;
3938 { 3861 {
3939 int idx = *idxp - 1; 3862 int idx = *idxp - 1;
3940 double f = 0; 3863 double f = 0;
3941 3864
3942 if (tvs[idx].v_type == VAR_UNKNOWN) 3865 if (tvs[idx].v_type == VAR_UNKNOWN)
4032 va_end(ap); 3955 va_end(ap);
4033 return str_l; 3956 return str_l;
4034 } 3957 }
4035 3958
4036 int 3959 int
4037 vim_vsnprintf(str, str_m, fmt, ap, tvs) 3960 vim_vsnprintf(
4038 char *str; 3961 char *str,
4039 size_t str_m; 3962 size_t str_m,
4040 char *fmt; 3963 char *fmt,
4041 va_list ap; 3964 va_list ap,
4042 typval_T *tvs; 3965 typval_T *tvs)
4043 { 3966 {
4044 size_t str_l = 0; 3967 size_t str_l = 0;
4045 char *p = fmt; 3968 char *p = fmt;
4046 int arg_idx = 1; 3969 int arg_idx = 1;
4047 3970