Okay, I am writing an ncurses program.
The Program:
Splits screen into 3 windows, one displaying available commands, another allowing for user input with echo on and nocbreak. The third will display status information.
Once the windows are created and setup, the program will call fork.
The Parent Process will handle the input with echo
The Child Process will handle the status information.
My problem is that in order to update information in the third window I would have to call wrefresh(..). Unfortunately, this will focus the input on the third window, screwing up anything going on in the top window.
Is there a way around this? How would I tell ncurses to hold the input to window 2, and not move it to window 3?
Here is the relevant code example:
Code:
clear();
init_pair(1, COLOR_GREEN, COLOR_BLACK);
createNCursesWindows(Left, Right, Bottom, LeftBorder, RightBorder, BottomBorder);
printBorder(LeftBorder);
printMainMenu(Right, RightBorder);
printBorder(BottomBorder);
wrefresh(Bottom);
wrefresh(Left);
nocbreak();
echo();
keypad(Left, true);
//nodelay(Left, true);
int PID = fork();
// CHILD PROCESS
if (PID == 0){
while (true){
wprintw(Bottom, "!");
wrefresh(Bottom);
sleep(5);
}
}
// PARENT PROCESS
else if (PID > 0){
while (true){
character = wgetch(Left);
}
}
// FORK FAILURE
else{
removeNCursesWindows(Left, Right, Bottom, LeftBorder, RightBorder, BottomBorder);
endwin();
return false;
}