diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 6dd485f2..17736daf 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -50,7 +50,7 @@ buffer_create(void) return new_buff; } -int +unsigned int buffer_size(ProfBuff buffer) { return g_slist_length(buffer->entries); @@ -114,7 +114,7 @@ buffer_remove_entry_by_id(ProfBuff buffer, const char* const id) } void -buffer_remove_entry(ProfBuff buffer, int entry) +buffer_remove_entry(ProfBuff buffer, unsigned int entry) { GSList* node = g_slist_nth(buffer->entries, entry); ProfBuffEntry* e = node->data; @@ -142,7 +142,7 @@ buffer_mark_received(ProfBuff buffer, const char* const id) } ProfBuffEntry* -buffer_get_entry(ProfBuff buffer, int entry) +buffer_get_entry(ProfBuff buffer, unsigned int entry) { GSList* node = g_slist_nth(buffer->entries, entry); return node->data; diff --git a/src/ui/buffer.h b/src/ui/buffer.h index 6062d207..61840621 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -49,9 +49,9 @@ void buffer_free(ProfBuff buffer); void buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos); void buffer_prepend(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos); void buffer_remove_entry_by_id(ProfBuff buffer, const char* const id); -void buffer_remove_entry(ProfBuff buffer, int entry); -int buffer_size(ProfBuff buffer); -ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry); +void buffer_remove_entry(ProfBuff buffer, unsigned int entry); +unsigned int buffer_size(ProfBuff buffer); +ProfBuffEntry* buffer_get_entry(ProfBuff buffer, unsigned int entry); ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char* const id); gboolean buffer_mark_received(ProfBuff buffer, const char* const id); diff --git a/src/ui/window.c b/src/ui/window.c index dba4a728..12816eea 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -637,7 +637,7 @@ win_page_up(ProfWin* window, int scroll_size) iq_mam_request_older(chatwin); } - int buff_size = buffer_size(window->layout->buffer); + unsigned int buff_size = buffer_size(window->layout->buffer); int offset_entry_id = buff_size > 10 ? 10 : buff_size - 1; int offset = buffer_get_entry(window->layout->buffer, offset_entry_id)->y_end_pos; *page_start = offset - page_space; @@ -678,8 +678,8 @@ win_page_down(ProfWin* window, int scroll_size) // Scrolled down after reaching the bottom of the page if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) { - int bf_size = buffer_size(window->layout->buffer); - if (bf_size > 0) { + unsigned int bf_size = buffer_size(window->layout->buffer); + if (bf_size != 0) { ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1); auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time); GDateTime* now = g_date_time_new_now_local(); @@ -1954,10 +1954,10 @@ win_print_trackbar(ProfWin* window) void win_redraw(ProfWin* window) { - int size = buffer_size(window->layout->buffer); + unsigned int size = buffer_size(window->layout->buffer); werase(window->layout->win); - for (int i = 0; i < size; i++) { + for (unsigned int i = 0; i < size; i++) { ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); e->y_start_pos = getcury(window->layout->win); @@ -2185,11 +2185,11 @@ win_handle_command_exec_result_note(ProfWin* window, const char* const type, con void win_insert_last_read_position_marker(ProfWin* window, char* id) { - int size = buffer_size(window->layout->buffer); + unsigned int size = buffer_size(window->layout->buffer); // TODO: this is somewhat costly. We should improve this later. // check if we already have a separator present - for (int i = 0; i < size; i++) { + for (unsigned int i = 0; i < size; i++) { ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); // if yes, don't print a new one