]> granicus.if.org Git - vim/commitdiff
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled v8.2.0258
authorBram Moolenaar <Bram@vim.org>
Fri, 14 Feb 2020 15:53:00 +0000 (16:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 14 Feb 2020 15:53:00 +0000 (16:53 +0100)
Problem:    ModifyOtherKeys cannot be temporarily disabled.
Solution:   Add echoraw() with an example for modifyOtherKeys.

runtime/doc/eval.txt
src/evalfunc.c
src/testdir/dumps/Test_functions_echoraw.dump [new file with mode: 0644]
src/testdir/test_functions.vim
src/version.c

index 765d83637595391d56e5d4035736981a75d50a2c..62a73048b70a0f74f99f308060f5a72facf77612 100644 (file)
@@ -1,4 +1,4 @@
-*eval.txt*     For Vim version 8.2.  Last change: 2020 Feb 03
+*eval.txt*     For Vim version 8.2.  Last change: 2020 Feb 14
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2414,6 +2414,7 @@ deletebufline({expr}, {first} [, {last}])
 did_filetype()                 Number  |TRUE| if FileType autocmd event used
 diff_filler({lnum})            Number  diff filler lines about {lnum}
 diff_hlID({lnum}, {col})       Number  diff highlighting at {lnum}/{col}
+echoraw({expr})                        none    output {expr} as-is
 empty({expr})                  Number  |TRUE| if {expr} is empty
 environ()                      Dict    return environment variables
 escape({string}, {chars})      String  escape {chars} in {string} with '\'
@@ -2899,6 +2900,7 @@ win_id2win({expr})                Number  get window nr from window ID
 win_screenpos({nr})            List    get screen position of window {nr}
 win_splitmove({nr}, {target} [, {options}])
                                Number  move window {nr} to split of {target}
+win_type([{nr}])               String  type of window {nr}
 winbufnr({nr})                 Number  buffer number of window {nr}
 wincol()                       Number  window column of the cursor
 winheight({nr})                        Number  height of window {nr}
@@ -3944,6 +3946,17 @@ diff_hlID({lnum}, {col})                         *diff_hlID()*
                Can also be used as a |method|: >
                        GetLnum()->diff_hlID(col)
 
+
+echoraw({expr})                                                *echoraw()*
+               Output {expr} as-is, including unprintable characters.  This
+               can be used to output a terminal code. For example, to disable
+               modifyOtherKeys: >
+                       call echoraw(&t_TE)
+<              and to enable it again: >
+                       call echoraw(&t_TI)
+<              Use with care, you can mess up the terminal this way.
+
+
 empty({expr})                                          *empty()*
                Return the Number 1 if {expr} is empty, zero otherwise.
                - A |List| or |Dictionary| is empty when it does not have any
@@ -10402,6 +10415,7 @@ win_splitmove({nr}, {target} [, {options}])             *win_splitmove()*
                Can also be used as a |method|: >
                        GetWinid()->win_splitmove(target)
 <
+
                                                        *winbufnr()*
 winbufnr({nr}) The result is a Number, which is the number of the buffer
                associated with window {nr}.  {nr} can be the window number or
index a0f29943ec93cf2d88e096b9193548cdafc3fe19..3e1a462d19a6db315932f448f12434e799d162dd 100644 (file)
@@ -60,6 +60,7 @@ static void f_debugbreak(typval_T *argvars, typval_T *rettv);
 #endif
 static void f_deepcopy(typval_T *argvars, typval_T *rettv);
 static void f_did_filetype(typval_T *argvars, typval_T *rettv);
+static void f_echoraw(typval_T *argvars, typval_T *rettv);
 static void f_empty(typval_T *argvars, typval_T *rettv);
 static void f_environ(typval_T *argvars, typval_T *rettv);
 static void f_escape(typval_T *argvars, typval_T *rettv);
@@ -394,6 +395,7 @@ static funcentry_T global_functions[] =
     {"did_filetype",   0, 0, 0,          &t_number,    f_did_filetype},
     {"diff_filler",    1, 1, FEARG_1,    &t_number,    f_diff_filler},
     {"diff_hlID",      2, 2, FEARG_1,    &t_number,    f_diff_hlID},
+    {"echoraw",                1, 1, FEARG_1,    &t_number,    f_echoraw},
     {"empty",          1, 1, FEARG_1,    &t_number,    f_empty},
     {"environ",                0, 0, 0,          &t_dict_string, f_environ},
     {"escape",         2, 2, FEARG_1,    &t_string,    f_escape},
@@ -1813,6 +1815,21 @@ f_did_filetype(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
     rettv->vval.v_number = did_filetype;
 }
 
+/*
+ * "echoraw({expr})" function
+ */
+    static void
+f_echoraw(typval_T *argvars, typval_T *rettv UNUSED)
+{
+    char_u *str = tv_get_string_chk(&argvars[0]);
+
+    if (str != NULL && *str != NUL)
+    {
+       out_str(str);
+       out_flush();
+    }
+}
+
 /*
  * "empty({expr})" function
  */
diff --git a/src/testdir/dumps/Test_functions_echoraw.dump b/src/testdir/dumps/Test_functions_echoraw.dump
new file mode 100644 (file)
index 0000000..f27cd03
--- /dev/null
@@ -0,0 +1,5 @@
+>x+0&#ffffff0|e|l@1|o| @34
+|~+0#4040ff13&| @38
+|~| @38
+|~| @38
+| +0#0000000&@21|0|,|0|-|1| @8|A|l@1| 
index 9173e8547c9600ed452b5820b9ea76e466918cc1..c7488547692bc1fb85ad07c522d20f9bb360363c 100644 (file)
@@ -2,6 +2,7 @@
 source shared.vim
 source check.vim
 source term_util.vim
+source screendump.vim
 
 " Must be done first, since the alternate buffer must be unset.
 func Test_00_bufexists()
@@ -2017,3 +2018,19 @@ func Test_range()
   " uniq()
   call assert_equal([0, 1, 2, 3, 4], uniq(range(5)))
 endfunc
+
+func Test_echoraw()
+  CheckScreendump
+
+  " Normally used for escape codes, but let's test with a CR.
+  let lines =<< trim END
+    call echoraw("hello\<CR>x")
+  END
+  call writefile(lines, 'XTest_echoraw')
+  let buf = RunVimInTerminal('-S XTest_echoraw', {'rows': 5, 'cols': 40})
+  call VerifyScreenDump(buf, 'Test_functions_echoraw', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XTest_echoraw')
+endfunc
index 70ea449a3542967f5a36492b2caa1e8d90a7204d..2720dc65289c465702e0ab115de340c3e06933f1 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    258,
 /**/
     257,
 /**/