Skip to content

Commit bb8476b

Browse files
committed
patch 8.1.1262: cannot simulate a mouse click in a test
Problem: Cannot simulate a mouse click in a test. Solution: Add test_setmouse().
1 parent 25190db commit bb8476b

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

runtime/doc/eval.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,6 +2700,7 @@ test_override({expr}, {val}) none test with Vim internal overrides
27002700
test_refcount({expr}) Number get the reference count of {expr}
27012701
test_scrollbar({which}, {value}, {dragging})
27022702
none scroll in the GUI for testing
2703+
test_setmouse({row}, {col}) none set the mouse position for testing
27032704
test_settime({expr}) none set current time for testing
27042705
timer_info([{id}]) List information about timers
27052706
timer_pause({id}, {pause}) none pause or unpause a timer
@@ -9841,6 +9842,13 @@ test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
98419842
Only works when the {which} scrollbar actually exists,
98429843
obviously only when using the GUI.
98439844

9845+
test_setmouse({row}, {col}) *test_setmouse()*
9846+
Set the mouse position to be used for the next mouse action.
9847+
{row} and {col} are one based.
9848+
For example: >
9849+
call test_setmouse(4, 20)
9850+
call feedkeys("\<LeftMouse>", "xt")
9851+
98449852
test_settime({expr}) *test_settime()*
98459853
Set the time Vim uses internally. Currently only used for
98469854
timestamps in the history, as they are used in viminfo, and

runtime/doc/usr_41.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim version 8.1. Last change: 2019 Apr 06
1+
*usr_41.txt* For Vim version 8.1. Last change: 2019 May 04
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -955,6 +955,7 @@ Testing: *test-functions*
955955
test_null_partial() return a null Partial function
956956
test_null_string() return a null String
957957
test_settime() set the time Vim uses internally
958+
test_setmouse() set the mouse position
958959
test_feedinput() add key sequence to input buffer
959960
test_option_not_set() reset flag indicating option was set
960961
test_scrollbar() simulate scrollbar movement in the GUI

src/evalfunc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ static void f_test_null_string(typval_T *argvars, typval_T *rettv);
456456
#ifdef FEAT_GUI
457457
static void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
458458
#endif
459+
static void f_test_setmouse(typval_T *argvars, typval_T *rettv);
459460
static void f_test_settime(typval_T *argvars, typval_T *rettv);
460461
#ifdef FEAT_FLOAT
461462
static void f_tan(typval_T *argvars, typval_T *rettv);
@@ -993,6 +994,7 @@ static struct fst
993994
#ifdef FEAT_GUI
994995
{"test_scrollbar", 3, 3, f_test_scrollbar},
995996
#endif
997+
{"test_setmouse", 2, 2, f_test_setmouse},
996998
{"test_settime", 1, 1, f_test_settime},
997999
#ifdef FEAT_TIMERS
9981000
{"timer_info", 0, 1, f_timer_info},
@@ -14493,6 +14495,13 @@ f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
1449314495
}
1449414496
#endif
1449514497

14498+
static void
14499+
f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
14500+
{
14501+
mouse_row = (time_t)tv_get_number(&argvars[0]) - 1;
14502+
mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
14503+
}
14504+
1449614505
static void
1449714506
f_test_settime(typval_T *argvars, typval_T *rettv UNUSED)
1449814507
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1262,
770772
/**/
771773
1261,
772774
/**/

0 commit comments

Comments
 (0)