窗口超过8列时边框无法正确绘制 [英] Borders don't draw properly when window has more than 8 columns

查看:60
本文介绍了窗口超过8列时边框无法正确绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当窗口的宽度大于8时,边框绘制功能似乎无法正确绘制上下边框.作为免责声明,我正在使用KiTTY将SSH SSH到Arch Linux服务器中.

The border drawing functions just don't seem to draw the top and bottom borders properly when the window's width is above 8. As a disclaimer, I'm using KiTTY to SSH into an Arch Linux server.

我是ncurses的新手,所以很有可能我做错了事,但是从我读到的内容来看,这应该是正确的...

I'm a newbie to ncurses, so there's a good chance I'm doing something wrong, but from what I've read this should be right...

#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;
}

运行此代码,这是我看到的:

Running this code, this is what I see:

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",但可以在会话设置中的连接-> 数据-> 终端类型字符串下进行更改strong>.

ncurses uses a terminal capability database to get information about terminal control sequences that a terminal supports. It uses the value of the TERM environment variable to look up this information. PuTTY or KiTTY passes a desired value of the TERM environment variable to the SSH server. Often it is set to "xterm" by default, but it can be changed in the session settings under Connection -> Data -> Terminal-type string.

PuTTY和KiTTY曾经在终端能力数据库中很好地支持"xterm"的控制序列,但是数据库的最新版本(2017年中以后)优化了为"xterm"定义的序列,以使用当前不支持的序列通过PuTTY或KiTTY.具体来说,它现在使用了PuTTY不支持的ECMA-48 REP (重复字符)控制序列.为了使线图在具有最新终端功能数据库的系统上正常工作,需要为PuTTY或KiTTY更改TERM环境变量. (可以如上所述在会话设置中更改它.)终端功能数据库的最新版本的合适值包括"putty"或"putty-256color".值"xterm-old"也可以使用.

PuTTY and KiTTY used to support the control sequences for "xterm" in the terminal capability database quite well, but recent (mid-2017 onwards) versions of the database optimized the sequences defined for "xterm" to use sequences not currently supported by PuTTY or KiTTY. Specifically, it now makes use of the ECMA-48 REP (repeat character) control sequence which is not supported by PuTTY. To make line drawing work properly on systems with a recent terminal capability database, the TERM environment variable needs to be changed for PuTTY or KiTTY. (It can be changed in the session settings as discussed above.) Suitable values for recent versions of the terminal capability database include "putty" or "putty-256color". The value "xterm-old" may also work.

检查主机系统上的"/usr/share/terminfo"目录,以查看系统实际定义了哪些终端类型.终端类型的第一个字母被拆分为一个子目录,例如,"putty"终端类型的终端功能由"/usr/share/terminfo/p/putty"文件定义.

Check the "/usr/share/terminfo" directory on your host system to see which terminal types are actually defined by the system. The first letter of the terminal type is split off as a subdirectory so that, for example, the terminal capabilities for the "putty" terminal type are defined by the "/usr/share/terminfo/p/putty" file.

请注意,此问题不仅影响画线,而且还会影响同一字符的水平重复超过六次.通过 ncurses 常见问题解答解决:

Note that this problem affects not only line-drawing, but any horizontal repeats of the same character more than six times. It is addressed by the ncurses FAQ:

这仅涵盖了终端说明中的功能,而没有解决终端仿真器之间的差异.例如,在 2017年中中,xterm终端的更新说明中添加了ECMA-48 REP (重复字符)控件.自1997年1月以来,它是xterm的一部分,但是使用该功能的终端说明仅是 xterm 的一部分(不是 ncurses ).将其添加到ncurses后,观察到:

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不受影响,因为它不使用TERM=xterm.
  • mlterm和OSX Terminal使用TERM=xterm支持 REP .
  • VTE,konsole,PuTTY,iTerm2不支持 xterm ,尽管他们将TERM设置为 xterm xterm-256color .
  • 屏幕和tmux使用不同的TERM设置,并且似乎可以正常工作(尽管tmux在测试中还有其他问题).
  • 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).

这篇关于窗口超过8列时边框无法正确绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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