[英]How to dynamically change text color in a linux terminal using PuTTy?
我有一个 CS 课程的项目,我的小组想要构建一个基于终端的笔记本程序。 我们想要拥有的功能之一是能够在“亮”和“暗”模式之间切换。 有没有办法像这样动态改变终端的颜色偏好?
PuTTY 响应 Linux 控制台的调色板控件。 这些碰巧不是ANSI转义序列。
除了源代码之外,没有 PuTTY 的相关文档,但 Linux console_codes
联机帮助页包含以下信息:
ESC ] OSC (Should be: Operating system command) ESC ] P
nrrggbb: set palette, with parameter given in 7
hexadecimal digits after the final P :-(. Here n
is the color (0–15), and rrggbb indicates the
red/green/blue values (0–255). ESC ] R: reset
palette
(关于“ANSI”,请参阅BUGS部分)。
用于 ncurses 终端描述linux-c-nc
,
linux-c-nc|linux console with color-change,
ccc,
initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/
%02x%p4%{255}%*%{1000}%/%02x,
oc=\E]R, use=linux-basic,
这最终成为当前的linux
终端描述。 您应该能够使用tput
更改调色板,例如,
tput -T linux initc 0 255 255 255
tput -T linux initc 15 0 0 0
反转黑色 (0) 和白色 (15)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.