Skip to main content

一个在终端中输出色彩斑斓、颜色多样内容以及快捷输入的强大工具。A powerful tool for print colorfully and input quickly in terminal.

Project description

NbCmdIO: 终端色彩与交互的革命者⌨️

Terminal Art

NbCmdIO 是一个强大的Python库,将普通的命令行终端转变为充满活力的视觉画布和强大的交互平台!告别单调的黑白输出,迎接RGB真彩世界;告别笨重的文本界面,迎接精准的光标控制和输入捕获能力。

🌟 核心功能亮点

⚡ 支持链式调用

  • 随时随地,设置光标位置、样式,方便快捷、清晰易读! prt[row, col].bold("text")

🎨 真彩RGB终端着色

  • 支持以RGB、HEX格式设定前景色、背景色
  • 支持默认颜色:Black、Red、Green等
  • 支持Bold、Underline、Italics等效果

🖱️ 像素级光标控制

  • 精确到字符的光标定位
  • 保存/恢复光标位置

📦 动态区域管理

  • 创建独立更新区域
  • 嵌套区域支持

⌨️ 输入捕获(...ing)

  • 单键无缓冲读取
  • 快捷键组合检测

🚀 快速入门

安装

pip install nbcmdio

基础使用

from nbcmdio import prt

def NbCmdIO():
    lavender = "#ccf"
    # 清屏并设置终端标题
    prt.cls().setTitle("NbCmdIO")
    # 在第2行 以文字黄色 背景色#ccf  居中显示
    prt[2].fg_yellow().bg_hex(lavender).alignCenter(" NbCmdIO by Cipen ")
    WIDTH = 40
    HEIGHT = 10
    center_offset = (prt.size_col - WIDTH) // 2
    # 以前景#CCF 在 3,centerOffset 处 绘制指定大小的方形,并默认设定新区域 为该方形
    prt.fg_hex(lavender)[3, center_offset].rectangle(WIDTH, HEIGHT)
    prt.fg_blue()[0, 3](" NbCmdIO ").bold()[0, WIDTH - 8](prt.__version__)
    b2 = "  "
    # 进入上下文(里面不会自动重置样式),在区域的4个角添加方形色块
    with prt.bg_hex(lavender):
        prt[1, 1](b2)[1, WIDTH - 1](b2)
        prt[HEIGHT, 1](b2)[HEIGHT, WIDTH - 1](b2)
    # 字符串内添加样式
    line1 = f"Welcome to {prt.bold().bg_hex(lavender).fg_hex('#000')} NbCmdIO "
    line2 = "Print your string colorfully!"
    # 保存并使用样式
    head_style = prt.fg_red().bold().makeStyle()
    prt[1].use(head_style).alignCenter(line1)  # 在新区域第一行使用样式居中显示文本
    prt[2].use(head_style).alignCenter(line2)
    prt[3, 3].fg_grey().hline(WIDTH - 4)

    text = r"""
 _____    _____    _______ 
|  _  \  |  _  \  |__   __|
| |__) | | |__) |    | |   
|  __ /  |  _  <     | |   
| |      | | \ \     | |   
|_|      |_|  \_\    |_|   """[1:]
    lines = text.splitlines()
    chr1 = [l[:8] for l in lines]
    chr2 = [l[8:18] for l in lines]
    chr3 = [l[18:] for l in lines]
    prt.fg_red().bold()[4, 8].printLinesInRegion(chr1)
    prt.fg_green().bold()[4, 16].printLinesInRegion(chr2)
    prt.fg_blue().bold()[4, 25].printLinesInRegion(chr3)

    # 光标跳至本区域下一行,结束
    prt[HEIGHT + 1].setOriginTerm().end()

NbCmdIO()

🔮 未来路线图

版本 功能 状态
v1.0 RGB色彩支持、区域管理 ✅ 已发布
v2.0 输入捕获系统 📅 规划中
v3.0 终端UI组件库 💡 构思中

🌍 社区贡献

我们欢迎各种形式的贡献!无论您是:

  • 发现并报告问题
  • 提交功能请求
  • 贡献代码
  • 创作文档
  • 分享创意用例

📜 开源协议

NbCmdIO采用MIT许可证 - 您可以自由地在商业和个人项目中使用它!

✨ 立即体验终端魔法!

pip install nbcmdio

准备好将您的命令行体验提升到全新维度了吗?NbCmdIO正在等待为您的终端注入生命!


PyPI Version Downloads License Python Versions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbcmdio-1.8.4.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbcmdio-1.8.4-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file nbcmdio-1.8.4.tar.gz.

File metadata

  • Download URL: nbcmdio-1.8.4.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.8

File hashes

Hashes for nbcmdio-1.8.4.tar.gz
Algorithm Hash digest
SHA256 309cfbb4471941d13b6de06e28440a5e0516b23bd7f74ccdbdf383ac4e619bf7
MD5 94bfd6534daa03662a1da6f503a8d5af
BLAKE2b-256 c927ccbd6017ddece51503cd57f28d48d144c4dc1340cf0be32acc4f514d1417

See more details on using hashes here.

File details

Details for the file nbcmdio-1.8.4-py3-none-any.whl.

File metadata

  • Download URL: nbcmdio-1.8.4-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.8

File hashes

Hashes for nbcmdio-1.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7b183e68c6c0d44448749750728d722bec270c72a91ea09b3d0e8c86f9f18684
MD5 c6c5d3f33d5bf8fd92cb689c894a3189
BLAKE2b-256 d1f6c69fd4cedbaae782d2483d030012f830e405e20db1feef577a7a9d055f14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page