当 window 超过 8 列时,边框无法正确绘制
Borders don't draw properly when window has more than 8 columns
当 window 的宽度大于 8 时,边框绘制功能似乎无法正确绘制顶部和底部边框。作为免责声明,我正在使用 KiTTY 通过 SSH 连接到 Arch Linux 服务器。
我是 ncurses 的新手,所以很有可能我做错了什么,但从我读到的内容来看,这应该是正确的...
#include <ncurses.h>
int main() {
initscr(); cbreak();
WINDOW *win = newwin(1,1, 1,1);
for(int i=1; i < 16; ++i) {
wresize(win, i, i);
wclear(win);
box(win, 0,0); // I've also tested wborder()
wrefresh(win);
mvprintw(0,0, "size: %i", i);
getch(); //pause
}
endwin();
return 0;
}
运行这段代码,我看到的是这样的:
size: 8
+------+
¦ ¦ Displays like this (normally)
¦ ¦ for both top and bottom borders
¦ ¦
¦ ¦
¦ ¦
¦ ¦
+------+
size: 9
+-+
¦ ¦ Each size up it will continue
¦ ¦ to look like this, with the
¦ ¦ top and bottom borders looking
¦ ¦ like `+-+`
¦ ¦
¦ ¦
¦ ¦
+-+
ncurses 使用终端能力数据库获取有关终端支持的终端控制序列的信息。它使用 TERM
环境变量的值来查找此信息。 PuTTY 或 KiTTY 将 TERM
环境变量的期望值传递给 SSH 服务器。通常它默认设置为“xterm”,但可以在 Connection -> Data -> [=34 下的会话设置中更改=]终端类型字符串.
PuTTY 和 KiTTY 曾经很好地支持终端功能数据库中“xterm”的控制序列,但最近(2017 年中开始)的数据库版本优化了为“xterm”定义的序列以使用不使用的序列目前由 PuTTY 或 KiTTY 支持。具体来说,它现在使用 PuTTY 不支持的 ECMA-48 REP(重复字符)控制序列。为了使线图在具有最新终端功能数据库的系统上正常工作,需要为 PuTTY 或 KiTTY 更改 TERM
环境变量。 (它可以在上面讨论的会话设置中更改。)终端功能数据库最新版本的合适值包括“putty”或“putty-256color”。值“xterm-old”也可能有效。
检查主机系统上的“/usr/share/terminfo”目录以查看系统实际定义了哪些终端类型。终端类型的第一个字母被拆分为一个子目录,例如,“putty”终端类型的终端功能由“/usr/share/terminfo/p/putty”文件定义。
请注意,此问题不仅会影响线条绘制,还会影响同一字符的水平重复六次以上。它由 ncurses FAQ:
寻址
That only covers the features which are in the terminal description, and does not address differences between terminal emulators. For example, in mid-2017, an update to the xterm terminal description added the ECMA-48 REP (repeat character) control. It was part of xterm since January 1997, but a terminal description using the feature was part of xterm only (not ncurses). After adding it to ncurses, it was observed that:
- rxvt is unaffected, since it does not use
TERM=xterm
.
- mlterm and OSX Terminal supported REP, using
TERM=xterm
.
- VTE, konsole, PuTTY, iTerm2 did not support this standard, longstanding feature, of xterm although they set
TERM
to xterm
or xterm-256color
.
- screen and tmux use a different
TERM
setting, and seemed to work (although tmux had some other issue with the test).
后续行动 2020-09-07
PuTTY 0.71 版(2019 年 3 月 16 日发布)添加了对 REP 转义序列的支持。 (参见change log。)
当 window 的宽度大于 8 时,边框绘制功能似乎无法正确绘制顶部和底部边框。作为免责声明,我正在使用 KiTTY 通过 SSH 连接到 Arch Linux 服务器。
我是 ncurses 的新手,所以很有可能我做错了什么,但从我读到的内容来看,这应该是正确的...
#include <ncurses.h>
int main() {
initscr(); cbreak();
WINDOW *win = newwin(1,1, 1,1);
for(int i=1; i < 16; ++i) {
wresize(win, i, i);
wclear(win);
box(win, 0,0); // I've also tested wborder()
wrefresh(win);
mvprintw(0,0, "size: %i", i);
getch(); //pause
}
endwin();
return 0;
}
运行这段代码,我看到的是这样的:
size: 8
+------+
¦ ¦ Displays like this (normally)
¦ ¦ for both top and bottom borders
¦ ¦
¦ ¦
¦ ¦
¦ ¦
+------+
size: 9
+-+
¦ ¦ Each size up it will continue
¦ ¦ to look like this, with the
¦ ¦ top and bottom borders looking
¦ ¦ like `+-+`
¦ ¦
¦ ¦
¦ ¦
+-+
ncurses 使用终端能力数据库获取有关终端支持的终端控制序列的信息。它使用 TERM
环境变量的值来查找此信息。 PuTTY 或 KiTTY 将 TERM
环境变量的期望值传递给 SSH 服务器。通常它默认设置为“xterm”,但可以在 Connection -> Data -> [=34 下的会话设置中更改=]终端类型字符串.
PuTTY 和 KiTTY 曾经很好地支持终端功能数据库中“xterm”的控制序列,但最近(2017 年中开始)的数据库版本优化了为“xterm”定义的序列以使用不使用的序列目前由 PuTTY 或 KiTTY 支持。具体来说,它现在使用 PuTTY 不支持的 ECMA-48 REP(重复字符)控制序列。为了使线图在具有最新终端功能数据库的系统上正常工作,需要为 PuTTY 或 KiTTY 更改 TERM
环境变量。 (它可以在上面讨论的会话设置中更改。)终端功能数据库最新版本的合适值包括“putty”或“putty-256color”。值“xterm-old”也可能有效。
检查主机系统上的“/usr/share/terminfo”目录以查看系统实际定义了哪些终端类型。终端类型的第一个字母被拆分为一个子目录,例如,“putty”终端类型的终端功能由“/usr/share/terminfo/p/putty”文件定义。
请注意,此问题不仅会影响线条绘制,还会影响同一字符的水平重复六次以上。它由 ncurses FAQ:
寻址That only covers the features which are in the terminal description, and does not address differences between terminal emulators. For example, in mid-2017, an update to the xterm terminal description added the ECMA-48 REP (repeat character) control. It was part of xterm since January 1997, but a terminal description using the feature was part of xterm only (not ncurses). After adding it to ncurses, it was observed that:
- rxvt is unaffected, since it does not use
TERM=xterm
.- mlterm and OSX Terminal supported REP, using
TERM=xterm
.- VTE, konsole, PuTTY, iTerm2 did not support this standard, longstanding feature, of xterm although they set
TERM
toxterm
orxterm-256color
.- screen and tmux use a different
TERM
setting, and seemed to work (although tmux had some other issue with the test).
后续行动 2020-09-07
PuTTY 0.71 版(2019 年 3 月 16 日发布)添加了对 REP 转义序列的支持。 (参见change log。)