From 8de666a349911c21b69127e7126bcbac26931904 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Tue, 26 Nov 2013 17:39:11 -0500 Subject: [PATCH] a small fixes --- src/chat.c | 5 +++-- src/global_commands.c | 2 +- src/groupchat.c | 12 +++++------- src/groupchat.h | 8 +++++--- src/toxic_windows.h | 1 + src/windows.c | 9 +++++---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/chat.c b/src/chat.c index 37df637..52cfec4 100644 --- a/src/chat.c +++ b/src/chat.c @@ -415,6 +415,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) } wprintw(statusbar->topline, "\n"); + mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x); wrefresh(self->window); } @@ -438,9 +439,9 @@ static void chat_onInit(ToxWindow *self, Tox *m) /* Init subwindows */ ChatContext *ctx = (ChatContext *) self->chatwin; statusbar->topline = subwin(self->window, 2, x, 0, 0); - ctx->history = subwin(self->window, y-3, x, 0, 0); + ctx->history = subwin(self->window, y-CHATBOX_HEIGHT+1, x, 0, 0); scrollok(ctx->history, 1); - ctx->linewin = subwin(self->window, 0, x, y-4, 0); + ctx->linewin = subwin(self->window, CHATBOX_HEIGHT, x, y-CHATBOX_HEIGHT, 0); wprintw(ctx->history, "\n\n"); execute(ctx->history, self, m, "/help", CHAT_COMMAND_MODE); wmove(self->window, y - CURS_Y_OFFSET, 0); diff --git a/src/global_commands.c b/src/global_commands.c index 7a1b5b1..c5bdbe2 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -218,7 +218,7 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) { /* check arguments */ - if (argc != 1) { + if (argc < 1) { wprintw(window, "Invalid syntax.\n"); return; } diff --git a/src/groupchat.c b/src/groupchat.c index 79c453c..624fb33 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -100,9 +100,9 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int nick[TOXIC_MAX_NAME_LENGTH] = '\0'; /* enforce client max name length */ print_time(ctx->history); - wattron(ctx->history, COLOR_PAIR(4)); + wattron(ctx->history, COLOR_PAIR(BLUE)); wprintw(ctx->history, "%s: ", nick); - wattroff(ctx->history, COLOR_PAIR(4)); + wattroff(ctx->history, COLOR_PAIR(BLUE)); if (msg[0] == '>') { wattron(ctx->history, COLOR_PAIR(GREEN)); @@ -120,8 +120,10 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu if (self->num != groupnum) return; + groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum); + /* Temporary */ - if (peernum < 0 || peernum > MAX_GROUP_PEERS) + if (peernum < 0 || groupchats[groupnum].num_peers > MAX_GROUP_PEERS) return; /* get old peer name before updating name list */ @@ -131,8 +133,6 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu if (string_is_empty(oldpeername)) strcpy(oldpeername, (uint8_t *) UNKNOWN_NAME); - groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum); - /* two copies: oldpeer_names will be unsorted and match correct peernums on the next callback */ tox_group_copy_names(m, groupnum, groupchats[groupnum].peer_names, groupchats[groupnum].num_peers); tox_group_copy_names(m, groupnum, groupchats[groupnum].oldpeer_names, groupchats[groupnum].num_peers); @@ -316,8 +316,6 @@ ToxWindow new_group_chat(Tox *m, int groupnum) ret.onInit = &groupchat_onInit; ret.onGroupMessage = &groupchat_onGroupMessage; ret.onGroupNamelistChange = &groupchat_onGroupNamelistChange; - // ret.onNickChange = &groupchat_onNickChange; - // ret.onStatusChange = &groupchat_onStatusChange; // ret.onAction = &groupchat_onAction; snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum); diff --git a/src/groupchat.h b/src/groupchat.h index 3765ebd..8eafd8f 100644 --- a/src/groupchat.h +++ b/src/groupchat.h @@ -3,10 +3,12 @@ */ #define SIDEBAR_WIDTH 16 -#define CHATBOX_HEIGHT 4 -/* Limits # of peers in sidepanel (make this go away) */ -#define MAX_GROUP_PEERS 500 +/* If this limit is reached the chat will still work + but the side panel and channel updates will be frozen. + + TODO: Make this not necessary */ +#define MAX_GROUP_PEERS 1000 typedef struct { int chatwin; diff --git a/src/toxic_windows.h b/src/toxic_windows.h index d988c75..da42966 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -25,6 +25,7 @@ #define TOXIC_MAX_NAME_LENGTH 30 /* Must be <= TOX_MAX_NAME_LENGTH */ #define N_DEFAULT_WINS 2 /* number of permanent default windows */ #define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */ +#define CHATBOX_HEIGHT 4 #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 diff --git a/src/windows.c b/src/windows.c index 0a46300..cbda523 100644 --- a/src/windows.c +++ b/src/windows.c @@ -263,10 +263,11 @@ ToxWindow *init_windows(Tox *mToAssign) return prompt; } +#define TAB_BLINKRATE 30 + static void draw_bar(void) { static int odd = 0; - int blinkrate = 30; attron(COLOR_PAIR(BLUE)); mvhline(LINES - 2, 0, '_', COLS); @@ -290,15 +291,15 @@ static void draw_bar(void) attron(A_BOLD); } - odd = (odd + 1) % blinkrate; + odd = (odd + 1) % TAB_BLINKRATE; - if (windows[i].blink && (odd < (blinkrate / 2))) + if (windows[i].blink && (odd < (TAB_BLINKRATE / 2))) attron(COLOR_PAIR(RED)); clrtoeol(); printw(" [%s]", windows[i].name); - if (windows[i].blink && (odd < (blinkrate / 2))) + if (windows[i].blink && (odd < (TAB_BLINKRATE / 2))) attroff(COLOR_PAIR(RED)); if (windows + i == active_window) {