0
0
mirror of https://github.com/vim/vim.git synced 2025-10-13 06:54:15 -04:00

patch 7.4.2180

Problem:    There is no easy way to stop all timers.  There is no way to
            temporary pause a timer.
Solution:   Add timer_stopall() and timer_pause().
This commit is contained in:
Bram Moolenaar
2016-08-07 18:22:53 +02:00
parent e4a76ad0e7
commit b73598e2f0
8 changed files with 161 additions and 20 deletions

View File

@@ -397,8 +397,10 @@ static void f_tanh(typval_T *argvars, typval_T *rettv);
#endif
#ifdef FEAT_TIMERS
static void f_timer_info(typval_T *argvars, typval_T *rettv);
static void f_timer_pause(typval_T *argvars, typval_T *rettv);
static void f_timer_start(typval_T *argvars, typval_T *rettv);
static void f_timer_stop(typval_T *argvars, typval_T *rettv);
static void f_timer_stopall(typval_T *argvars, typval_T *rettv);
#endif
static void f_tolower(typval_T *argvars, typval_T *rettv);
static void f_toupper(typval_T *argvars, typval_T *rettv);
@@ -817,8 +819,10 @@ static struct fst
{"test_settime", 1, 1, f_test_settime},
#ifdef FEAT_TIMERS
{"timer_info", 0, 1, f_timer_info},
{"timer_pause", 2, 2, f_timer_pause},
{"timer_start", 2, 3, f_timer_start},
{"timer_stop", 1, 1, f_timer_stop},
{"timer_stopall", 0, 0, f_timer_stopall},
#endif
{"tolower", 1, 1, f_tolower},
{"toupper", 1, 1, f_toupper},
@@ -11987,6 +11991,25 @@ f_timer_info(typval_T *argvars, typval_T *rettv)
add_timer_info_all(rettv);
}
/*
* "timer_pause(timer, paused)" function
*/
static void
f_timer_pause(typval_T *argvars, typval_T *rettv UNUSED)
{
timer_T *timer = NULL;
int paused = (int)get_tv_number(&argvars[1]);
if (argvars[0].v_type != VAR_NUMBER)
EMSG(_(e_number_exp));
else
{
timer = find_timer((int)get_tv_number(&argvars[0]));
if (timer != NULL)
timer->tr_paused = paused;
}
}
/*
* "timer_start(time, callback [, options])" function
*/
@@ -12048,6 +12071,15 @@ f_timer_stop(typval_T *argvars, typval_T *rettv UNUSED)
if (timer != NULL)
stop_timer(timer);
}
/*
* "timer_stopall()" function
*/
static void
f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
stop_all_timers();
}
#endif
/*