Mercurial > vim
comparison src/ex_cmds2.c @ 9810:6a28d0c6f929 v7.4.2180
commit https://github.com/vim/vim/commit/b73598e2f022a22fec512ea681c70d2775e8fd87
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 7 18:22:53 2016 +0200
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().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 07 Aug 2016 18:30:05 +0200 |
parents | 711b42c1013b |
children | 939a8f55aea0 |
comparison
equal
deleted
inserted
replaced
9809:f08483937ffd | 9810:6a28d0c6f929 |
---|---|
1187 { | 1187 { |
1188 profile_start(&now); | 1188 profile_start(&now); |
1189 next_due = -1; | 1189 next_due = -1; |
1190 for (timer = first_timer; timer != NULL; timer = timer->tr_next) | 1190 for (timer = first_timer; timer != NULL; timer = timer->tr_next) |
1191 { | 1191 { |
1192 if (timer->tr_paused) | |
1193 continue; | |
1192 # ifdef WIN3264 | 1194 # ifdef WIN3264 |
1193 this_due = (long)(((double)(timer->tr_due.QuadPart - now.QuadPart) | 1195 this_due = (long)(((double)(timer->tr_due.QuadPart - now.QuadPart) |
1194 / (double)fr.QuadPart) * 1000); | 1196 / (double)fr.QuadPart) * 1000); |
1195 # else | 1197 # else |
1196 this_due = (timer->tr_due.tv_sec - now.tv_sec) * 1000 | 1198 this_due = (timer->tr_due.tv_sec - now.tv_sec) * 1000 |
1250 remove_timer(timer); | 1252 remove_timer(timer); |
1251 free_timer(timer); | 1253 free_timer(timer); |
1252 } | 1254 } |
1253 | 1255 |
1254 void | 1256 void |
1257 stop_all_timers(void) | |
1258 { | |
1259 timer_T *timer; | |
1260 | |
1261 while (first_timer != NULL) | |
1262 stop_timer(first_timer); | |
1263 } | |
1264 | |
1265 void | |
1255 add_timer_info(typval_T *rettv, timer_T *timer) | 1266 add_timer_info(typval_T *rettv, timer_T *timer) |
1256 { | 1267 { |
1257 list_T *list = rettv->vval.v_list; | 1268 list_T *list = rettv->vval.v_list; |
1258 dict_T *dict = dict_alloc(); | 1269 dict_T *dict = dict_alloc(); |
1259 dictitem_T *di; | 1270 dictitem_T *di; |
1281 # endif | 1292 # endif |
1282 dict_add_nr_str(dict, "remaining", (long)remaining, NULL); | 1293 dict_add_nr_str(dict, "remaining", (long)remaining, NULL); |
1283 | 1294 |
1284 dict_add_nr_str(dict, "repeat", | 1295 dict_add_nr_str(dict, "repeat", |
1285 (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1), NULL); | 1296 (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1), NULL); |
1297 dict_add_nr_str(dict, "paused", (long)(timer->tr_paused), NULL); | |
1286 | 1298 |
1287 di = dictitem_alloc((char_u *)"callback"); | 1299 di = dictitem_alloc((char_u *)"callback"); |
1288 if (di != NULL) | 1300 if (di != NULL) |
1289 { | 1301 { |
1290 if (dict_add(dict, di) == FAIL) | 1302 if (dict_add(dict, di) == FAIL) |