Advertisement

03.01.2008 at 11:27PM PST, ID: 23207185
[x]
Attachment Details

Calcualting terminal/console width, generic unix, C language, stdout w/o curses

Asked by brycen in Unix Systems Programming, C Programming Language, SSH / Telnet Software

Tags: , , ,

I'd like to add an output formatting enhancement to a C language open source command line terminal application.

The application does not place the console into any sort of raw mode, it just uses printf to stdout.  I'd like to format the output a little better, but this requires knowing the current width of the console (and reacting when the width changes).  The code includes termios (#include <termios.h>) if it's present, but does not make any real use of it.  Nothing like ncurses is present in the code at all.

The application must remain fully cross-platform compatible, and not break when used over an ssh or telnet session.  So I'm seeking an answer with an eye to all the gotchas that can come up with terminal width detection.

Again, all I need is the width.  If the width is unavailable, I can fall back to the present assumption that the terminal is infinitely wide.  If the width changes during execution, I must find out.

------------------------------------------------------------------------------------------------------------------------
Keywords: detect, sense, terminal, console, display size, width, wide, columns, output formatting, alternative, TERMIOS.TIOCGWINSZ, without curses, without ncurses, echo $COLUMNS, Linux, Unix, Solaris, cross-platform, generic unix, open source.Start Free Trial
 
Loading Advertisement...
 
[+][-]03.02.2008 at 02:49AM PST, ID: 21025583

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Unix Systems Programming, C Programming Language, SSH / Telnet Software
Tags: Open Source, Unix, Generic - must be a cross-platform solution, C
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 2
Solution Grade: B
 
 
[+][-]03.03.2008 at 03:53AM PST, ID: 21030600

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.11.2008 at 04:28AM PDT, ID: 21094631

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 04:46AM PDT, ID: 21094719

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 05:51AM PDT, ID: 21095162

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 06:06AM PDT, ID: 21095292

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 06:28AM PDT, ID: 21095448

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 06:30AM PDT, ID: 21095467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 07:48AM PDT, ID: 21096215

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 08:26AM PDT, ID: 21096617

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 08:50AM PDT, ID: 21096903

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 08:08PM PDT, ID: 21102691

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 09:05PM PDT, ID: 21102949

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 09:12PM PDT, ID: 21102988

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.12.2008 at 12:14AM PDT, ID: 21103661

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.12.2008 at 01:19AM PDT, ID: 21103871

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.12.2008 at 01:22AM PDT, ID: 21103881

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628