Added window winch signal

This commit is contained in:
2017-11-27 18:06:32 +00:00
parent 4add211375
commit b78d59dd85
2 changed files with 14 additions and 0 deletions

View File

@@ -6,6 +6,13 @@
#include "numbers.h"
#include <time.h>
#include <unistd.h> //sleep
#include <signal.h>
void handle_winch(int sig) {
endwin();
clear();
refresh();
}
int main(int argc, char **argv) {
/* enable ncurses standard screen */
@@ -16,6 +23,11 @@ int main(int argc, char **argv) {
keypad(stdscr, FALSE); //Disable the F1-12 keypad
curs_set(0); //Disable the cursor
//Windows resize handler
struct sigaction sa;
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = handle_winch;
sigaction(SIGWINCH, &sa, NULL);
state s = {0};
@@ -81,6 +93,7 @@ void draw(state *s) {
while (1) {
time(&timer);
curTime = localtime(&timer);
initState(s);
drawTime(s, curTime->tm_hour, curTime->tm_min, curTime->tm_sec);
refresh();
sleep(1);