Mercurial > vim
comparison src/testing.c @ 25006:496221916885 v8.2.3040
patch 8.2.3040: GUI: dropping files not tested
Commit: https://github.com/vim/vim/commit/18d46587b985923ef4b90b19a0cf37a094607fec
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Jun 23 20:46:52 2021 +0200
patch 8.2.3040: GUI: dropping files not tested
Problem: GUI: dropping files not tested.
Solution: Add test_gui_drop_files() and tests. (Yegappan Lakshmanan,
closes #8434)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 23 Jun 2021 21:00:03 +0200 |
parents | 3b1770226f85 |
children | 54c0cb81e6a7 |
comparison
equal
deleted
inserted
replaced
25005:791ae2f86aa4 | 25006:496221916885 |
---|---|
1222 } | 1222 } |
1223 | 1223 |
1224 void | 1224 void |
1225 f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | 1225 f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
1226 { | 1226 { |
1227 #ifdef FEAT_GUI | 1227 # ifdef FEAT_GUI |
1228 int button; | 1228 int button; |
1229 int row; | 1229 int row; |
1230 int col; | 1230 int col; |
1231 int repeated_click; | 1231 int repeated_click; |
1232 int_u mods; | 1232 int_u mods; |
1246 col = tv_get_number(&argvars[2]); | 1246 col = tv_get_number(&argvars[2]); |
1247 repeated_click = tv_get_number(&argvars[3]); | 1247 repeated_click = tv_get_number(&argvars[3]); |
1248 mods = tv_get_number(&argvars[4]); | 1248 mods = tv_get_number(&argvars[4]); |
1249 | 1249 |
1250 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods); | 1250 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods); |
1251 #endif | 1251 # endif |
1252 } | 1252 } |
1253 | 1253 |
1254 void | 1254 void |
1255 f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) | 1255 f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) |
1256 { | 1256 { |
1257 time_for_testing = (time_t)tv_get_number(&argvars[0]); | 1257 time_for_testing = (time_t)tv_get_number(&argvars[0]); |
1258 } | 1258 } |
1259 | 1259 |
1260 void | |
1261 f_test_gui_drop_files(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | |
1262 { | |
1263 # ifdef FEAT_GUI | |
1264 int row; | |
1265 int col; | |
1266 int_u mods; | |
1267 char_u **fnames; | |
1268 int count = 0; | |
1269 list_T *l; | |
1270 listitem_T *li; | |
1271 | |
1272 if (argvars[0].v_type != VAR_LIST | |
1273 || (argvars[1].v_type) != VAR_NUMBER | |
1274 || (argvars[2].v_type) != VAR_NUMBER | |
1275 || (argvars[3].v_type) != VAR_NUMBER) | |
1276 { | |
1277 emsg(_(e_invarg)); | |
1278 return; | |
1279 } | |
1280 | |
1281 row = tv_get_number(&argvars[1]); | |
1282 col = tv_get_number(&argvars[2]); | |
1283 mods = tv_get_number(&argvars[3]); | |
1284 | |
1285 l = argvars[0].vval.v_list; | |
1286 if (list_len(l) == 0) | |
1287 return; | |
1288 | |
1289 fnames = ALLOC_MULT(char_u *, list_len(l)); | |
1290 if (fnames == NULL) | |
1291 return; | |
1292 | |
1293 FOR_ALL_LIST_ITEMS(l, li) | |
1294 { | |
1295 // ignore non-string items | |
1296 if (li->li_tv.v_type != VAR_STRING) | |
1297 continue; | |
1298 | |
1299 fnames[count] = vim_strsave(li->li_tv.vval.v_string); | |
1300 if (fnames[count] == NULL) | |
1301 { | |
1302 while (--count >= 0) | |
1303 vim_free(fnames[count]); | |
1304 vim_free(fnames); | |
1305 return; | |
1306 } | |
1307 count++; | |
1308 } | |
1309 | |
1310 if (count > 0) | |
1311 gui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count); | |
1312 else | |
1313 vim_free(fnames); | |
1314 # endif | |
1315 } | |
1260 | 1316 |
1261 #endif // defined(FEAT_EVAL) | 1317 #endif // defined(FEAT_EVAL) |