diff --git a/driver/cli b/driver/cli index bebcfb1..d0c668b 100755 Binary files a/driver/cli and b/driver/cli differ diff --git a/driver/cli.cpp b/driver/cli.cpp index 03ad066..0947d0c 100644 --- a/driver/cli.cpp +++ b/driver/cli.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include "ui/view_selection.h" #include "ui/view_info.h" #include "ui/view_monitor.h" @@ -25,8 +28,14 @@ std::string ERR_MSG; std::vector win_stack; +volatile int win_changed_cooldown = 0; +volatile bool t_refresh_active = false; +std::thread t_refresh; + void cleanup() { + if(t_refresh.joinable()) + t_refresh.join(); clrtoeol(); refresh(); endwin(); @@ -36,11 +45,26 @@ void signal_handler(int signal) { if(signal == SIGWINCH) { - if(win_stack.size()) + win_changed_cooldown = 10; // 100ms + + if (!t_refresh_active) { - usleep(1000); - win_stack.back()->repaint(); + if(t_refresh.joinable()) + t_refresh.join(); + t_refresh_active = true; + t_refresh = std::thread([](){ + + while(win_changed_cooldown--) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + t_refresh_active = false; + + if(win_stack.size()) + win_stack.back()->repaint(); + + }); } + } else if(signal == SIGINT) { @@ -56,7 +80,7 @@ void init() { // init b15 driver B15F::getInstance(); - //std::cout << std::endl << "Starte in 3s ..." << std::endl; + std::cout << std::endl << "Starte in 3s ..." << std::endl; //sleep(3); // init all ncurses stuff diff --git a/driver/main b/driver/main new file mode 100755 index 0000000..09368ac Binary files /dev/null and b/driver/main differ diff --git a/driver/ui/view_promt.cpp b/driver/ui/view_promt.cpp index 80e2f24..241dfe3 100644 --- a/driver/ui/view_promt.cpp +++ b/driver/ui/view_promt.cpp @@ -58,9 +58,8 @@ std::function ViewPromt::keypress(int& key) if(input.length()) input.pop_back(); break; + case '\t': case KEY_LEFT: - selection = (selection + 1 ) % 2; - break; case KEY_RIGHT: selection = (selection + 1 ) % 2; break; diff --git a/driver/ui/view_selection.cpp b/driver/ui/view_selection.cpp index c6cd98b..88c30c7 100644 --- a/driver/ui/view_selection.cpp +++ b/driver/ui/view_selection.cpp @@ -29,11 +29,14 @@ std::function ViewSelection::keypress(int& key) selection = (selection - 1 + choices.size()) % choices.size(); while(!choices[selection].length() && choices.size()); break; + + case '\t': case KEY_DOWN: do selection = (selection + 1) % choices.size(); while(!choices[selection].length() && choices.size()); break; + case KEY_MOUSE: { // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml @@ -58,6 +61,7 @@ std::function ViewSelection::keypress(int& key) // fall through to next case __attribute__ ((fallthrough)); } + case KEY_ENT: if(selection == choices.size() - 1) // exit key = -1; // do return from view