Gnu-Linux/Unix 终端有规范或标准宽度吗?

发布于 2024-11-26 23:34:59 字数 121 浏览 1 评论 0 原文

我必须创建一个在不同的 Gnu-Linux/Unix 终端中写入大量文本的应用程序。有我可以参考的规范或标准宽度吗?我的意思是,就像在网页设计领域一样,他们使用 1024 像素宽度作为经验法则。

感谢您抽出时间。

I have to create an application which writes a big amount of text in different Gnu-Linux/Unix-terminals. Is there a norm or standard width I could refer to? I mean like in the world of web-design where they use 1024 Pixel width as a rule of thumb.

Thanks for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

想你的星星会说话 2024-12-03 23:34:59

传统上,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

猫烠⑼条掵仅有一顆心 2024-12-03 23:34:59

程序可以使用带有 TIOCGWINSZ 请求代码的 ioctl() 系统调用从终端驱动程序获取终端宽度和高度。如果这不可用,默认为 80 似乎是明智的。

例如:

#include <sys/ioctl.h>

int get_term_width(void) {
  struct winsize ws;
  if (ioctl(1, TIOCGWINSZ, &ws) >= 0)
    return ws.ws_col;
  else
    return 80;
}

Programs can obtain the terminal width and height from the terminal driver using the ioctl() system call with the TIOCGWINSZ request code. If that's not available, defaulting to 80 seems sensible.

For example:

#include <sys/ioctl.h>

int get_term_width(void) {
  struct winsize ws;
  if (ioctl(1, TIOCGWINSZ, &ws) >= 0)
    return ws.ws_col;
  else
    return 80;
}
浮云落日 2024-12-03 23:34:59

80 列和 24 是旧的 VT200 标准,保留了很长时间。

对于当今的图形监视器,您无法坚持这一点,但还有其他方法。
查看 ncurses。它是在控制台上定位文本的功能集,无论是否调整大小等。 WeechatIrssi 是 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.

失退 2024-12-03 23:34:59

简而言之,80个字符。

自从打孔卡问世以来,这一直是一种事实上的标准。

In brief, 80 characters.

That's been a sort of de-facto standard since, well, since punched cards actually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文