comparison src/testing.c @ 27497:7480a2e2ca0f v8.2.4276

patch 8.2.4276: separate test function for the GUI scrollbar Commit: https://github.com/vim/vim/commit/9e0208f51cf1354ce0a7d3988133041a78681605 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Jan 31 17:40:55 2022 +0000 patch 8.2.4276: separate test function for the GUI scrollbar Problem: Separate test function for the GUI scrollbar. Solution: Use test_gui_event(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9674)
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 Jan 2022 18:45:03 +0100
parents f0096e5b3df9
children 378d3f7483e9
comparison
equal deleted inserted replaced
27496:cd5a89c0e571 27497:7480a2e2ca0f
1251 f_test_void(typval_T *argvars UNUSED, typval_T *rettv) 1251 f_test_void(typval_T *argvars UNUSED, typval_T *rettv)
1252 { 1252 {
1253 rettv->v_type = VAR_VOID; 1253 rettv->v_type = VAR_VOID;
1254 } 1254 }
1255 1255
1256 #ifdef FEAT_GUI
1257 void
1258 f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
1259 {
1260 char_u *which;
1261 long value;
1262 int dragging;
1263 scrollbar_T *sb = NULL;
1264
1265 if (check_for_string_arg(argvars, 0) == FAIL
1266 || check_for_number_arg(argvars, 1) == FAIL
1267 || check_for_number_arg(argvars, 2) == FAIL)
1268 return;
1269
1270 if (argvars[0].v_type != VAR_STRING
1271 || (argvars[1].v_type) != VAR_NUMBER
1272 || (argvars[2].v_type) != VAR_NUMBER)
1273 {
1274 emsg(_(e_invalid_argument));
1275 return;
1276 }
1277 which = tv_get_string(&argvars[0]);
1278 value = tv_get_number(&argvars[1]);
1279 dragging = tv_get_number(&argvars[2]);
1280
1281 if (STRCMP(which, "left") == 0)
1282 sb = &curwin->w_scrollbars[SBAR_LEFT];
1283 else if (STRCMP(which, "right") == 0)
1284 sb = &curwin->w_scrollbars[SBAR_RIGHT];
1285 else if (STRCMP(which, "hor") == 0)
1286 sb = &gui.bottom_sbar;
1287 if (sb == NULL)
1288 {
1289 semsg(_(e_invalid_argument_str), which);
1290 return;
1291 }
1292 gui_drag_scrollbar(sb, value, dragging);
1293 # ifndef USE_ON_FLY_SCROLL
1294 // need to loop through normal_cmd() to handle the scroll events
1295 exec_normal(FALSE, TRUE, FALSE);
1296 # endif
1297 }
1298 #endif
1299
1300 void 1256 void
1301 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) 1257 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
1302 { 1258 {
1303 if (in_vim9script() 1259 if (in_vim9script()
1304 && (check_for_number_arg(argvars, 0) == FAIL 1260 && (check_for_number_arg(argvars, 0) == FAIL
1428 repeated_click, mods); 1384 repeated_click, mods);
1429 return TRUE; 1385 return TRUE;
1430 } 1386 }
1431 1387
1432 static int 1388 static int
1389 test_gui_scrollbar(dict_T *args)
1390 {
1391 char_u *which;
1392 long value;
1393 int dragging;
1394 scrollbar_T *sb = NULL;
1395
1396 if (dict_find(args, (char_u *)"which", -1) == NULL
1397 || dict_find(args, (char_u *)"value", -1) == NULL
1398 || dict_find(args, (char_u *)"dragging", -1) == NULL)
1399 return FALSE;
1400
1401 which = dict_get_string(args, (char_u *)"which", FALSE);
1402 value = (long)dict_get_number(args, (char_u *)"value");
1403 dragging = (int)dict_get_number(args, (char_u *)"dragging");
1404
1405 if (STRCMP(which, "left") == 0)
1406 sb = &curwin->w_scrollbars[SBAR_LEFT];
1407 else if (STRCMP(which, "right") == 0)
1408 sb = &curwin->w_scrollbars[SBAR_RIGHT];
1409 else if (STRCMP(which, "hor") == 0)
1410 sb = &gui.bottom_sbar;
1411 if (sb == NULL)
1412 {
1413 semsg(_(e_invalid_argument_str), which);
1414 return FALSE;
1415 }
1416 gui_drag_scrollbar(sb, value, dragging);
1417 # ifndef USE_ON_FLY_SCROLL
1418 // need to loop through normal_cmd() to handle the scroll events
1419 exec_normal(FALSE, TRUE, FALSE);
1420 # endif
1421
1422 return TRUE;
1423 }
1424
1425 static int
1433 test_gui_tabline_event(dict_T *args UNUSED) 1426 test_gui_tabline_event(dict_T *args UNUSED)
1434 { 1427 {
1435 # ifdef FEAT_GUI_TABLINE 1428 # ifdef FEAT_GUI_TABLINE
1436 int tabnr; 1429 int tabnr;
1437 1430
1485 rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict); 1478 rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict);
1486 else if (STRCMP(event, "findrepl") == 0) 1479 else if (STRCMP(event, "findrepl") == 0)
1487 rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict); 1480 rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);
1488 else if (STRCMP(event, "mouse") == 0) 1481 else if (STRCMP(event, "mouse") == 0)
1489 rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict); 1482 rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);
1483 else if (STRCMP(event, "scrollbar") == 0)
1484 rettv->vval.v_number = test_gui_scrollbar(argvars[1].vval.v_dict);
1490 else if (STRCMP(event, "tabline") == 0) 1485 else if (STRCMP(event, "tabline") == 0)
1491 rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict); 1486 rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);
1492 else if (STRCMP(event, "tabmenu") == 0) 1487 else if (STRCMP(event, "tabmenu") == 0)
1493 rettv->vval.v_number = test_gui_tabmenu_event(argvars[1].vval.v_dict); 1488 rettv->vval.v_number = test_gui_tabmenu_event(argvars[1].vval.v_dict);
1494 else 1489 else