#color #terminal-colors #crossterm #attributes #style #terminal #ansi-colors

废弃 crossterm_style

一个用于美化终端输出的跨平台库

11 个版本 (4 个重大更新)

0.5.2 2019 年 10 月 21 日
0.4.1 2019 年 8 月 2 日
0.4.0 2019 年 7 月 26 日
0.2.0 2019 年 2 月 22 日

#34#crossterm

Download history 306/week @ 2024-03-13 318/week @ 2024-03-20 316/week @ 2024-03-27 385/week @ 2024-04-03 296/week @ 2024-04-10 366/week @ 2024-04-17 447/week @ 2024-04-24 311/week @ 2024-05-01 323/week @ 2024-05-08 310/week @ 2024-05-15 275/week @ 2024-05-22 393/week @ 2024-05-29 306/week @ 2024-06-05 398/week @ 2024-06-12 529/week @ 2024-06-19 359/week @ 2024-06-26

每月下载量 1,662

MIT 许可证

55KB
866

Lines of Code Latest Version MIT docs Join us on Discord

Crossterm Style

crossterm_style 包已被废弃,不再维护。GitHub 仓库将很快被存档。所有代码都将迁移到 crossterm 。您可以在 将子包合并到 crossterm 包 的问题中了解更多信息。

此包允许您处理终端颜色和文本属性。它支持所有 UNIX 和 Windows 7 及以上版本的终端(并非所有终端都经过测试,有关更多信息,请参阅已测试终端)。

crossterm_stylecrossterm 包的子包。您可以直接使用它,但强烈建议您启用 style 功能来使用 crossterm 包。

特性

  • 跨平台
  • 多线程(发送、同步)
  • 详细的文档
  • 依赖项少
  • 样式化输出
    • 前景色(16种基本颜色)
    • 背景色(16种基本颜色)
    • 256 (ANSI) 颜色支持(仅限 Windows 10 和 UNIX)
    • RGB 颜色支持(仅限 Windows 10 和 UNIX)
    • 文本属性,如粗体、斜体、下划线、删除线等。

入门指南

点击以显示 Cargo.toml。
[dependencies]
# All crossterm features are enabled by default.
crossterm = "0.11"

属性

use crossterm::{Colored, Color, Colorize, Styler, Attribute};

// pass any `Attribute` value to the formatting braces.
println!("{} Underlined {} No Underline", Attribute::Underlined, Attribute::NoUnderline);

// you could also call different attribute methods on a `&str` and keep on chaining if needed.
let styled_text = "Bold Underlined".bold().underlined();
println!("{}", styled_text);

// old-way but still usable
let styled_text = style("Bold Underlined").bold().underlined();

颜色

use crossterm::{Colored, Color, Colorize};

println!("{} Red foreground color", Colored::Fg(Color::Red));
println!("{} Blue background color", Colored::Bg(Color::Blue));

// you can also call different coloring methods on a `&str`.
let styled_text = "Bold Underlined".red().on_blue();
println!("{}", styled_text);

// old-way but still usable
let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue);

RGB 颜色和 ANSI 值

use crossterm::{Colored, Color, Colorize};

// custom rgb value (Windows 10 and UNIX systems)
println!("{} some colored text", Colored::Fg(Color::Rgb {
    r: 10,
    g: 10,
    b: 10
}));

// custom ansi color value (Windows 10 and UNIX systems)
println!("{} some colored text", Colored::Fg(Color::AnsiValue(10)));

其他资源

作者

  • Timon Post - 项目负责人 & 创建者

许可证

本项目采用 MIT 许可证 - 有关详细信息,请参阅LICENSE 文件。

依赖项

~29–430KB