summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-23 20:58:45 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-23 20:58:45 +0200
commit37f4cbd46f5a6f2dd3a48d5fa4324dce37e4bd6c (patch)
treebed00affbe1920deeeb36b270db9c3b076694c0f
parent570497ac409ad448574bb6210cb9c6e573483759 (diff)
downloadvim-git-37f4cbd46f5a6f2dd3a48d5fa4324dce37e4bd6c.tar.gz
patch 8.1.1913: not easy to compute the space on the command linev8.1.1913
Problem: Not easy to compute the space on the command line. Solution: Add v:echospace. (Daniel Hahler, closes #4732)
-rw-r--r--runtime/doc/eval.txt7
-rw-r--r--src/eval.c3
-rw-r--r--src/option.c3
-rw-r--r--src/testdir/test_messages.vim17
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h3
6 files changed, 34 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1cafba243..aa27beac1 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1768,6 +1768,13 @@ v:dying Normally zero. When a deadly signal is caught it's set to
< Note: if another deadly signal is caught when v:dying is one,
VimLeave autocommands will not be executed.
+ *v:echospace* *echospace-variable*
+v:echospace Number of screen cells that can be used for an `:echo` message
+ in the last screen line before causing the |hit-enter-prompt|.
+ Depends on 'showcmd', 'ruler' and 'columns'. You need to
+ check 'cmdheight' for whether there are full-width lines
+ available above the last line.
+
*v:errmsg* *errmsg-variable*
v:errmsg Last given error message. It's allowed to set this variable.
Example: >
diff --git a/src/eval.c b/src/eval.c
index 5c5fd2f10..9a2642cbe 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -201,6 +201,7 @@ static struct vimvar
{VV_NAME("termblinkresp", VAR_STRING), VV_RO},
{VV_NAME("event", VAR_DICT), VV_RO},
{VV_NAME("versionlong", VAR_NUMBER), VV_RO},
+ {VV_NAME("echospace", VAR_NUMBER), VV_RO},
};
/* shorthand */
@@ -389,6 +390,8 @@ eval_init(void)
set_vim_var_nr(VV_TYPE_CHANNEL, VAR_TYPE_CHANNEL);
set_vim_var_nr(VV_TYPE_BLOB, VAR_TYPE_BLOB);
+ set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);
+
set_reg_var(0); /* default for v:register is not 0 but '"' */
#ifdef EBCDIC
diff --git a/src/option.c b/src/option.c
index 6d3a059cc..215d48a09 100644
--- a/src/option.c
+++ b/src/option.c
@@ -10881,6 +10881,9 @@ comp_col(void)
sc_col = Columns;
ru_col = Columns;
#endif
+#ifdef FEAT_EVAL
+ set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);
+#endif
}
#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim
index 8c6c854fa..f122917ba 100644
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -155,3 +155,20 @@ func Test_mode_message_at_leaving_insert_with_esc_mapped()
exe buf . 'bwipe!'
call delete(testfile)
endfunc
+
+func Test_echospace()
+ set noruler noshowcmd laststatus=1
+ call assert_equal(&columns - 1, v:echospace)
+ split
+ call assert_equal(&columns - 1, v:echospace)
+ set ruler
+ call assert_equal(&columns - 1, v:echospace)
+ close
+ call assert_equal(&columns - 19, v:echospace)
+ set showcmd noruler
+ call assert_equal(&columns - 12, v:echospace)
+ set showcmd ruler
+ call assert_equal(&columns - 29, v:echospace)
+
+ set ruler& showcmd&
+endfunc
diff --git a/src/version.c b/src/version.c
index dfe1438bf..ee4c964ec 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1913,
+/**/
1912,
/**/
1911,
diff --git a/src/vim.h b/src/vim.h
index 254d3efbe..dca874817 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1981,7 +1981,8 @@ typedef int sock_T;
#define VV_TERMBLINKRESP 89
#define VV_EVENT 90
#define VV_VERSIONLONG 91
-#define VV_LEN 92 // number of v: vars
+#define VV_ECHOSPACE 92
+#define VV_LEN 93 // number of v: vars
// used for v_number in VAR_SPECIAL
#define VVAL_FALSE 0L