当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R tune message_wrap 写一条尊重线宽的消息


写一条尊重线宽的消息

用法

message_wrap(
  x,
  width = options()$width - 2,
  prefix = "",
  color_text = NULL,
  color_prefix = color_text
)

参数

x

消息文本的字符串。

width

宽度的整数。

prefix

位于消息第一行的可选字符串。

color_text, color_prefix

用于为文本和/或前缀着色的函数(或 NULL )。

处理后的文本被返回(不可见),但会写入一条消息。

例子

library(cli)
Gaiman <-
  paste(
    '"Good point." Bod was pleased with himself, and glad he had thought of',
    "asking the poet for advice. Really, he thought, if you couldn't trust a",
    "poet to offer sensible advice, who could you trust?",
    collapse = ""
  )
message_wrap(Gaiman)
#> "Good point." Bod was pleased with himself, and glad he had thought of
#> asking the poet for advice. Really, he thought, if you couldn't trust
#> a poet to offer sensible advice, who could you trust?
message_wrap(Gaiman, width = 20, prefix = "-")
#> - "Good point." Bod
#>   was pleased with
#>   himself, and glad
#>   he had thought of
#>   asking the poet
#>   for advice.
#>   Really, he
#>   thought, if you
#>   couldn't trust a
#>   poet to offer
#>   sensible advice,
#>   who could you
#>   trust?
message_wrap(Gaiman,
  width = 30, prefix = "-",
  color_text = cli::col_silver
)
#> - "Good point." Bod was
#>   pleased with himself, and
#>   glad he had thought of
#>   asking the poet for advice.
#>   Really, he thought, if you
#>   couldn't trust a poet to
#>   offer sensible advice, who
#>   could you trust?
message_wrap(Gaiman,
  width = 30, prefix = "-",
  color_text = cli::style_underline,
  color_prefix = cli::col_green
)
#> - "Good point." Bod was
#>   pleased with himself, and
#>   glad he had thought of
#>   asking the poet for advice.
#>   Really, he thought, if you
#>   couldn't trust a poet to
#>   offer sensible advice, who
#>   could you trust?
源代码:R/logging.R

相关用法


注:本文由纯净天空筛选整理自Max Kuhn等大神的英文原创作品 Write a message that respects the line width。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。