diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-05-03 17:21:46 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-05-03 17:31:52 +0200 |
| commit | 02c18c23d7eb8e520e8584af183ca9b67937d45d (patch) | |
| tree | 9a3caaa42dcb1d79074bd30476a8fc0d1f6207f7 /vis.c | |
| parent | 3a1b14314b9b7c00aa78eee0b2aa5b492f2dd40f (diff) | |
| download | vis-02c18c23d7eb8e520e8584af183ca9b67937d45d.tar.gz vis-02c18c23d7eb8e520e8584af183ca9b67937d45d.tar.xz | |
vis: introduce count iterator to handle interrupted flag
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1545,6 +1545,28 @@ void vis_count_set(Vis *vis, int count) { vis->action.count = (count >= 0 ? count : VIS_COUNT_UNKNOWN); } +VisCountIterator vis_count_iterator_get(Vis *vis, int def) { + return (VisCountIterator) { + .vis = vis, + .iteration = 0, + .count = vis_count_get_default(vis, def), + }; +} + +VisCountIterator vis_count_iterator_init(Vis *vis, int count) { + return (VisCountIterator) { + .vis = vis, + .iteration = 0, + .count = count, + }; +} + +bool vis_count_iterator_next(VisCountIterator *it) { + if (it->vis->interrupted) + return false; + return it->iteration++ < it->count; +} + void vis_exit(Vis *vis, int status) { vis->running = false; vis->exit_status = status; |
