1## Copyright (C) 2021 Brodie Gaslam 2## 3## This file is part of "fansi - ANSI Control Sequence Aware String Functions" 4## 5## This program is free software: you can redistribute it and/or modify 6## it under the terms of the GNU General Public License as published by 7## the Free Software Foundation, either version 2 of the License, or 8## (at your option) any later version. 9## 10## This program is distributed in the hope that it will be useful, 11## but WITHOUT ANY WARRANTY; without even the implied warranty of 12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13## GNU General Public License for more details. 14## 15## Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license. 16 17## Tracks whether we are running in R > 3.2.2 or not (see .onLoad) 18 19R.ver.gte.3.2.2 <- NA 20 21## Internal functions, used primarily for testing 22 23## A version of unique that isn't terrible for very long strings that are 24## actually the same 25 26unique_chr <- function(x) .Call(FANSI_unique_chr, enc2utf8(x)) 27 28## Testing interface for color code to HTML conversion 29 30esc_color_code_to_html <- function(x) { 31 if(!is.matrix(x) || !is.integer(x) || nrow(x) != 5) 32 stop("Argument `x` must be a five row integer matrix.") 33 .Call(FANSI_color_to_html, as.integer(x)) 34} 35 36check_assumptions <- function() .Call(FANSI_check_assumptions) # nocov 37digits_in_int <- function(x) .Call(FANSI_digits_in_int, x) 38 39add_int <- function(x, y) .Call(FANSI_add_int, as.integer(x), as.integer(y)) 40 41## testing interface for low overhead versions of R funs 42 43cleave <- function(x) .Call(FANSI_cleave, x) 44forder <- function(x) .Call(FANSI_order, x) 45sort_chr <- function(x) .Call(FANSI_sort_chr, x) 46 47set_int_max <- function(x) .Call(FANSI_set_int_max, as.integer(x)[1]) 48get_int_max <- function(x) .Call(FANSI_get_int_max) # nocov for debug only 49 50## exposed internals for testing 51 52check_enc <- function(x, i) .Call(FANSI_check_enc, x, as.integer(i)[1]) 53 54## make sure what compression working 55 56ctl_as_int <- function(x) .Call(FANSI_ctl_as_int, as.integer(x)) 57 58