aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-08-03 23:47:05 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2022-08-03 23:47:05 +0200
commitc1344f9692273f2e1bd5688adfb39bda33394a0b (patch)
tree5b98c1e38a9d0793d9c016cfa7fd9e36e5c3295b
parent0616015bc457d387dbaa86cd428f119d51511341 (diff)
downloadmessenger-cli-c1344f9692273f2e1bd5688adfb39bda33394a0b.tar.gz
messenger-cli-c1344f9692273f2e1bd5688adfb39bda33394a0b.zip
Implemented dynamic layout with subwindows
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/application.c16
-rw-r--r--src/application.h11
-rw-r--r--src/chat.c200
-rw-r--r--src/chat.h4
-rw-r--r--src/ui/account_create_dialog.c13
-rw-r--r--src/ui/account_create_dialog.h2
-rw-r--r--src/ui/accounts.c6
-rw-r--r--src/ui/accounts.h3
-rw-r--r--src/ui/chat_open_dialog.c13
-rw-r--r--src/ui/chat_open_dialog.h2
-rw-r--r--src/ui/chats.c6
-rw-r--r--src/ui/chats.h3
-rw-r--r--src/ui/members.c4
-rw-r--r--src/ui/members.h2
-rw-r--r--src/ui/messages.c47
-rw-r--r--src/ui/messages.h2
-rw-r--r--src/util.c20
-rw-r--r--src/util.h3
18 files changed, 297 insertions, 60 deletions
diff --git a/src/application.c b/src/application.c
index 65bdd81..d8314df 100644
--- a/src/application.c
+++ b/src/application.c
@@ -51,12 +51,28 @@ application_init(MESSENGER_Application *app,
51 return; 51 return;
52 } 52 }
53 53
54 application_refresh(app);
55
54 noecho(); 56 noecho();
55 57
56 keypad(app->window, TRUE); 58 keypad(app->window, TRUE);
57 wtimeout(app->window, 10); 59 wtimeout(app->window, 10);
58} 60}
59 61
62void
63application_refresh(MESSENGER_Application *app)
64{
65 if (app->ui.logo) delwin(app->ui.logo);
66 if (app->ui.main) delwin(app->ui.main);
67 if (app->ui.left) delwin(app->ui.left);
68 if (app->ui.right) delwin(app->ui.right);
69 if (app->ui.input) delwin(app->ui.input);
70
71 memset(&(app->ui), 0, sizeof(app->ui));
72
73 curs_set(0);
74}
75
60static void 76static void
61run (void *cls, 77run (void *cls,
62 UNUSED char* const* args, 78 UNUSED char* const* args,
diff --git a/src/application.h b/src/application.h
index 1ad0c11..75bf336 100644
--- a/src/application.h
+++ b/src/application.h
@@ -43,6 +43,14 @@ typedef struct MESSENGER_Application
43 int status; 43 int status;
44 WINDOW *window; 44 WINDOW *window;
45 45
46 struct {
47 WINDOW *logo;
48 WINDOW *main;
49 WINDOW *left;
50 WINDOW *right;
51 WINDOW *input;
52 } ui;
53
46 MESSENGER_Chat chat; 54 MESSENGER_Chat chat;
47 55
48 UI_ACCOUNTS_Handle accounts; 56 UI_ACCOUNTS_Handle accounts;
@@ -59,6 +67,9 @@ application_init(MESSENGER_Application *app,
59 char **argv); 67 char **argv);
60 68
61void 69void
70application_refresh(MESSENGER_Application *app);
71
72void
62application_run(MESSENGER_Application *app); 73application_run(MESSENGER_Application *app);
63 74
64int 75int
diff --git a/src/chat.c b/src/chat.c
index fac192e..b7ed4fa 100644
--- a/src/chat.c
+++ b/src/chat.c
@@ -25,32 +25,26 @@
25#include "chat.h" 25#include "chat.h"
26 26
27#include "application.h" 27#include "application.h"
28#include "util.h"
28 29
29static void 30static void
30_chat_refresh(MESSENGER_Application *app) 31_chat_refresh(MESSENGER_Application *app)
31{ 32{
32 const struct GNUNET_CHAT_Account *account = GNUNET_CHAT_get_connected(
33 app->chat.handle
34 );
35
36 application_clear(app); 33 application_clear(app);
37 34 chat_update_layout(&(app->chat), app);
38 if (!account)
39 app->accounts.window = app->window;
40 else if (app->chat.context)
41 {
42 if (app->chat.show_members)
43 app->current.members.window = app->window;
44 else
45 app->current.messages.window = app->window;
46 }
47 else
48 app->chats.window = app->window;
49 35
50 accounts_print(&(app->accounts), app); 36 accounts_print(&(app->accounts), app);
51 chats_print(&(app->chats), app); 37 chats_print(&(app->chats), app);
52 members_print(&(app->current.members)); 38 members_print(&(app->current.members));
53 messages_print(&(app->current.messages)); 39 messages_print(&(app->current.messages));
40
41 if (!app->ui.logo)
42 return;
43
44 werase(app->ui.logo);
45 wmove(app->ui.logo, 0, 0);
46
47 util_print_logo(app->ui.logo);
54} 48}
55 49
56static bool 50static bool
@@ -160,6 +154,180 @@ chat_stop(MESSENGER_Chat *chat)
160} 154}
161 155
162void 156void
157_chat_update_layout_accounts(struct MESSENGER_Application *app)
158{
159 int rows, cols;
160 getmaxyx(app->window, rows, cols);
161
162 if (rows >= UTIL_LOGO_ROWS + UI_ACCOUNTS_ROWS_MIN)
163 {
164 const int offset = UTIL_LOGO_ROWS + 1;
165
166 app->ui.logo = subwin(app->window, UTIL_LOGO_ROWS, cols, 0, 0);
167 app->ui.main = subwin(app->window, rows - offset, cols, offset, 0);
168
169 wmove(app->window, UTIL_LOGO_ROWS, 0);
170 whline(app->window, ACS_HLINE, cols);
171 }
172 else
173 app->ui.main = subwin(app->window, rows, cols, 0, 0);
174
175 app->accounts.window = app->ui.main;
176}
177
178void
179_chat_update_layout_chats(struct MESSENGER_Application *app)
180{
181 int rows, cols;
182 getmaxyx(app->window, rows, cols);
183
184 int min_rows = UI_CHATS_ROWS_MIN;
185 int offset_x = 0;
186 int offset_y = 0;
187
188 if (cols >= UI_ACCOUNTS_COLS_MIN + UI_CHATS_COLS_MIN)
189 {
190 offset_x = UI_ACCOUNTS_COLS_MIN + 1;
191
192 if (UI_ACCOUNTS_ROWS_MIN > min_rows) min_rows = UI_ACCOUNTS_ROWS_MIN;
193 }
194
195 if (rows >= UTIL_LOGO_ROWS + min_rows)
196 {
197 offset_y = UTIL_LOGO_ROWS + 1;
198
199 app->ui.logo = subwin(app->window, UTIL_LOGO_ROWS, cols, 0, 0);
200
201 wmove(app->window, UTIL_LOGO_ROWS, 0);
202 whline(app->window, ACS_HLINE, cols);
203 }
204
205 if (offset_x > 0)
206 {
207 app->ui.left = subwin(
208 app->window,
209 rows - offset_y,
210 UI_ACCOUNTS_COLS_MIN,
211 offset_y,
212 0
213 );
214
215 wmove(app->window, offset_y > 0? offset_y : 0, UI_ACCOUNTS_COLS_MIN);
216 wvline(app->window, ACS_VLINE, rows - offset_y);
217
218 if (offset_y > 0)
219 {
220 wmove(app->window, offset_y - 1, UI_ACCOUNTS_COLS_MIN);
221 waddch(app->window, ACS_TTEE);
222 }
223 }
224
225 app->ui.main = subwin(
226 app->window,
227 rows - offset_y,
228 cols - offset_x,
229 offset_y,
230 offset_x
231 );
232
233 app->accounts.window = app->ui.left;
234 app->chats.window = app->ui.main;
235}
236
237void
238_chat_update_layout_messages(struct MESSENGER_Application *app)
239{
240 int rows, cols;
241 getmaxyx(app->window, rows, cols);
242
243 const int cols_min_left = (UTIL_LOGO_COLS > UI_CHATS_COLS_MIN?
244 UTIL_LOGO_COLS : UI_CHATS_COLS_MIN
245 );
246
247 int offset_x = 0;
248
249 if (cols >= cols_min_left + UI_MESSAGES_COLS_MIN)
250 offset_x = cols_min_left + 1;
251 else
252 goto skip_left_split;
253
254 if (rows >= UTIL_LOGO_ROWS + UI_CHATS_ROWS_MIN)
255 {
256 const int offset = UTIL_LOGO_ROWS + 1;
257
258 app->ui.logo = subwin(app->window, UTIL_LOGO_ROWS, cols_min_left, 0, 0);
259 app->ui.left = subwin(app->window, rows - offset, cols_min_left, offset, 0);
260
261 wmove(app->window, UTIL_LOGO_ROWS, 0);
262 whline(app->window, ACS_HLINE, cols_min_left);
263 }
264 else
265 app->ui.left = subwin(app->window, rows, cols_min_left, 0, 0);
266
267 int cut_x = 0;
268
269 if (cols >= cols_min_left + UI_MESSAGES_COLS_MIN + UI_MEMBERS_COLS_MIN)
270 {
271 cut_x = UI_MEMBERS_COLS_MIN + 1;
272
273 app->ui.right = subwin(
274 app->window,
275 rows,
276 UI_MEMBERS_COLS_MIN,
277 0,
278 cols - UI_MEMBERS_COLS_MIN
279 );
280
281 wmove(app->window, 0, cols - cut_x);
282 wvline(app->window, ACS_VLINE, rows);
283 }
284
285 wmove(app->window, 0, cols_min_left);
286 wvline(app->window, ACS_VLINE, rows);
287
288skip_left_split:
289 app->ui.main = subwin(
290 app->window,
291 rows,
292 cols - offset_x - cut_x,
293 0,
294 offset_x
295 );
296
297 app->chats.window = app->ui.left;
298
299 if (app->ui.right)
300 {
301 app->current.members.window = app->ui.right;
302 app->current.messages.window = app->ui.main;
303 return;
304 }
305
306 if (app->chat.show_members)
307 app->current.members.window = app->ui.main;
308 else
309 app->current.messages.window = app->ui.main;
310}
311
312void
313chat_update_layout(MESSENGER_Chat *chat,
314 struct MESSENGER_Application *app)
315{
316 const struct GNUNET_CHAT_Account *account = GNUNET_CHAT_get_connected(
317 chat->handle
318 );
319
320 application_refresh(app);
321
322 if (!account)
323 _chat_update_layout_accounts(app);
324 else if (app->chat.context)
325 _chat_update_layout_messages(app);
326 else
327 _chat_update_layout_chats(app);
328}
329
330void
163chat_process_message(UNUSED MESSENGER_Chat *chat, 331chat_process_message(UNUSED MESSENGER_Chat *chat,
164 struct GNUNET_CHAT_Context *context, 332 struct GNUNET_CHAT_Context *context,
165 const struct GNUNET_CHAT_Message *message) 333 const struct GNUNET_CHAT_Message *message)
diff --git a/src/chat.h b/src/chat.h
index 8ce5f3e..5422e3b 100644
--- a/src/chat.h
+++ b/src/chat.h
@@ -51,6 +51,10 @@ void
51chat_stop(MESSENGER_Chat *chat); 51chat_stop(MESSENGER_Chat *chat);
52 52
53void 53void
54chat_update_layout(MESSENGER_Chat *chat,
55 struct MESSENGER_Application *app);
56
57void
54chat_process_message(MESSENGER_Chat *chat, 58chat_process_message(MESSENGER_Chat *chat,
55 struct GNUNET_CHAT_Context *context, 59 struct GNUNET_CHAT_Context *context,
56 const struct GNUNET_CHAT_Message *message); 60 const struct GNUNET_CHAT_Message *message);
diff --git a/src/ui/account_create_dialog.c b/src/ui/account_create_dialog.c
index b283092..5472bc7 100644
--- a/src/ui/account_create_dialog.c
+++ b/src/ui/account_create_dialog.c
@@ -114,9 +114,14 @@ account_create_dialog_print(UI_ACCOUNT_CREATE_DIALOG_Handle *create_dialog,
114 if (!(create_dialog->window)) 114 if (!(create_dialog->window))
115 return; 115 return;
116 116
117 werase(create_dialog->window); 117 WINDOW *window = *(create_dialog->window);
118 wmove(create_dialog->window, 0, 0);
119 118
120 wprintw(create_dialog->window, "%s", create_dialog->name); 119 werase(window);
121 wmove(create_dialog->window, 0, create_dialog->name_pos); 120 wmove(window, 0, 0);
121
122 wprintw(window, "%s", create_dialog->name);
123 wmove(window, 0, create_dialog->name_pos);
124
125 wcursyncup(window);
126 curs_set(1);
122} 127}
diff --git a/src/ui/account_create_dialog.h b/src/ui/account_create_dialog.h
index 69dbb1c..d42fef2 100644
--- a/src/ui/account_create_dialog.h
+++ b/src/ui/account_create_dialog.h
@@ -32,7 +32,7 @@ struct MESSENGER_Application;
32 32
33typedef struct UI_ACCOUNT_CREATE_DIALOG_Handle 33typedef struct UI_ACCOUNT_CREATE_DIALOG_Handle
34{ 34{
35 WINDOW *window; 35 WINDOW **window;
36 36
37 char name [256]; 37 char name [256];
38 int name_len; 38 int name_len;
diff --git a/src/ui/accounts.c b/src/ui/accounts.c
index ced1d68..4936c82 100644
--- a/src/ui/accounts.c
+++ b/src/ui/accounts.c
@@ -88,7 +88,7 @@ accounts_event(UI_ACCOUNTS_Handle *accounts,
88 if (accounts->selected) 88 if (accounts->selected)
89 GNUNET_CHAT_connect(app->chat.handle, accounts->selected); 89 GNUNET_CHAT_connect(app->chat.handle, accounts->selected);
90 else 90 else
91 accounts->create_dialog.window = accounts->window; 91 accounts->create_dialog.window = &(accounts->window);
92 break; 92 break;
93 } 93 }
94 default: 94 default:
@@ -103,7 +103,7 @@ accounts_event(UI_ACCOUNTS_Handle *accounts,
103 if (!(accounts->window)) 103 if (!(accounts->window))
104 return; 104 return;
105 105
106 const int height = getmaxy(accounts->window) - getbegy(accounts->window); 106 const int height = getmaxy(accounts->window);
107 const int y = accounts->line_selected - accounts->line_offset; 107 const int y = accounts->line_selected - accounts->line_offset;
108 108
109 if (y < 0) 109 if (y < 0)
@@ -130,7 +130,7 @@ _accounts_print_entry(UI_ACCOUNTS_Handle *accounts,
130 if (y < 0) 130 if (y < 0)
131 return GNUNET_YES; 131 return GNUNET_YES;
132 132
133 const int height = getmaxy(accounts->window) - getbegy(accounts->window); 133 const int height = getmaxy(accounts->window);
134 134
135 if (y >= height) 135 if (y >= height)
136 return GNUNET_NO; 136 return GNUNET_NO;
diff --git a/src/ui/accounts.h b/src/ui/accounts.h
index 2ca55b5..fe0e1b1 100644
--- a/src/ui/accounts.h
+++ b/src/ui/accounts.h
@@ -49,6 +49,9 @@ typedef struct UI_ACCOUNTS_Handle
49 UI_ACCOUNT_CREATE_DIALOG_Handle create_dialog; 49 UI_ACCOUNT_CREATE_DIALOG_Handle create_dialog;
50} UI_ACCOUNTS_Handle; 50} UI_ACCOUNTS_Handle;
51 51
52#define UI_ACCOUNTS_ROWS_MIN 5
53#define UI_ACCOUNTS_COLS_MIN 30
54
52void 55void
53accounts_event(UI_ACCOUNTS_Handle *accounts, 56accounts_event(UI_ACCOUNTS_Handle *accounts,
54 struct MESSENGER_Application *app, 57 struct MESSENGER_Application *app,
diff --git a/src/ui/chat_open_dialog.c b/src/ui/chat_open_dialog.c
index 180d7be..701b8e5 100644
--- a/src/ui/chat_open_dialog.c
+++ b/src/ui/chat_open_dialog.c
@@ -114,9 +114,14 @@ chat_open_dialog_print(UI_CHAT_OPEN_DIALOG_Handle *open_dialog,
114 if (!(open_dialog->window)) 114 if (!(open_dialog->window))
115 return; 115 return;
116 116
117 werase(open_dialog->window); 117 WINDOW *window = *(open_dialog->window);
118 wmove(open_dialog->window, 0, 0);
119 118
120 wprintw(open_dialog->window, "%s", open_dialog->topic); 119 werase(window);
121 wmove(open_dialog->window, 0, open_dialog->topic_pos); 120 wmove(window, 0, 0);
121
122 wprintw(window, "%s", open_dialog->topic);
123 wmove(window, 0, open_dialog->topic_pos);
124
125 wcursyncup(window);
126 curs_set(1);
122} 127}
diff --git a/src/ui/chat_open_dialog.h b/src/ui/chat_open_dialog.h
index 2adf465..0367abc 100644
--- a/src/ui/chat_open_dialog.h
+++ b/src/ui/chat_open_dialog.h
@@ -32,7 +32,7 @@ struct MESSENGER_Application;
32 32
33typedef struct UI_CHAT_OPEN_DIALOG_Handle 33typedef struct UI_CHAT_OPEN_DIALOG_Handle
34{ 34{
35 WINDOW *window; 35 WINDOW **window;
36 36
37 char topic [256]; 37 char topic [256];
38 int topic_len; 38 int topic_len;
diff --git a/src/ui/chats.c b/src/ui/chats.c
index f727a37..ddeb5d4 100644
--- a/src/ui/chats.c
+++ b/src/ui/chats.c
@@ -141,7 +141,7 @@ chats_event(UI_CHATS_Handle *chats,
141 app->chat.context = chats->selected; 141 app->chat.context = chats->selected;
142 } 142 }
143 else 143 else
144 chats->open_dialog.window = chats->window; 144 chats->open_dialog.window = &(chats->window);
145 break; 145 break;
146 } 146 }
147 default: 147 default:
@@ -156,7 +156,7 @@ chats_event(UI_CHATS_Handle *chats,
156 if (!(chats->window)) 156 if (!(chats->window))
157 return; 157 return;
158 158
159 const int height = getmaxy(chats->window) - getbegy(chats->window); 159 const int height = getmaxy(chats->window);
160 const int y = chats->line_selected - chats->line_offset; 160 const int y = chats->line_selected - chats->line_offset;
161 161
162 if (y < 0) 162 if (y < 0)
@@ -184,7 +184,7 @@ _chats_print_entry(UI_CHATS_Handle *chats,
184 if (y < 0) 184 if (y < 0)
185 return GNUNET_YES; 185 return GNUNET_YES;
186 186
187 const int height = getmaxy(chats->window) - getbegy(chats->window); 187 const int height = getmaxy(chats->window);
188 188
189 if (y >= height) 189 if (y >= height)
190 return GNUNET_NO; 190 return GNUNET_NO;
diff --git a/src/ui/chats.h b/src/ui/chats.h
index 85a84eb..339cb9c 100644
--- a/src/ui/chats.h
+++ b/src/ui/chats.h
@@ -49,6 +49,9 @@ typedef struct UI_CHATS_Handle
49 UI_CHAT_OPEN_DIALOG_Handle open_dialog; 49 UI_CHAT_OPEN_DIALOG_Handle open_dialog;
50} UI_CHATS_Handle; 50} UI_CHATS_Handle;
51 51
52#define UI_CHATS_ROWS_MIN 8
53#define UI_CHATS_COLS_MIN 30
54
52void 55void
53chats_event(UI_CHATS_Handle *chats, 56chats_event(UI_CHATS_Handle *chats,
54 struct MESSENGER_Application *app, 57 struct MESSENGER_Application *app,
diff --git a/src/ui/members.c b/src/ui/members.c
index 710c0d6..509e03b 100644
--- a/src/ui/members.c
+++ b/src/ui/members.c
@@ -86,7 +86,7 @@ members_event(UI_MEMBERS_Handle *members,
86 if (!(members->window)) 86 if (!(members->window))
87 return; 87 return;
88 88
89 const int height = getmaxy(members->window) - getbegy(members->window); 89 const int height = getmaxy(members->window);
90 const int y = members->line_selected - members->line_offset; 90 const int y = members->line_selected - members->line_offset;
91 91
92 if (y < 0) 92 if (y < 0)
@@ -112,7 +112,7 @@ _members_iterate_print(UI_MEMBERS_Handle *members,
112 if (y < 0) 112 if (y < 0)
113 return; 113 return;
114 114
115 const int height = getmaxy(members->window) - getbegy(members->window); 115 const int height = getmaxy(members->window);
116 116
117 if (y >= height) 117 if (y >= height)
118 return; 118 return;
diff --git a/src/ui/members.h b/src/ui/members.h
index 4f7c50d..8e70ca4 100644
--- a/src/ui/members.h
+++ b/src/ui/members.h
@@ -56,6 +56,8 @@ typedef struct UI_MEMBERS_Handle
56 const struct GNUNET_CHAT_Contact *selected; 56 const struct GNUNET_CHAT_Contact *selected;
57} UI_MEMBERS_Handle; 57} UI_MEMBERS_Handle;
58 58
59#define UI_MEMBERS_COLS_MIN 30
60
59void 61void
60members_event(UI_MEMBERS_Handle *members, 62members_event(UI_MEMBERS_Handle *members,
61 struct MESSENGER_Application *app, 63 struct MESSENGER_Application *app,
diff --git a/src/ui/messages.c b/src/ui/messages.c
index 9b0a692..26df838 100644
--- a/src/ui/messages.c
+++ b/src/ui/messages.c
@@ -158,7 +158,7 @@ messages_event(UI_MESSAGES_Handle *messages,
158 if (!(messages->window)) 158 if (!(messages->window))
159 return; 159 return;
160 160
161 const int height = getmaxy(messages->window) - getbegy(messages->window); 161 const int height = getmaxy(messages->window);
162 const int y = messages->line_selected - messages->line_offset; 162 const int y = messages->line_selected - messages->line_offset;
163 163
164 const int line_height = height - 2; 164 const int line_height = height - 2;
@@ -188,7 +188,7 @@ _messages_iterate_print(UI_MESSAGES_Handle *messages,
188 if (y < 0) 188 if (y < 0)
189 return; 189 return;
190 190
191 const int height = getmaxy(messages->window) - getbegy(messages->window); 191 const int height = getmaxy(messages->window);
192 const int line_height = height - 2; 192 const int line_height = height - 2;
193 193
194 if (y >= line_height) 194 if (y >= line_height)
@@ -199,38 +199,49 @@ _messages_iterate_print(UI_MESSAGES_Handle *messages,
199 const char *name = sender? GNUNET_CHAT_contact_get_name(sender) : NULL; 199 const char *name = sender? GNUNET_CHAT_contact_get_name(sender) : NULL;
200 const char *text = GNUNET_CHAT_message_get_text(message); 200 const char *text = GNUNET_CHAT_message_get_text(message);
201 201
202 struct GNUNET_TIME_Absolute timestamp = GNUNET_CHAT_message_get_timestamp( 202 struct GNUNET_TIME_Absolute abs_time = GNUNET_CHAT_message_get_timestamp(
203 message 203 message
204 ); 204 );
205 205
206 struct GNUNET_TIME_Timestamp timestamp = GNUNET_TIME_absolute_to_timestamp(
207 abs_time
208 );
209
210 const time_t s_after_epoch = (
211 GNUNET_TIME_timestamp_to_s(timestamp)
212 );
213
214 struct tm* ts = localtime(&s_after_epoch);
215 char time_buf [255];
216
217 strftime(time_buf, sizeof(time_buf), "%H:%M", ts);
218
206 const int attrs_select = A_BOLD; 219 const int attrs_select = A_BOLD;
207 220
208 if (selected) wattron(messages->window, attrs_select); 221 if (selected) wattron(messages->window, attrs_select);
209 222
210 wmove(messages->window, y, 0); 223 wmove(messages->window, y, 0);
224 wprintw(messages->window, "%s | ", time_buf);
211 225
212 switch (kind) { 226 switch (kind) {
213 case GNUNET_CHAT_KIND_JOIN: 227 case GNUNET_CHAT_KIND_JOIN:
214 wprintw( 228 wprintw(
215 messages->window, 229 messages->window,
216 "%s | %s joins the room.", 230 "%s joins the room.",
217 GNUNET_TIME_absolute2s(timestamp),
218 name 231 name
219 ); 232 );
220 break; 233 break;
221 case GNUNET_CHAT_KIND_LEAVE: 234 case GNUNET_CHAT_KIND_LEAVE:
222 wprintw( 235 wprintw(
223 messages->window, 236 messages->window,
224 "%s | %s leaves the room.", 237 "%s leaves the room.",
225 GNUNET_TIME_absolute2s(timestamp),
226 name 238 name
227 ); 239 );
228 break; 240 break;
229 case GNUNET_CHAT_KIND_INVITATION: 241 case GNUNET_CHAT_KIND_INVITATION:
230 wprintw( 242 wprintw(
231 messages->window, 243 messages->window,
232 "%s | %s invites you to a room.", 244 "%s invites you to a room.",
233 GNUNET_TIME_absolute2s(timestamp),
234 name 245 name
235 ); 246 );
236 break; 247 break;
@@ -238,8 +249,7 @@ _messages_iterate_print(UI_MESSAGES_Handle *messages,
238 case GNUNET_CHAT_KIND_FILE: 249 case GNUNET_CHAT_KIND_FILE:
239 wprintw( 250 wprintw(
240 messages->window, 251 messages->window,
241 "%s | %s: %s", 252 "%s: %s",
242 GNUNET_TIME_absolute2s(timestamp),
243 name, 253 name,
244 text 254 text
245 ); 255 );
@@ -247,8 +257,7 @@ _messages_iterate_print(UI_MESSAGES_Handle *messages,
247 default: 257 default:
248 wprintw( 258 wprintw(
249 messages->window, 259 messages->window,
250 "%s | [%d] %s: %s", 260 "[%d] %s: %s",
251 GNUNET_TIME_absolute2s(timestamp),
252 (int) kind, 261 (int) kind,
253 name, 262 name,
254 text 263 text
@@ -282,8 +291,8 @@ messages_print(UI_MESSAGES_Handle *messages)
282 291
283 const bool selected = (count == messages->line_selected); 292 const bool selected = (count == messages->line_selected);
284 293
285 const int width = getmaxx(messages->window) - getbegx(messages->window); 294 const int width = getmaxx(messages->window);
286 const int height = getmaxy(messages->window) - getbegy(messages->window); 295 const int height = getmaxy(messages->window);
287 const int line_height = height - 2; 296 const int line_height = height - 2;
288 297
289 wmove(messages->window, line_height, 0); 298 wmove(messages->window, line_height, 0);
@@ -299,6 +308,12 @@ messages_print(UI_MESSAGES_Handle *messages)
299 if (selected) wattroff(messages->window, attrs_select); 308 if (selected) wattroff(messages->window, attrs_select);
300 309
301 wmove(messages->window, height - 1, messages->text_pos); 310 wmove(messages->window, height - 1, messages->text_pos);
311
312 if (selected)
313 {
314 wcursyncup(messages->window);
315 curs_set(1);
316 }
302} 317}
303 318
304void 319void
@@ -355,7 +370,7 @@ messages_add(UI_MESSAGES_Handle *messages,
355 break; 370 break;
356 } 371 }
357 372
358 const int height = getmaxy(messages->window) - getbegy(messages->window); 373 const int height = getmaxy(messages->window);
359 const int line_height = height - 2; 374 const int line_height = height - 2;
360 375
361 int count = 0; 376 int count = 0;
diff --git a/src/ui/messages.h b/src/ui/messages.h
index 06de97f..166941a 100644
--- a/src/ui/messages.h
+++ b/src/ui/messages.h
@@ -62,6 +62,8 @@ typedef struct UI_MESSAGES_Handle
62 int text_pos; 62 int text_pos;
63} UI_MESSAGES_Handle; 63} UI_MESSAGES_Handle;
64 64
65#define UI_MESSAGES_COLS_MIN 50
66
65void 67void
66messages_event(UI_MESSAGES_Handle *messages, 68messages_event(UI_MESSAGES_Handle *messages,
67 struct MESSENGER_Application *app, 69 struct MESSENGER_Application *app,
diff --git a/src/util.c b/src/util.c
index d32eb6e..6647fef 100644
--- a/src/util.c
+++ b/src/util.c
@@ -30,14 +30,14 @@ util_print_logo(WINDOW *window)
30 int x = getcurx(window); 30 int x = getcurx(window);
31 int y = getcury(window); 31 int y = getcury(window);
32 32
33 wmove(window, x, y++); wprintw(window, " "); 33 wmove(window, y++, x); wprintw(window, " ");
34 wmove(window, x, y++); wprintw(window, " o/ \\o "); 34 wmove(window, y++, x); wprintw(window, " o/ \\o ");
35 wmove(window, x, y++); wprintw(window, " ooo oo "); 35 wmove(window, y++, x); wprintw(window, " ooo oo ");
36 wmove(window, x, y++); wprintw(window, " \\oooo\\ /oooo/ "); 36 wmove(window, y++, x); wprintw(window, " \\oooo\\ /oooo/ ");
37 wmove(window, x, y++); wprintw(window, " oo ooo "); 37 wmove(window, y++, x); wprintw(window, " oo ooo ");
38 wmove(window, x, y++); wprintw(window, " oo ooo "); 38 wmove(window, y++, x); wprintw(window, " oo ooo ");
39 wmove(window, x, y++); wprintw(window, " ooooooo "); 39 wmove(window, y++, x); wprintw(window, " ooooooo ");
40 wmove(window, x, y++); wprintw(window, " \\oooo/ "); 40 wmove(window, y++, x); wprintw(window, " \\oooo/ ");
41 wmove(window, x, y++); wprintw(window, " oooo "); 41 wmove(window, y++, x); wprintw(window, " oooo ");
42 wmove(window, x, y++); wprintw(window, " "); 42 wmove(window, y++, x); wprintw(window, " ");
43} 43}
diff --git a/src/util.h b/src/util.h
index 561f3ac..367eec9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -31,6 +31,9 @@
31 31
32#define UNUSED __attribute__((unused)) 32#define UNUSED __attribute__((unused))
33 33
34#define UTIL_LOGO_ROWS 10
35#define UTIL_LOGO_COLS 28
36
34void 37void
35util_print_logo(WINDOW *window); 38util_print_logo(WINDOW *window);
36 39