## Copyright (C) 2021  Brodie Gaslam
##
## This file is part of "fansi - ANSI Control Sequence Aware String Functions"
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 or 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## Go to <https://www.r-project.org/Licenses> for copies of the licenses.

str.1 <- c("hello", "\033[44mworld", "barrow")

substr_ctl(str.2, 2, 2, carry = TRUE, terminate = FALSE)

substr_ctl(str.3, 2, 2, carry = TRUE, terminate = FALSE)

wrp.0 <- c("once upon \033[44ma time in a land far away over ", 
    "the mountains and \033[7m sea lived a fair creature ", "with \033[4mdark itentions and a yappy dog.")

once upon [44ma time in a land far away over
the mountains and [7m sea lived a fair creature
with [4mdark itentions and a yappy dog.

strwrap_ctl(wrp.0, 20, carry = "\033[33m")

strwrap_sgr(wrp.0, 20, carry = "\033[33m")

strtrim_ctl(wrp.0, 20, carry = "\033[33m")

strtrim_sgr(wrp.0, 20, carry = "\033[33m")

wrp.1 <- c("once upon \033[44ma time in a land far away over ", 
    "the mountains and \033[7m sea lived a \033[32mfair creature ", 
    "with \033[4mdark itentions and a yappy dog.")

once upon [44ma time in a land far away over
the mountains and [7m sea lived a [32mfair creature
with [4mdark itentions and a yappy dog.

wrp.2 <- c("hello \033[42mworld", "goodnight\033[49m moon", "oh \033[39mboy")

strwrap_ctl(wrp.2, 10, carry = "\033[35m", simplify = FALSE)

strwrap_ctl(wrp.2, 10, carry = "\033[35m", simplify = FALSE, 
    terminate = FALSE)

# unlike substr/wrap normalize does not add the color from carry,
# it just accounts for its presence from prior strings in e.g. computing
# the close string.

substr_ctl("", 2, 3, carry = "\033[33m", terminate = FALSE)