當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。