]> granicus.if.org Git - vim/commitdiff
patch 8.1.1262: cannot simulate a mouse click in a test v8.1.1262
authorBram Moolenaar <Bram@vim.org>
Sat, 4 May 2019 13:47:48 +0000 (15:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 May 2019 13:47:48 +0000 (15:47 +0200)
Problem:    Cannot simulate a mouse click in a test.
Solution:   Add test_setmouse().

runtime/doc/eval.txt
runtime/doc/usr_41.txt
src/evalfunc.c
src/version.c

index 8faf17f6395e736556a35d9e8e5d81c747d53436..c12e69e4a153d49b16eb2f7be2a64f6be35ef84d 100644 (file)
@@ -2700,6 +2700,7 @@ test_override({expr}, {val})      none    test with Vim internal overrides
 test_refcount({expr})          Number  get the reference count of {expr}
 test_scrollbar({which}, {value}, {dragging})
                                none    scroll in the GUI for testing
+test_setmouse({row}, {col})    none    set the mouse position for testing
 test_settime({expr})           none    set current time for testing
 timer_info([{id}])             List    information about timers
 timer_pause({id}, {pause})     none    pause or unpause a timer
@@ -9841,6 +9842,13 @@ test_scrollbar({which}, {value}, {dragging})             *test_scrollbar()*
                Only works when the {which} scrollbar actually exists,
                obviously only when using the GUI.
 
+test_setmouse({row}, {col})                            *test_setmouse()*
+               Set the mouse position to be used for the next mouse action.
+               {row} and {col} are one based.
+               For example: >
+                       call test_setmouse(4, 20)
+                       call feedkeys("\<LeftMouse>", "xt")
+
 test_settime({expr})                                   *test_settime()*
                Set the time Vim uses internally.  Currently only used for
                timestamps in the history, as they are used in viminfo, and
index c95dca66a7436b9267a18d6f37daf8b725e079c6..cef6fd793a66eb9ad965215a5fd7bb431ccebba8 100644 (file)
@@ -1,4 +1,4 @@
-*usr_41.txt*   For Vim version 8.1.  Last change: 2019 Apr 06
+*usr_41.txt*   For Vim version 8.1.  Last change: 2019 May 04
 
                     VIM USER MANUAL - by Bram Moolenaar
 
@@ -955,6 +955,7 @@ Testing:                                *test-functions*
        test_null_partial()     return a null Partial function
        test_null_string()      return a null String
        test_settime()          set the time Vim uses internally
+       test_setmouse()         set the mouse position
        test_feedinput()        add key sequence to input buffer
        test_option_not_set()   reset flag indicating option was set
        test_scrollbar()        simulate scrollbar movement in the GUI
index 2b1b1424c1e1a37e8d1089e5b3df2213d3a02af7..7b6785cfae6fe9d40231a10720fdb10148c95d79 100644 (file)
@@ -456,6 +456,7 @@ static void f_test_null_string(typval_T *argvars, typval_T *rettv);
 #ifdef FEAT_GUI
 static void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
 #endif
+static void f_test_setmouse(typval_T *argvars, typval_T *rettv);
 static void f_test_settime(typval_T *argvars, typval_T *rettv);
 #ifdef FEAT_FLOAT
 static void f_tan(typval_T *argvars, typval_T *rettv);
@@ -993,6 +994,7 @@ static struct fst
 #ifdef FEAT_GUI
     {"test_scrollbar", 3, 3, f_test_scrollbar},
 #endif
+    {"test_setmouse",  2, 2, f_test_setmouse},
     {"test_settime",   1, 1, f_test_settime},
 #ifdef FEAT_TIMERS
     {"timer_info",     0, 1, f_timer_info},
@@ -14493,6 +14495,13 @@ f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
 }
 #endif
 
+    static void
+f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
+{
+    mouse_row = (time_t)tv_get_number(&argvars[0]) - 1;
+    mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
+}
+
     static void
 f_test_settime(typval_T *argvars, typval_T *rettv UNUSED)
 {
index d78ef3db78383b5ee42bafc3f83de3c0ffde4064..07f3962fb30dab29584bf4b9a569a35e67d98df4 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1262,
 /**/
     1261,
 /**/