Gnu-Linux/Unix 终端有规范或标准宽度吗?
我必须创建一个在不同的 Gnu-Linux/Unix 终端中写入大量文本的应用程序。有我可以参考的规范或标准宽度吗?我的意思是,就像在网页设计领域一样,他们使用 1024 像素宽度作为经验法则。
感谢您抽出时间。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
传统上,80 个字符的限制(意味着长度超过 80 个字符的行将换行到下一行)已成为常态。然而,关于该标准的相关性已经存在讨论(参见此处)。然而,根据我的大学经历,我们被告知在终端上舒适的观看是 80 个字符。如果您使用 Linux 默认的 12pt 等宽字体,这意味着合适的宽度约为 80 * 一个字符的宽度。更好的解决方案可能是简单地以编程方式截断每行 80 个字符。
总长度:80 个字符
Traditionally, the 80 character limit, (meaning that lines longer than 80 characters are wrapped to the next line), has been the norm. However, there has been discussion about the relevancy of this standard, (see here). In my University experience, however, we were taught that comfortable viewing in a terminal is 80 characters. If you are using the default 12pt monospaced font for linux, this would mean that a good width would be approximately 80 * the width of one character. A better solution would probably be to simply cut off each line at 80 chars programmatically.
tldr: 80 characters
程序可以使用带有
TIOCGWINSZ
请求代码的ioctl()
系统调用从终端驱动程序获取终端宽度和高度。如果这不可用,默认为 80 似乎是明智的。例如:
Programs can obtain the terminal width and height from the terminal driver using the
ioctl()
system call with theTIOCGWINSZ
request code. If that's not available, defaulting to 80 seems sensible.For example:
80 列和 24 是旧的 VT200 标准,保留了很长时间。
对于当今的图形监视器,您无法坚持这一点,但还有其他方法。
查看 ncurses。它是在控制台上定位文本的功能集,无论是否调整大小等。 Weechat和 Irssi 是 ncurses 的著名用户。
80 cols and 24 was the old VT200 standard, that was kept for a long time.
With today's graphical monitors, you can't adhere to that, but there's other means.
Take a look at ncurses. It is a function set of positioning text on the console, no matter if it is re-sized, etc. Weechat and Irssi are prominent users of ncurses.
简而言之,80个字符。
自从打孔卡问世以来,这一直是一种事实上的标准。
In brief, 80 characters.
That's been a sort of de-facto standard since, well, since punched cards actually.