5

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.

4 Answers 4

7

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

5

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

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.

2

In brief, 80 characters.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.