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.
The “normal” size for a terminal is 80 columns by 24 rows.
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.
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.
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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With