[1] "> hello >     goodbye" "> hello >moon"

strwrap2_ctl("goodbye moon", 16, indent = 5, prefix = "> hello >", 
    wrap.always = TRUE)

[1] "> hello >     g" "> hello >oodbye" "> hello >moon"

tryCatch(strwrap2_ctl("goodbye moon", 15, indent = 5, prefix = "> hello >", 
    wrap.always = TRUE), error = conditionMessage)

Width error: sum of `indent` and `initial` width or sum of `exdent` and `prefix` width must be less than `width - 1` when in `wrap.always`.

[1] "Width error: sum of `indent` and `initial` width or sum of `exdent` and `prefix` width must be less than `width - 1` when in `wrap.always`."

## Test mixing of SGR with non SGR escapes; non-SGR should not be
## dropped, and _trailing_ SGR should be dropped.

strwrap_ctl("hello \033[44m world", 5, terminate = FALSE)

strwrap_ctl("hello \033[44m world", 6, terminate = FALSE)

strwrap_ctl("hello \n \033[44m\n world", 5)

strwrap_ctl("hello \n \n\033[44m world", 5)

strwrap2_ctl("AB\033[44m\n\nCD", 3, wrap.always = TRUE)

## New paragraph with wrap.always and trailing SGR

strwrap2_ctl("AB\033[44m\n\nCD", 3, wrap.always = TRUE, pad.end = "#")

strwrap2_ctl("AB\033[44m\n\nCD", 3, wrap.always = TRUE, terminate = FALSE)

strwrap2_ctl("AB\033[44m CD", 4, pad.end = "#")

## Don't omit trail SGR when there is padding

strwrap2_ctl("AB\033[44m CD", 3, pad.end = "#")

strwrap2_sgr("\033[43mAB \033[34mCD", strip.spaces = FALSE, 4)

## Combine Leading SGR without stripping spaces

strwrap2_ctl("a\033[31mb", 2, wrap.always = TRUE)

strwrap2_ctl("\033[35phello \033[35p world", 5, strip.spaces = FALSE)

Warning in strwrap2_ctl("\033[35phello \033[35p world", 5, strip.spaces = FALSE) :
  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.

identical(strwrap(c(NA, "a b"), 4, prefix = ">"), strwrap_ctl(c(NA, 
    "a b"), 4, prefix = ">"))

identical(strwrap("a b", 4, prefix = NA), strwrap_ctl("a b", 
    4, prefix = NA))

Error in strwrap2_ctl(x = x, width = width, indent = indent, exdent = exdent,  : 
  Argument `width` must be numeric.