comparison src/ex_cmds2.c @ 17986:5c8906f653f5 v8.1.1989

patch 8.1.1989: the evalfunc.c file is still too big Commit: https://github.com/vim/vim/commit/af7645d3733fdd3cd2df03ec7b653601d26969ef Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 5 22:33:28 2019 +0200 patch 8.1.1989: the evalfunc.c file is still too big Problem: The evalfunc.c file is still too big. Solution: Move f_pathshorten() to filepath.c. Move f_cscope_connection() to if_cscope.c. Move diff_ functions to diff.c. Move timer_ functions to ex_cmds2.c. move callback functions to evalvars.c.
author Bram Moolenaar <Bram@vim.org>
date Thu, 05 Sep 2019 22:45:04 +0200
parents 0a5c615cd949
children d1e77015f60b
comparison
equal deleted inserted replaced
17985:9b43688b26bf 17986:5c8906f653f5
373 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); 373 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
374 } 374 }
375 return abort; 375 return abort;
376 } 376 }
377 377
378 # if defined(EXITFREE) || defined(PROTO) 378 # if defined(EXITFREE) || defined(PROTO)
379 void 379 void
380 timer_free_all() 380 timer_free_all()
381 { 381 {
382 timer_T *timer; 382 timer_T *timer;
383 383
386 timer = first_timer; 386 timer = first_timer;
387 remove_timer(timer); 387 remove_timer(timer);
388 free_timer(timer); 388 free_timer(timer);
389 } 389 }
390 } 390 }
391 # endif
392 # endif 391 # endif
393 392
394 #endif 393 /*
394 * "timer_info([timer])" function
395 */
396 void
397 f_timer_info(typval_T *argvars, typval_T *rettv)
398 {
399 timer_T *timer = NULL;
400
401 if (rettv_list_alloc(rettv) != OK)
402 return;
403 if (argvars[0].v_type != VAR_UNKNOWN)
404 {
405 if (argvars[0].v_type != VAR_NUMBER)
406 emsg(_(e_number_exp));
407 else
408 {
409 timer = find_timer((int)tv_get_number(&argvars[0]));
410 if (timer != NULL)
411 add_timer_info(rettv, timer);
412 }
413 }
414 else
415 add_timer_info_all(rettv);
416 }
417
418 /*
419 * "timer_pause(timer, paused)" function
420 */
421 void
422 f_timer_pause(typval_T *argvars, typval_T *rettv UNUSED)
423 {
424 timer_T *timer = NULL;
425 int paused = (int)tv_get_number(&argvars[1]);
426
427 if (argvars[0].v_type != VAR_NUMBER)
428 emsg(_(e_number_exp));
429 else
430 {
431 timer = find_timer((int)tv_get_number(&argvars[0]));
432 if (timer != NULL)
433 timer->tr_paused = paused;
434 }
435 }
436
437 /*
438 * "timer_start(time, callback [, options])" function
439 */
440 void
441 f_timer_start(typval_T *argvars, typval_T *rettv)
442 {
443 long msec = (long)tv_get_number(&argvars[0]);
444 timer_T *timer;
445 int repeat = 0;
446 callback_T callback;
447 dict_T *dict;
448
449 rettv->vval.v_number = -1;
450 if (check_secure())
451 return;
452 if (argvars[2].v_type != VAR_UNKNOWN)
453 {
454 if (argvars[2].v_type != VAR_DICT
455 || (dict = argvars[2].vval.v_dict) == NULL)
456 {
457 semsg(_(e_invarg2), tv_get_string(&argvars[2]));
458 return;
459 }
460 if (dict_find(dict, (char_u *)"repeat", -1) != NULL)
461 repeat = dict_get_number(dict, (char_u *)"repeat");
462 }
463
464 callback = get_callback(&argvars[1]);
465 if (callback.cb_name == NULL)
466 return;
467
468 timer = create_timer(msec, repeat);
469 if (timer == NULL)
470 free_callback(&callback);
471 else
472 {
473 set_callback(&timer->tr_callback, &callback);
474 rettv->vval.v_number = (varnumber_T)timer->tr_id;
475 }
476 }
477
478 /*
479 * "timer_stop(timer)" function
480 */
481 void
482 f_timer_stop(typval_T *argvars, typval_T *rettv UNUSED)
483 {
484 timer_T *timer;
485
486 if (argvars[0].v_type != VAR_NUMBER)
487 {
488 emsg(_(e_number_exp));
489 return;
490 }
491 timer = find_timer((int)tv_get_number(&argvars[0]));
492 if (timer != NULL)
493 stop_timer(timer);
494 }
495
496 /*
497 * "timer_stopall()" function
498 */
499 void
500 f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
501 {
502 stop_all_timers();
503 }
504
505 # endif // FEAT_TIMERS
506
507 #endif // FEAT_EVAL
395 508
396 /* 509 /*
397 * If 'autowrite' option set, try to write the file. 510 * If 'autowrite' option set, try to write the file.
398 * Careful: autocommands may make "buf" invalid! 511 * Careful: autocommands may make "buf" invalid!
399 * 512 *