From ba7d01d3c1dcf3d44e7e84c3a8e63e7a297b38d5 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 6 Sep 2013 00:56:55 -0400 Subject: [PATCH] bug fix and remove redundant code --- src/chat.c | 12 ++++-------- src/friendlist.c | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/chat.c b/src/chat.c index 2c8a436..03bc2e3 100644 --- a/src/chat.c +++ b/src/chat.c @@ -81,7 +81,6 @@ void chat_onConnectionChange(ToxWindow *self, Tox *m, int num, uint8_t status) StatusBar *statusbar = (StatusBar *) self->s; statusbar->is_online = status == 1 ? true : false; - } static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uint16_t len) @@ -425,9 +424,6 @@ static void chat_onDraw(ToxWindow *self, Tox *m) wmove(statusbar->topline, 0, 0); /* Draw name, status and note in statusbar */ - uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'}; - snprintf(nick, sizeof(nick), "%s", self->name); - if (statusbar->is_online) { char *status_text = "Unknown"; int colour = WHITE; @@ -449,17 +445,17 @@ static void chat_onDraw(ToxWindow *self, Tox *m) break; } wattron(statusbar->topline, A_BOLD); - wprintw(statusbar->topline, "%s", nick); + wprintw(statusbar->topline, " %s ", self->name); wattroff(statusbar->topline, A_BOLD); wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); - wprintw(statusbar->topline, " [%s]", status_text); + wprintw(statusbar->topline, "[%s]", status_text); wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); } else { wattron(statusbar->topline, A_BOLD); - wprintw(statusbar->topline, "%s", nick); + wprintw(statusbar->topline, " %s ", self->name); wattroff(statusbar->topline, A_BOLD); - wprintw(statusbar->topline, " [Offline]"); + wprintw(statusbar->topline, "[Offline]"); } if (statusbar->statusmsg[0]) diff --git a/src/friendlist.c b/src/friendlist.c index c487689..501081a 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -124,7 +124,8 @@ static void select_friend(Tox *m, wint_t key) } } } else if (key == KEY_DOWN) { - while ((n = (n + 1) % num_friends) != num_selected) { + while (++n != num_selected) { + n = n % num_friends; if (friends[n].active) { num_selected = n; return;