3

I'm writing a small program that needs to wrap text to produce multi column output on a terminal screen. This is fairly straightforward, except for having to account for hard tabs, which I cannot do without knowing what the tab stop settings are. Is there a way to query for tab stop settings? On OSX the tabs command appears to set tabs, but doesn't seem to report them. I can possibly parse infocmp output for the it value, but that seems to be just the default tab width, which may or may not line up with the full set of tab stops.

Is there a canonical way of pulling the tab stop settings on unix-like terminals? On Windows?

5

The tabs program uses data from the terminal database, to tell the terminal what tab-stops to use.

The computer does not know about the tab-stops: using stty you can set the terminal driver to use hard-tabs or soft (the usual expansion of 8 columns per tab stop). Whether you set hard/soft tabs, most applications on the system will assume 8, anyway.

The terminal database does not provide a standard way to determine what the tab-stops are set to. For the widely-used VT100 emulations in xterm, etc., it is possible to determine this information by using the cursor-position report. Someone could write an application that wrote tabs, used the cursor-report to see where the cursor ended up, and compute the tab-stops. (The resize program uses the cursor-position report to determine the screen size).

ncurses's terminal database provides u6 capabilities which attempt to describe cursor-position reports, but for practical purposes only the VT100-style reports are supported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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