Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a norm or standard width for Gnu-Linux/Unix-terminals?

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.

like image 293
AlexTheBird Avatar asked Jul 28 '11 17:07

AlexTheBird


People also ask

What is terminal width?

The “normal” size for a terminal is 80 columns by 24 rows.

How do I change terminal width?

Quick tip: You can also use the Ctrl + Shift , (comma) keyboard shortcut to open the settings page. Click on Startup. Under the “Launch size” section, use the Columns option to adjust the width of the Windows Terminal. Under the “Launch size” section, use the Rows option to adjust the height of the Windows Terminal.

What is size Unix?

The GNU size utility lists the section sizes---and the total size---for each of the object or archive files objfile in its argument list. By default, one line of output is generated for each object file or each module in an archive. objfile... are the object files to be examined.


2 Answers

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

like image 131
RestingRobot Avatar answered Nov 15 '22 16:11

RestingRobot


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;
}
like image 25
ak2 Avatar answered Nov 15 '22 14:11

ak2