im currently making a project of a typing game, and i want to have a countdown clock window on the top and a typing window running in the buttom, which has to run parallel.
The only way i can think of now is multi threading, and i've researched it which appears that i have to use something like use_screen()
or use_window()
to have multithread support in ncurses. but i can't find any examples about it or tutorials.
so my question is can any one give me an example of the usage of multithreading in ncurses?
or maybe if there's a different approach to having parallel execution in ncurses?
btw i use c++, but any language is probably fine.
For your intended use case, you could just create 2 windows in the main thread. One for the countdown window and one for the typing window. With newwin
you will get the 2 WINDOW*
. You can then set all properties of the windows.
Then, you can write code for your countdown window,
This code will be started with std::async
, which will have the respective WINDOW*
as one of its arguments. The associated code will write the countdown values to the window, with the given parameter.
The rest of the code uses input and output functions for the main window.
IMHO this would be the easiest approach.