diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-05-30 11:35:15 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-05-30 11:35:15 +0200 |
commit | b258c174a4e826c151adb216553628987e50f7c8 (patch) | |
tree | ca718fc5092cb64ff434f80dd7900fd1d87ec32f | |
parent | d3a9d7a5c6f891acf2eb0bcdc32b68795c9c225b (diff) | |
download | messenger-cli-b258c174a4e826c151adb216553628987e50f7c8.tar.gz messenger-cli-b258c174a4e826c151adb216553628987e50f7c8.zip |
Taking care of the application window
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/application.c | 17 | ||||
-rw-r--r-- | src/application.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/application.c b/src/application.c index a56fd43..74641c5 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -34,10 +34,17 @@ application_init(MESSENGER_Application *app, | |||
34 | app->argc = argc; | 34 | app->argc = argc; |
35 | app->argv = argv; | 35 | app->argv = argv; |
36 | 36 | ||
37 | initscr(); | 37 | app->window = initscr(); |
38 | |||
39 | if (!(app->window)) | ||
40 | { | ||
41 | app->status = GNUNET_SYSERR; | ||
42 | return; | ||
43 | } | ||
44 | |||
38 | noecho(); | 45 | noecho(); |
39 | 46 | ||
40 | keypad(stdscr, TRUE); | 47 | keypad(app->window, TRUE); |
41 | timeout(100); | 48 | timeout(100); |
42 | } | 49 | } |
43 | 50 | ||
@@ -49,6 +56,9 @@ run (void *cls, | |||
49 | { | 56 | { |
50 | MESSENGER_Application *app = cls; | 57 | MESSENGER_Application *app = cls; |
51 | 58 | ||
59 | if (!(app->window)) | ||
60 | return; | ||
61 | |||
52 | chat_start(&(app->chat), app, cfg); | 62 | chat_start(&(app->chat), app, cfg); |
53 | } | 63 | } |
54 | 64 | ||
@@ -71,6 +81,9 @@ application_run(MESSENGER_Application *app) | |||
71 | 81 | ||
72 | messages_clear(&(app->messages)); | 82 | messages_clear(&(app->messages)); |
73 | 83 | ||
84 | if (app->window) | ||
85 | delwin(app->window); | ||
86 | |||
74 | endwin(); | 87 | endwin(); |
75 | } | 88 | } |
76 | 89 | ||
diff --git a/src/application.h b/src/application.h index 3e4bede..63e1689 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -41,6 +41,7 @@ typedef struct MESSENGER_Application | |||
41 | int argc; | 41 | int argc; |
42 | 42 | ||
43 | int status; | 43 | int status; |
44 | WINDOW *window; | ||
44 | 45 | ||
45 | MESSENGER_Chat chat; | 46 | MESSENGER_Chat chat; |
46 | 47 | ||