是否可以更改文本的颜色并使其从TCL脚本中粗体并输出到控制台/终端?
我在论坛上找到了这是一个例子,但是我得到了以下错误:
错误:无法执行"tput":没有这样的文件或目录过程“颜色”第4行:
想知道有人能不能给我建议。
提前谢谢你,
参考文献中的示例(见上面的链接),Donal Fellows提供的示例
proc color {foreground text} {
# tput is a little Unix utility that lets you use the termcap database
# *much* more easily...
return [exec tput setaf $foreground]$text[exec tput sgr0]
}
puts "Why not [color 4 G][color 1 o][color 3 o][color 4 g][color 2 l][color 1 e] first?"
# Hmm, that's clearer than using those escapes directly too!
发布于 2016-04-02 12:43:31
tput
是一个linux命令,它是ncurses
包的一部分。如果您没有使用任何linux版本,或者ncurses包没有正确安装-您将得到此错误。所以如果你用
是否安装了linux-检查ncurses库。
窗口:-
它更好地使用了twapi
软件包。
安装twapi。
teacup install twapi
试试下面的tclsh。
# Import package twapi
package require twapi
# Get handler of console
set hndl [twapi::get_console_handle stdout]
# Set console foreground color to red
twapi::_set_console_default_attr $hndl fgred 1
https://stackoverflow.com/questions/36372248
复制相似问题