Reputation: 107
This should work Can anyone tell me why I see no typed output on the screen?
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
int nRows;
int nCols;
WINDOW *myPad;
int main(void)
{
initscr();
getmaxyx(stdscr, nRows, nCols);
myPad = newpad(nRows, nCols);
while (1)
{
waddch(myPad, wgetch(myPad));
prefresh(myPad, 0, 0, 0, 0, nRows, nCols);
}
return EXIT_SUCCESS;
}
I have no idea ... other similar examples work. Could this be an Ubuntu issue?
18.04.3 latest patches of today.
Upvotes: 2
Views: 178
Reputation: 54515
After calling initscr
, the current position in stdscr
is 0,0
. Your program then asks for the position and uses it as the size of a pad:
A pad with zero lines and zero columns will not show much on the screen.
In the altered question, there are still two problems:
cbreak
to change that)refresh
before the loop (to ensure that stdscr
is displayed).Here is a diff showing what might be done to fix those problems:
> diff -u foo.c.orig foo.c
--- foo.c.orig 2019-08-21 19:24:24.000000000 -0400
+++ foo.c 2019-08-21 19:30:46.202769968 -0400
@@ -13,12 +13,14 @@
{
initscr();
+ cbreak();
+ noecho();
getmaxyx(stdscr, nRows, nCols);
myPad = newpad(nRows, nCols);
-
+ refresh();
while (1)
{
waddch(myPad, wgetch(myPad));
Upvotes: 1