Vavas42
Vavas42

Reputation: 1

Ncurses, updating screen and breaking a loop

I'm trying to make a htop like in ncurses.

I'm doing an infinite loop to have the information updating and a condition to make it stop. But it doesn't update itself because it wants to check the input before.

What shall I do ?

Upvotes: 0

Views: 699

Answers (2)

user2417891
user2417891

Reputation: 15

When you are initializing the curses parameters, you could use the next function

timeout(TIME_IN_MILLIS);

code sample:

initscr();
cbreak(); 
noecho();
nonl();

timeout(1000);
mvprintw( 1, 1, "%s", "Hello World!" );
refresh();
getch();
endwin();

Upvotes: 0

Hisham H M
Hisham H M

Reputation: 6798

htop author here -- htop itself is written in ncurses. You need to use the halfdelay() function to make the input function timeout.

See http://linux.die.net/man/3/halfdelay

Upvotes: 1

Related Questions