如何在ncurses中启用32k颜色对? [英] How to enable 32k color pairs in ncurses?

查看:99
本文介绍了如何在ncurses中启用32k颜色对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过ncurses最多可以支持256种颜色和32k对颜色.我自己设法设置了256种颜色,但是找不到有关如何设置32k对颜色的任何信息.

I've read that ncurses can support up to 256 colors and up to 32k color pairs. While I managed to set up 256 colors by myself, I can't find any information on how to set up 32k color pairs.

printf("%d - %d\n", COLORS, COLOR_PAIRS);

256 - 256

虽然对于硬核终端迷来说2种颜色和2种颜色对可能就足够了,但我想知道如何从库中获取最多的颜色.

and while 2 colors and 2 color pairs may be enough for hardcore terminal fans, I'd like to know how to get the most colors out of the library.

推荐答案

默认情况下,ncurses6配置启用了--enable-ext-colors.您还需要--enable-widec(否则,将不使用存储扩展颜色的cchar_t类型).配置脚本会对此发出警告:

By default, ncurses6 configures with --enable-ext-colors enabled. You need also --enable-widec (otherwise, the cchar_t type which stores extended colors is not used). The configure script warns about this:

checking if you want to use extended colors... yes
configure: WARNING: This option applies only to wide-character library

假设您使用扩展的颜色(和宽字符)构建了库,则它能够显示多达256种颜色和多达32767种颜色对(带符号的16位中的最大值)数字).之后,这取决于您正在使用的终端描述(以及终端仿真器).在X Windows中运行的大多数终端仿真器可以显示256种颜色.在X之外,尚不清楚是否有多数.

Assuming that you built the library with extended colors (and wide characters), it is capable of displaying up to 256 colors and up to 32767 color pairs (the maximum value in a signed 16-bit number). After that, it depends on the terminal description that you are using (and the terminal emulator). A majority of the terminal emulators running in X Windows can display 256 colors. Outside of X, it's not clear that there is a majority.

ncurses对每个终端都有相当准确的终端描述(不是,使用TERM=xterm-256color并不是每个终端的答案,因为特殊键和其他特征通常不同于xterm:常见问题解答 也适用于).

ncurses has reasonably accurate terminal descriptions for each of these (and no, using TERM=xterm-256color is not the answer for each, since special keys and other characteristics generally differ from xterm: the FAQ Why not just use TERM set to "xterm"? also applies to xterm-256color).

以下是屏幕截图,显示了xterm运行ncurses测试程序(来自 ncurses-examples )表示宽色:

Here is a screenshot showing xterm running the ncurses test program (from ncurses-examples) for wide colors:

这篇关于如何在ncurses中启用32k颜色对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆