artist has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I have to design and code an application using curses in Perl. I have file with data in various fields.I need following functionalities. Now I haven't designed an application like this before so I may miss other important features. But this is what I can think of currently.

Your input will be valuable. Here is a sample program for curses, Here is the code if anyone want to give it a shot.

#!/usr/local/bin/perl use strict; use Curses; &initialize(); &routine(); &finalize(); sub routine { while(1){ while ((my $key = getch()) ne ERR) { if($key eq 'q'){ &clear_screen; done("See you again!"); } if($key eq 'h'){ &clear_screen; print_me("Hello"); } if($key eq 'w'){ &clear_screen; print_me("World"); } } } } sub initialize{ Curses::initscr(); Curses::noecho(); Curses::cbreak(); Curses::nodelay(1); } sub finalize{ Curses::endwin(); exit(0); } sub print_me { my $string = shift; Curses::move(10,20); Curses::addstr($string); Curses::move(0,0); } sub clear_screen { Curses::move(10,20); Curses::addstr(" "x70); } sub done { endwin(); print "@_\n"; exit; }
Your help would be useful in any direction, including suggestions and examples.

Thanks
Artist

Replies are listed 'Best First'.
Re: Application using Curses
by derby (Abbot) on Jul 29, 2003 at 15:07 UTC
    may miss other important features ... hmm you mean like handling the ga-billion different terminals out there? Or the signal handling you need to ensure your terminal is usable after some wayward error? Or the differing curses libraries (I forget which one Curses is built on). Or are you talking about the simple stuff like how to carve up a screen for user input and display? Wether to always have a command line or display it automatically or with newer libs - pop-ups? O'Reilly has a good book on programming curses but it's C based.

    Sorry to sound sarcastic but I was so so so happy when the web came around so I could abandon curses programming. The last curses based app I worked on (C based), I cheated and used curses just for the menuing system. For display, I shelled out to whatever editor the user configured. That made life easier for all involved. The end users loved not having to learn new keystrokes and I loved not having to write curses code.

    But then again, there may be some monks out there that thrived on it - to each his own.

    -derby