]> granicus.if.org Git - vim/commitdiff
patch 8.1.1913: not easy to compute the space on the command line v8.1.1913
authorBram Moolenaar <Bram@vim.org>
Fri, 23 Aug 2019 18:58:45 +0000 (20:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 23 Aug 2019 18:58:45 +0000 (20:58 +0200)
Problem:    Not easy to compute the space on the command line.
Solution:   Add v:echospace. (Daniel Hahler, closes #4732)

runtime/doc/eval.txt
src/eval.c
src/option.c
src/testdir/test_messages.vim
src/version.c
src/vim.h

index 1cafba243613b373b12b1ff63ee01150e47a2a8b..aa27beac102ce93181a1ae2fc656f1c134c4c8f6 100644 (file)
@@ -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: >
index 5c5fd2f10dec32aab21ff0aeb0dd8c3648238769..9a2642cbe81b812e0beb671d486f082df4cf56ec 100644 (file)
@@ -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
index 6d3a059cca66aa724f456c1a4d01123f3ebc721d..215d48a0922494c88a13b66bcd6c6b35f5c2b93c 100644 (file)
@@ -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)
index 8c6c854fabdac4942eba881b4a723a106b4046c5..f122917ba7e33ef510e0ad9b792282a7b63641f0 100644 (file)
@@ -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
index dfe1438bffe82964608354deb25e19c0a8798070..ee4c964ec5dcaf979294507da2c0d65002534ab9 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1913,
 /**/
     1912,
 /**/
index 254d3efbe6dcae38ba5effeec4494113e4d7f134..dca8748179089cac60a5bd21d45a207a2cff48ba 100644 (file)
--- 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