Suite101
Post this Blog to facebook Add this Blog to del.icio.us! Digg this Blog furl this Blog Add this Blog to Reddit Add this Blog to Technorati Add this Blog to Newsvine Add this Blog to Windows Live Add this Blog to Yahoo Add this Blog to StumbleUpon Add this Blog to BlinkLists Add this Blog to Spurl Add this Blog to Google Add this Blog to Ask Add this Blog to Squidoo

Sep 29, 2006

Console programming and Curses

The discussions here at Suite sometimes throw up a question to which even I have to sit back and think about. Drawing a rectangle on the screen was one such question.

This, I told myself, is easy. I've done it in BASIC (in 1982), in C (in 1992), and in many other languages since. But, those wree for me. For fun.

This is telling someone else how to go about it.

So, I thought I'd be nice. Since the question mentioned words like 'void' I assumed that the person asking it wanted a C styled answer. Text was mentioned, so I immediately thought, being a Win32 programmer, of using a Console Window.

Then, I thought that maybe that was too specific and non-portable. So I went for a conio solution. Then I tried to compile it under a generic Unix and failed miserably.

That's when I discovered the curses library. Now, my C command line programming toolbox is one step closer to completion. I've also learned a thing or two about porting applications, and writing for potability.

As for the text rectangle that started it all...

Check out the How to draw a Box on the Screen in C article for the full solution.