as you all know, tput is somewhat of a utility that can be used to put the cursor on specific places on the screen. now, I usually use this utility when I do shell programming but I began wondering that there should be a way to put that utility into my c program so I can be able to clear the screen and also display the cursor at where ever i choose.
now, i know this is confusing but please, help me in anyway you can.
heres an idea of what am talking about
you create a file called cursor containing this line:
tput cup $1 $2
you make the file cursor executable.
In an ordinary shell scripting file, if i want to display a line on a screen, all i have to type is something like this:
cursor 16 41; echo "Please enter your salary: "
16 and 41 being the position on the screen i want the line "Please enter your salary" to appear on.
now, how can i do something like that in C. how can i incorporate it in a C programming application.
do i put it in before the int main () function or after or in between.??
Why not use the ncurses library directly in your C programs?
Documentation included in the source tarball at NCURSES – New Curses
I'm not familiar with ncurses programming, but this small code snippet may give you some insights of what this tastes like (it works for me from my cursory glance of the man pages, but the program may not be strictly a correct one)
#include <curses.h>
#include <unistd.h>
int main(int argc, char* argv[]) {
(void) initscr();
erase();
move(4, 3); /* Move to line 4, col 3 */
addstr("H E L L O W O R L D !"); /* print char */
refresh();
sleep(5);
endwin();
return 0;
}
\(void\) initscr\(\);
erase\(\);
move\(4, 3\); /* Move to line 4, col 3 */
addstr\("H E L L O W O R L D !"\); /* print char */
refresh\(\);
sleep\(5\);
endwin\(\);
return 0;
}
now what i what to know is how do i tweak this program to accept input from the user and do whatever i want to do with it.
to start tweaking it, i assume i'd have to start at the addstr(HELLO WORLD) line. right? if not, please spray me some suggestions