diff options
Diffstat (limited to 'src/ui/messages.c')
-rw-r--r-- | src/ui/messages.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/ui/messages.c b/src/ui/messages.c index 52da9a7..70d64df 100644 --- a/src/ui/messages.c +++ b/src/ui/messages.c | |||
@@ -156,10 +156,12 @@ messages_event(UI_MESSAGES_Handle *messages, | |||
156 | const int height = getmaxy(messages->window) - getbegy(messages->window); | 156 | const int height = getmaxy(messages->window) - getbegy(messages->window); |
157 | const int y = messages->line_selected - messages->line_offset; | 157 | const int y = messages->line_selected - messages->line_offset; |
158 | 158 | ||
159 | const int line_height = height - 2; | ||
160 | |||
159 | if (y < 0) | 161 | if (y < 0) |
160 | messages->line_offset += y; | 162 | messages->line_offset += y; |
161 | else if (y + 3 >= height) | 163 | else if (y + 1 >= line_height) |
162 | messages->line_offset += y + 3 - height; | 164 | messages->line_offset += y + 1 - line_height; |
163 | 165 | ||
164 | if (messages->line_offset < 0) | 166 | if (messages->line_offset < 0) |
165 | messages->line_offset = 0; | 167 | messages->line_offset = 0; |
@@ -181,9 +183,10 @@ _messages_iterate_print(UI_MESSAGES_Handle *messages, | |||
181 | if (y < 0) | 183 | if (y < 0) |
182 | return; | 184 | return; |
183 | 185 | ||
184 | const int height = getmaxy(messages->window) - getbegy(messages->window) - 2; | 186 | const int height = getmaxy(messages->window) - getbegy(messages->window); |
187 | const int line_height = height - 2; | ||
185 | 188 | ||
186 | if (y >= height) | 189 | if (y >= line_height) |
187 | return; | 190 | return; |
188 | 191 | ||
189 | struct GNUNET_CHAT_Contact *sender = GNUNET_CHAT_message_get_sender(message); | 192 | struct GNUNET_CHAT_Contact *sender = GNUNET_CHAT_message_get_sender(message); |
@@ -276,8 +279,9 @@ messages_print(UI_MESSAGES_Handle *messages) | |||
276 | 279 | ||
277 | const int width = getmaxx(messages->window) - getbegx(messages->window); | 280 | const int width = getmaxx(messages->window) - getbegx(messages->window); |
278 | const int height = getmaxy(messages->window) - getbegy(messages->window); | 281 | const int height = getmaxy(messages->window) - getbegy(messages->window); |
282 | const int line_height = height - 2; | ||
279 | 283 | ||
280 | wmove(messages->window, height - 2, 0); | 284 | wmove(messages->window, line_height, 0); |
281 | whline(messages->window, '-', width); | 285 | whline(messages->window, '-', width); |
282 | 286 | ||
283 | const int attrs_select = A_BOLD; | 287 | const int attrs_select = A_BOLD; |
@@ -333,6 +337,7 @@ _message_compare_timestamps(UNUSED void *cls, | |||
333 | 337 | ||
334 | void | 338 | void |
335 | messages_add(UI_MESSAGES_Handle *messages, | 339 | messages_add(UI_MESSAGES_Handle *messages, |
340 | struct GNUNET_CHAT_Context *context, | ||
336 | const struct GNUNET_CHAT_Message *message) | 341 | const struct GNUNET_CHAT_Message *message) |
337 | { | 342 | { |
338 | enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind(message); | 343 | enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind(message); |
@@ -346,7 +351,28 @@ messages_add(UI_MESSAGES_Handle *messages, | |||
346 | break; | 351 | break; |
347 | } | 352 | } |
348 | 353 | ||
349 | UI_MESSAGES_List *element = GNUNET_new(UI_MESSAGES_List); | 354 | struct GNUNET_CHAT_Contact *sender = GNUNET_CHAT_message_get_sender(message); |
355 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); | ||
356 | |||
357 | if ((GNUNET_CHAT_KIND_JOIN == kind) && | ||
358 | (GNUNET_CHAT_member_get_user_pointer(group, sender))) | ||
359 | { | ||
360 | return; | ||
361 | } | ||
362 | |||
363 | const int height = getmaxy(messages->window) - getbegy(messages->window); | ||
364 | const int line_height = height - 2; | ||
365 | |||
366 | int count = 0; | ||
367 | |||
368 | UI_MESSAGES_List *element = messages->head; | ||
369 | while (element) | ||
370 | { | ||
371 | count++; | ||
372 | element = element->next; | ||
373 | } | ||
374 | |||
375 | element = GNUNET_new(UI_MESSAGES_List); | ||
350 | element->message = message; | 376 | element->message = message; |
351 | 377 | ||
352 | GNUNET_CONTAINER_DLL_insert_sorted( | 378 | GNUNET_CONTAINER_DLL_insert_sorted( |
@@ -357,10 +383,20 @@ messages_add(UI_MESSAGES_Handle *messages, | |||
357 | messages->tail, | 383 | messages->tail, |
358 | element | 384 | element |
359 | ); | 385 | ); |
386 | |||
387 | if (GNUNET_CHAT_KIND_JOIN == kind) | ||
388 | GNUNET_CHAT_member_set_user_pointer(group, sender, element); | ||
389 | |||
390 | if (messages->line_selected >= count) | ||
391 | messages->line_selected = count + 1; | ||
392 | |||
393 | if ((line_height > 0) && (messages->line_offset + line_height >= count)) | ||
394 | messages->line_offset = count + 1 - line_height; | ||
360 | } | 395 | } |
361 | 396 | ||
362 | void | 397 | void |
363 | messages_remove(UI_MESSAGES_Handle *messages, | 398 | messages_remove(UI_MESSAGES_Handle *messages, |
399 | UNUSED struct GNUNET_CHAT_Context *context, | ||
364 | const struct GNUNET_CHAT_Message *message) | 400 | const struct GNUNET_CHAT_Message *message) |
365 | { | 401 | { |
366 | UI_MESSAGES_List *element = messages->head; | 402 | UI_MESSAGES_List *element = messages->head; |