-
Notifications
You must be signed in to change notification settings - Fork 6
/
text_wrap.Rd
71 lines (59 loc) · 2.29 KB
/
text_wrap.Rd
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/text.R
\name{text_wrap}
\alias{text_wrap}
\alias{word_wrap}
\alias{meta_word_cat}
\alias{meta_word_msg}
\alias{word_cat}
\alias{word_msg}
\alias{word_comment}
\title{Text Wrapping Utilities}
\usage{
text_wrap(x, width)
word_wrap(x, width = getOption("width"), tolerance = 8L,
hyphens = TRUE, unlist = TRUE, collapse = NULL)
meta_word_cat(..., sep = "\\n", width = getOption("width"),
tolerance = 8L, file = stdout(), trail.nl = TRUE)
meta_word_msg(..., sep = "\\n", width = getOption("width"),
tolerance = 8L, trail.nl = TRUE)
word_cat(..., sep = " ", width = getOption("width"), tolerance = 8L,
file = stdout())
word_msg(...)
word_comment(x, width = getOption("width"), tolerance = 8L,
hyphens = TRUE, unlist = TRUE, color = crayon::has_color())
}
\arguments{
\item{x}{character vector}
\item{width}{what width to wrap at}
\item{tolerance}{how much earlier than \code{width} we're allowed to wrap}
\item{hyphens}{whether to allow hyphenation}
\item{unlist}{logical(1L) if FALSE each element in \code{x} is returned as
an element of a list, otherwise one character vector is returned}
}
\value{
a list with, for each item in \code{x}, a character vector
of the item wrapped to length \code{width}
if \code{unlist} is a parameter, then a character vector, or
if not or if \code{unlist} is FALSE, a list with each element from \code{x}
corresponding to an element from the list
}
\description{
Functions to break up character vector components to a specified width.
}
\details{
\itemize{
\item \code{text_wrap} breaks each element to a specified \code{width},
where \code{width} can contain different values for each value in
\code{x}
\item \code{word_wrap} wraps at whitespace, or crudely hyphenates if
necessary; note that unlike \code{text_wrap} \code{width} must be scalar
\item \code{word_cat} is like \code{word_wrap}, except it outputs to screen
\item \code{word_msg} is like \code{word_cat}, except it ouputs to stderr
\item \code{meta_word_cat} is like \code{word_cat}, except it wraps output
in formatting to highlight this is not normal output
}
Newlines are replaced by empty strings in the output so that each character
vector in the output represents a line of screen output.
}
\keyword{internal}