diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 41 | ||||
-rw-r--r-- | src/testdir/test_gui.vim | 35 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 78 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index f49bcb843d..0daf5903a7 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -429,6 +429,9 @@ static void f_test_null_job(typval_T *argvars, typval_T *rettv); static void f_test_null_list(typval_T *argvars, typval_T *rettv); static void f_test_null_partial(typval_T *argvars, typval_T *rettv); 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_settime(typval_T *argvars, typval_T *rettv); #ifdef FEAT_FLOAT static void f_tan(typval_T *argvars, typval_T *rettv); @@ -925,6 +928,9 @@ static struct fst {"test_null_string", 0, 0, f_test_null_string}, {"test_option_not_set", 1, 1, f_test_option_not_set}, {"test_override", 2, 2, f_test_override}, +#ifdef FEAT_GUI + {"test_scrollbar", 3, 3, f_test_scrollbar}, +#endif {"test_settime", 1, 1, f_test_settime}, #ifdef FEAT_TIMERS {"timer_info", 0, 1, f_timer_info}, @@ -13202,6 +13208,41 @@ f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv) rettv->vval.v_string = NULL; } +#ifdef FEAT_GUI + static void +f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED) +{ + char_u *which; + long value; + int dragging; + scrollbar_T *sb = NULL; + + if (argvars[0].v_type != VAR_STRING + || (argvars[1].v_type) != VAR_NUMBER + || (argvars[2].v_type) != VAR_NUMBER) + { + EMSG(_(e_invarg)); + return; + } + which = get_tv_string(&argvars[0]); + value = get_tv_number(&argvars[1]); + dragging = get_tv_number(&argvars[2]); + + if (STRCMP(which, "left") == 0) + sb = &curwin->w_scrollbars[SBAR_LEFT]; + else if (STRCMP(which, "right") == 0) + sb = &curwin->w_scrollbars[SBAR_RIGHT]; + else if (STRCMP(which, "hor") == 0) + sb = &gui.bottom_sbar; + if (sb == NULL) + { + EMSG2(_(e_invarg2), which); + return; + } + gui_drag_scrollbar(sb, value, dragging); +} +#endif + static void f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) { diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 9b42134ac9..0775b178fb 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -667,6 +667,41 @@ func Test_set_guioptions() let &guioptions = guioptions_saved endfunc +func Test_scrollbars() + new + " buffer with 200 lines + call setline(1, repeat(['one', 'two'], 100)) + set guioptions+=rlb + + " scroll to move line 11 at top, moves the cursor there + call test_scrollbar('left', 10, 0) + redraw + call assert_equal(1, winline()) + call assert_equal(11, line('.')) + + " scroll to move line 1 at top, cursor stays in line 11 + call test_scrollbar('right', 0, 0) + redraw + call assert_equal(11, winline()) + call assert_equal(11, line('.')) + + set nowrap + call setline(11, repeat('x', 150)) + redraw + call assert_equal(1, wincol()) + call assert_equal(1, col('.')) + + " scroll to character 11, cursor is moved + call test_scrollbar('hor', 10, 0) + redraw + call assert_equal(1, wincol()) + call assert_equal(11, col('.')) + + set guioptions& + set wrap& + bwipe! +endfunc + func Test_set_guipty() let guipty_saved = &guipty diff --git a/src/version.c b/src/version.c index a5f251255c..f9e9cf495b 100644 --- a/src/version.c +++ b/src/version.c @@ -795,6 +795,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 390, +/**/ 389, /**/ 388, |