diff src/evalfunc.c @ 9790:34cc6a101340 v7.4.2170

commit https://github.com/vim/vim/commit/8e97bd74b5377753597e3d98e7123d8985c7fffd Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 6 22:05:07 2016 +0200 patch 7.4.2170 Problem: Cannot get information about timers. Solution: Add timer_info().
author Christian Brabandt <cb@256bit.org>
date Sat, 06 Aug 2016 22:15:05 +0200
parents 5385e72e1ac2
children 6a28d0c6f929
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -396,6 +396,7 @@ static void f_tan(typval_T *argvars, typ
 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_start(typval_T *argvars, typval_T *rettv);
 static void f_timer_stop(typval_T *argvars, typval_T *rettv);
 #endif
@@ -815,6 +816,7 @@ static struct fst
     {"test_null_string", 0, 0, f_test_null_string},
     {"test_settime",	1, 1, f_test_settime},
 #ifdef FEAT_TIMERS
+    {"timer_info",	0, 1, f_timer_info},
     {"timer_start",	2, 3, f_timer_start},
     {"timer_stop",	1, 1, f_timer_stop},
 #endif
@@ -11961,6 +11963,31 @@ free_callback(char_u *callback, partial_
 
 #ifdef FEAT_TIMERS
 /*
+ * "timer_info([timer])" function
+ */
+    static void
+f_timer_info(typval_T *argvars, typval_T *rettv)
+{
+    timer_T *timer = NULL;
+
+    if (rettv_list_alloc(rettv) != OK)
+	return;
+    if (argvars[0].v_type != VAR_UNKNOWN)
+    {
+	if (argvars[0].v_type != VAR_NUMBER)
+	    EMSG(_(e_number_exp));
+	else
+	{
+	    timer = find_timer((int)get_tv_number(&argvars[0]));
+	    if (timer != NULL)
+		add_timer_info(rettv, timer);
+	}
+    }
+    else
+	add_timer_info_all(rettv);
+}
+
+/*
  * "timer_start(time, callback [, options])" function
  */
     static void