On Tue, Feb 19, 2008 at 09:52:53AM -0600, Dan Armbrust wrote:
> I have a program that is writing info out to the console - and I need
> to know where to wrap the lines.
> 
> How does one go about finding the width of a console on linux?  Or
> (shudder) on windows?

//--- cut here --- cut here --- cut here --- cut here --- cut here ---

/*
 * Compile me like this:
 *     "cc -lncurses screen_size.c"
 */

#include <curses.h>

int main(void)
{
   int bx, by, mx, my;

   initscr();

   getbegyx(stdscr, by, bx);
   getmaxyx(stdscr, my, mx);

   endwin();

   printf("%d rows and %d columns\n", mx - bx, my - by);

   return 0;
}

//--- cut here --- cut here --- cut here --- cut here --- cut here ---

There is curses for windows, too.

Cheers,
florin

-- 
Bruce Schneier expects the Spanish Inquisition.
      http://geekz.co.uk/schneierfacts/fact/163
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20080219/025b533b/attachment.pgp