File: timer.R

package info (click to toggle)
r-cran-cli 3.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,300 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#' @export
`__cli_update_due` <- FALSE

#' @export

cli_tick_reset <- function() {
  .Call(clic_tick_reset)
}

#' @export

ccli_tick_reset <- NULL

cli_tick_set <- function(tick_time = NULL, speed_time = NULL) {
  tick_time <- tick_time %||% clienv$tick_time
  speed_time <- speed_time %||% clienv$speed_time

  clienv$speed_time <- as.double(speed_time)
  clienv$tick_time <- as.integer(tick_time)
  .Call(clic_tick_set, clienv$tick_time, clienv$speed_time)
  invisible()
}

cli_tick_pause <- function(state = TRUE) {
  .Call(clic_tick_pause, state)
}

cli_tick_resume <- function(state = TRUE) {
  .Call(clic_tick_resume, state)
}

cli_with_ticks <- function(expr) {
  on.exit(cli_tick_resume(TRUE), add = TRUE)
  opts <- options(cli.progress_show_after = 0)
  on.exit(options(opts), add = TRUE)
  cli_tick_pause(TRUE)
  expr
}

cli_without_ticks <- function(expr) {
  on.exit(cli_tick_resume(TRUE), add = TRUE)
  opts <- options(cli.progress_show_after = 0)
  on.exit(options(opts), add = TRUE)
  cli_tick_pause(FALSE)
  expr
}