diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/buffer.c | 15 | ||||
-rw-r--r-- | src/ui/buffer.h | 1 | ||||
-rw-r--r-- | src/ui/inputwin.c | 3 | ||||
-rw-r--r-- | src/ui/window.c | 21 | ||||
-rw-r--r-- | src/ui/window.h | 2 |
5 files changed, 42 insertions, 0 deletions
diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 29eddd89..a86e85ae 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -125,6 +125,21 @@ buffer_yield_entry(ProfBuff buffer, int entry) return node->data; } +ProfBuffEntry* +buffer_yield_entry_by_id(ProfBuff buffer, const char *const id) +{ + GSList *entries = buffer->entries; + while (entries) { + ProfBuffEntry *entry = entries->data; + if (entry->receipt && g_strcmp0(entry->receipt->id, id) == 0) { + return entry; + } + entries = g_slist_next(entries); + } + + return NULL; +} + static void _free_entry(ProfBuffEntry *entry) { diff --git a/src/ui/buffer.h b/src/ui/buffer.h index ce9763ed..50ce0634 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -64,6 +64,7 @@ void buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTim const char *const from, const char *const message, DeliveryReceipt *receipt); int buffer_size(ProfBuff buffer); ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry); +ProfBuffEntry* buffer_yield_entry_by_id(ProfBuff buffer, const char *const id); gboolean buffer_mark_received(ProfBuff buffer, const char *const id); #endif diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index fc1c204d..c94c0a8c 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -42,6 +42,7 @@ #include <wchar.h> #include <sys/time.h> #include <errno.h> +#include <pthread.h> #include <readline/readline.h> #include <readline/history.h> @@ -145,7 +146,9 @@ inp_readline(void) FD_ZERO(&fds); FD_SET(fileno(rl_instream), &fds); errno = 0; + pthread_mutex_unlock(&lock); r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout); + pthread_mutex_lock(&lock); if (r < 0) { if (errno != EINTR) { char *err_msg = strerror(errno); diff --git a/src/ui/window.c b/src/ui/window.c index 1d95d4cb..3a96ca08 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1055,6 +1055,27 @@ win_mark_received(ProfWin *window, const char *const id) } void +win_update_entry_message(ProfWin *window, const char *const id, const char *const message) +{ + ProfBuffEntry *entry = buffer_yield_entry_by_id(window->layout->buffer, id); + if (entry) { + free(entry->message); + entry->message = strdup(message); + win_redraw(window); + } +} + +void +win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme_item) +{ + ProfBuffEntry *entry = buffer_yield_entry_by_id(window->layout->buffer, id); + if (entry) { + entry->theme_item = theme_item; + win_redraw(window); + } +} + +void win_println(ProfWin *window, int pad, const char *const message) { win_print(window, '-', pad, NULL, 0, 0, "", message); diff --git a/src/ui/window.h b/src/ui/window.h index 4923f4ec..f1f740c5 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -70,6 +70,8 @@ int win_occpuants_cols(void); void win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent); void win_sub_newline_lazy(WINDOW *win); void win_mark_received(ProfWin *window, const char *const id); +void win_update_entry_message(ProfWin *window, const char *const id, const char *const message); +void win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme_item); gboolean win_has_active_subwin(ProfWin *window); |