str.3 <- structure("fu\033[42mba\033[0mr", class = "foo", at = "bar")

substr_ctl(str.2, 2, 6, ctl = c("all", "sgr"))

substr_ctl(str.2, 8, 10, ctl = c("all", "sgr"))

Argument `x` contains a non-SGR CSI or a non-URL OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in substr_ctl_internal(x, start = start, stop = stop, type.int = TYPE.INT,  :
  Argument `x` contains a non-SGR CSI or a non-URL OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

# Re-issue when state change out of substring

substr_ctl(str.4, 1, 1, carry = TRUE, terminate = FALSE)

Argument `x` contains a malformed CSI or OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in substr_ctl_internal(x, start = start, stop = stop, type.int = TYPE.INT,  :
  Argument `x` contains a malformed CSI or OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

substr_ctl("a\033[42", 1, 2, terminate = FALSE)

# Incomplete, but we know it's a URL, so we remove it even if past end

substr_ctl("a\033]8;;END", 1, 2, terminate = FALSE)

Argument `x` contains a CSI SGR sequence or OSC hyperlink with invalid substrings at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in substr_ctl_internal(x, start = start, stop = stop, type.int = TYPE.INT,  :
  Argument `x` contains a CSI SGR sequence or OSC hyperlink with invalid substrings at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

substr_ctl("\033[45pA", 1, 1, warn = FALSE)

substr_ctl("\033[45pA", 0, 1, warn = FALSE)

substr_ctl(c("AB", NA, "CD"), 1, 2, carry = TRUE)

substr_ctl(c("AB", "CD"), c(NA, 1), 2, carry = TRUE)

# Old vs new term.cap behavior (almost certainly captured already, but adding
# specific tests).

Argument `x` contains a CSI SGR sequence with color codes not supported by terminal at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.