summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ex_docmd.c9
-rw-r--r--src/message.c172
-rw-r--r--src/proto/charset.pro2
-rw-r--r--src/testdir/Make_os2.mak2
-rw-r--r--src/testdir/test57.ok35
5 files changed, 212 insertions, 8 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 58905f0975..8cbec380ed 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1056,11 +1056,14 @@ do_cmdline(cmdline, getline, cookie, flags)
if (p_verbose >= 15 && sourcing_name != NULL)
{
++no_wait_return;
- msg_scroll = TRUE; /* always scroll up, don't overwrite */
+ verbose_enter_scroll();
+
smsg((char_u *)_("line %ld: %s"),
(long)sourcing_lnum, cmdline_copy);
- msg_puts((char_u *)"\n"); /* don't overwrite this either */
- cmdline_row = msg_row;
+ if (msg_silent == 0)
+ msg_puts((char_u *)"\n"); /* don't overwrite this */
+
+ verbose_leave_scroll();
--no_wait_return;
}
diff --git a/src/message.c b/src/message.c
index 85ff3e629b..ff79649897 100644
--- a/src/message.c
+++ b/src/message.c
@@ -34,6 +34,7 @@ static void t_puts __ARGS((int t_col, char_u *t_s, char_u *s, int attr));
static void msg_screen_putchar __ARGS((int c, int attr));
static int msg_check_screen __ARGS((void));
static void redir_write __ARGS((char_u *s, int maxlen));
+static void verbose_write __ARGS((char_u *s, int maxlen));
#ifdef FEAT_CON_DIALOG
static char_u *msg_show_console_dialog __ARGS((char_u *message, char_u *buttons, int dfltbutton));
static int confirm_msg_used = FALSE; /* displaying confirm_msg */
@@ -101,6 +102,25 @@ msg(s)
return msg_attr_keep(s, 0, FALSE);
}
+#if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
+ || defined(PROTO)
+/*
+ * Like msg() but keep it silent when 'verbosefile' is set.
+ */
+ int
+verb_msg(s)
+ char_u *s;
+{
+ int n;
+
+ verbose_enter();
+ n = msg_attr_keep(s, 0, FALSE);
+ verbose_leave();
+
+ return n;
+}
+#endif
+
int
msg_attr(s, attr)
char_u *s;
@@ -183,7 +203,7 @@ msg_strtrunc(s)
/* May truncate message to avoid a hit-return prompt */
if (!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL)
- && !exmode_active)
+ && !exmode_active && msg_silent == 0)
{
len = vim_strsize(s);
room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
@@ -2524,11 +2544,22 @@ redir_write(str, maxlen)
char_u *s = str;
static int cur_col = 0;
- if ((redir_fd != NULL
+ /* Don't do anything for displaying prompts and the like. */
+ if (redir_off)
+ return;
+
+ /*
+ * If 'verbosefile' is set write message in that file.
+ * Must come before the rest because of updating "msg_col".
+ */
+ if (*p_vfile != NUL)
+ verbose_write(s, maxlen);
+
+ if (redir_fd != NULL
#ifdef FEAT_EVAL
|| redir_reg || redir_vname
#endif
- ) && !redir_off)
+ )
{
/* If the string doesn't start with CR or NL, go to msg_col */
if (*s != '\n' && *s != '\r')
@@ -2576,6 +2607,139 @@ redir_write(str, maxlen)
}
/*
+ * Before giving verbose messsage.
+ * Must always be called paired with verbose_leave()!
+ */
+ void
+verbose_enter()
+{
+ if (*p_vfile != NUL)
+ ++msg_silent;
+}
+
+/*
+ * After giving verbose message.
+ * Must always be called paired with verbose_enter()!
+ */
+ void
+verbose_leave()
+{
+ if (*p_vfile != NUL)
+ if (--msg_silent < 0)
+ msg_silent = 0;
+}
+
+/*
+ * Like verbose_enter() and set msg_scroll when displaying the message.
+ */
+ void
+verbose_enter_scroll()
+{
+ if (*p_vfile != NUL)
+ ++msg_silent;
+ else
+ /* always scroll up, don't overwrite */
+ msg_scroll = TRUE;
+}
+
+/*
+ * Like verbose_leave() and set cmdline_row when displaying the message.
+ */
+ void
+verbose_leave_scroll()
+{
+ if (*p_vfile != NUL)
+ {
+ if (--msg_silent < 0)
+ msg_silent = 0;
+ }
+ else
+ cmdline_row = msg_row;
+}
+
+static FILE *verbose_fd = NULL;
+static int verbose_did_open = FALSE;
+
+/*
+ * Called when 'verbosefile' is set: stop writing to the file.
+ */
+ void
+verbose_stop()
+{
+ if (verbose_fd != NULL)
+ {
+ fclose(verbose_fd);
+ verbose_fd = NULL;
+ }
+ verbose_did_open = FALSE;
+}
+
+/*
+ * Open the file 'verbosefile'.
+ * Return FAIL or OK.
+ */
+ int
+verbose_open()
+{
+ if (verbose_fd == NULL && !verbose_did_open)
+ {
+ /* Only give the error message once. */
+ verbose_did_open = TRUE;
+
+ verbose_fd = fopen((char *)p_vfile, "a");
+ if (verbose_fd == NULL)
+ {
+ EMSG2(_(e_notopen), p_vfile);
+ return FAIL;
+ }
+ }
+ return OK;
+}
+
+/*
+ * Write a string to 'verbosefile'.
+ * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes.
+ */
+ static void
+verbose_write(str, maxlen)
+ char_u *str;
+ int maxlen;
+{
+ char_u *s = str;
+ static int cur_col = 0;
+
+ /* Open the file when called the first time. */
+ if (verbose_fd == NULL)
+ verbose_open();
+
+ if (verbose_fd != NULL)
+ {
+ /* If the string doesn't start with CR or NL, go to msg_col */
+ if (*s != '\n' && *s != '\r')
+ {
+ while (cur_col < msg_col)
+ {
+ fputs(" ", verbose_fd);
+ ++cur_col;
+ }
+ }
+
+ /* Adjust the current column */
+ while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
+ {
+ putc(*s, verbose_fd);
+ if (*s == '\r' || *s == '\n')
+ cur_col = 0;
+ else if (*s == '\t')
+ cur_col += (8 - cur_col % 8);
+ else
+ ++cur_col;
+ ++s;
+ }
+ }
+}
+
+/*
* Give a warning message (for searching).
* Use 'w' highlighting and may repeat the message after redrawing
*/
@@ -3206,7 +3370,7 @@ do_browse(flags, title, dflt, ext, initdir, filter, buf)
*
* This code is based on snprintf.c - a portable implementation of snprintf
* by Mark Martinec <mark.martinec@ijs.si>, Version 2.2, 2000-10-06.
- * It was heavely modified to fit in Vim.
+ * Included with permission. It was heavely modified to fit in Vim.
* The original code, including useful comments, can be found here:
* http://www.ijs.si/software/snprintf/
*
diff --git a/src/proto/charset.pro b/src/proto/charset.pro
index dc33f654b3..e839d6374c 100644
--- a/src/proto/charset.pro
+++ b/src/proto/charset.pro
@@ -40,6 +40,8 @@ void getvvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, co
void getvcols __ARGS((win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, colnr_T *right));
char_u *skipwhite __ARGS((char_u *p));
char_u *skipdigits __ARGS((char_u *p));
+char_u *skiptodigit __ARGS((char_u *p));
+char_u *skiptohex __ARGS((char_u *p));
int vim_isdigit __ARGS((int c));
int vim_isxdigit __ARGS((int c));
char_u *skiptowhite __ARGS((char_u *p));
diff --git a/src/testdir/Make_os2.mak b/src/testdir/Make_os2.mak
index 3f63cec6ee..4d3296c07a 100644
--- a/src/testdir/Make_os2.mak
+++ b/src/testdir/Make_os2.mak
@@ -24,7 +24,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test38.out test39.out test40.out test41.out test42.out \
test43.out test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out test55.out \
- test56.out
+ test56.out test57.out
.SUFFIXES: .in .out
diff --git a/src/testdir/test57.ok b/src/testdir/test57.ok
new file mode 100644
index 0000000000..69b98625df
--- /dev/null
+++ b/src/testdir/test57.ok
@@ -0,0 +1,35 @@
+t1: alphabetical
+One test
+Two test
+one test
+two test
+t2: alpha, unique
+One test
+Two test
+Two test
+one test
+t3: alpha, unique, skip pattern
+two: aaa
+another: tuvy
+one: xay
+t4: number
+xce 9
+asdf 83 asd
+one 333
+t5: number and skip
+one 33:4 99
+:9
+asdf 3 a: sd 11
+t6: octal
+asdf 0014
+2389
+111
+t7: hex and skip
+asd/ad 1413
+0x44/1a1
+sf/0x1d3
+t8: wrong arguments
+ccc
+bbb
+aaa
+t8: