9 Star 48 Fork 11

ShirDon-廖显东 / RustTerm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Rust跨平台终端操作库

当Rust语言的终端库只为UNIX系统编写时,您是否曾感到失望?

rustterm提供了清除、输入处理、样式设置、光标移动和终端操作

Windows和UNIX系统。

rusterm的目标是简单且易于调用代码。通过rustterm的简单性,您不必

担心你工作的平台。

这个机箱支持所有的UNIX和Windows终端,直到Windows7(不是所有的终端都经过测试, 查看 Tested Terminals 获取更多信息).

Tips:作者《Go Web编程实战派》出版了,促销活动中,想学Go Web编程的朋友,欢迎京东当当购买! 当当(🔥🔥🔥🔥🔥🔥 活动抢购中......):http://product.dangdang.com/29225055.html 京东(🔥🔥🔥🔥🔥🔥 活动抢购中......):https://item.jd.com/13200972.html

目录

特色

  • 跨平台
  • 多线程(发送、同步)
  • 详细文件
  • 依赖关系很少
  • 完全控制输出缓冲区
  • 光标(功能“Cursor”)
    • 将光标移动N次(上、下、左、右)
    • 设置/获取光标位置
    • 存储光标位置,稍后恢复
    • 隐藏/显示光标
    • 启用/禁用光标闪烁(并非所有终端都支持此功能)
  • 样式化输出(功能“style”)
    • 前景色(16基色)
    • 背景色(16基色)
    • 256(ANSI)颜色支持(仅限Windows 10和UNIX)
    • RGB颜色支持(仅限Windows 10和UNIX)
    • 文本属性,如粗体、斜体、下划线、交叉等。
  • 终端(功能“终端”)
    • 清除(所有行,当前行,从光标向下和向上,直到新行)
    • 上下滚动
    • 设置/获取终端大小
    • 退出当前进程
  • 输入(功能“Input”)
    • 读字符
    • 读取行
    • 读取密钥输入事件(异步/同步)
    • 读取鼠标输入事件(按下、释放、位置、按钮)
  • 屏幕(功能“Screen”)
    • 交替屏幕
    • 原始屏幕

已经测试的终端

  • Windows Powershell
    • Windows 10 (Pro)
  • Windows CMD
    • Windows 10 (Pro)
    • Windows 8.1 (N)
  • Ubuntu Desktop Terminal
    • Ubuntu 17.10
  • (Arch, Manjaro) KDE Konsole
  • Linux Mint

这个机箱支持所有UNIX终端和Windows终端,直到Windows 7;但是,并不是所有的

终端已经过测试。如果您已将此库用于除上述列表之外的终端

问题,然后请随意添加到上面的列表-我真的很感激!

入门

点击展示Cargo.toml.配置文件
[dependencies]
rustterm = "0.13"

use std::io::{stdout, Write};

use rustterm::{execute, ExecutableCommand, style::{Attribute, Color, SetForegroundColor, SetBackgroundColor, ResetColor}, Output, Result};

fn main() -> Result<()> {
    // 调用 macro
    execute!(
        stdout(),
        SetForegroundColor(Color::Blue),
        SetBackgroundColor(Color::Red),
        Output("Styled text here."),
        ResetColor
    )?;

    // 或者调用方法
    stdout()
        .execute(SetForegroundColor(Color::Blue))?
        .execute(SetBackgroundColor(Color::Red))?
        .execute(Output("Styled text here."))?
        .execute(ResetColor)?;

    Ok(())
}

功能标志

默认情况下启用所有功能。您可以禁用默认功能并仅启用其中一些功能。

[dependencies.rustterm]
version = "0.12"
default-features = false        # Disable default features
features = ["cursor", "screen"] # Enable required features only
Feature Description
input Sync/Async input readers
cursor Cursor manipulation
screen Alternate screen & raw mode
terminal Size, clear, scroll
style Colors, text attributes

作者

  • Shirdon - Project Owner & creator

许可证

这个项目,rusterm和它的所有子板条箱:rusterm_screenrusterm_cursorrusterm_style

rusterm_inputrusterm_terminalrusterm_winapirusterm_utils是MIT

MIT License Copyright (c) 2019 Shirdon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

RustTerm是一个Rust开发的跨平台终端操作库, let's go rust! 一起学习rust!推广rust!喜欢就star一下吧~ 展开 收起
Rust
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Rust
1
https://gitee.com/shirdonl/RustTerm.git
git@gitee.com:shirdonl/RustTerm.git
shirdonl
RustTerm
RustTerm
master

搜索帮助