diff --git a/src/groupchat.c b/src/groupchat.c index 40c77b3..64a726c 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -19,7 +19,7 @@ static GroupChat groupchats[MAX_GROUPCHAT_NUM]; static int group_chat_index = 0; -ToxWindow new_groupchat(Tox *m, ToxWindow *prompt, int groupnum); +ToxWindow new_group_chat(Tox *m, ToxWindow *prompt, int groupnum); extern char *DATA_FILE; extern int store_data(Tox *m, char *path); @@ -36,15 +36,15 @@ int get_num_groupchats(void) return -1; } -int init_groupchat_win(ToxWindow *prompt, Tox *m) +int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum) { int i; for (i = 0; i <= group_chat_index; ++i) { if (!groupchats[i].active) { + groupchats[i].chatwin = add_window(m, new_group_chat(m, prompt, groupnum)); groupchats[i].active = true; - groupchats[i].chatwin = add_window(m, new_groupchat(m, prompt, i)); - //set_active_window(groupchats[i].chatwin); + set_active_window(groupchats[i].chatwin); if (i == group_chat_index) ++group_chat_index; @@ -64,7 +64,7 @@ static void close_groupchatwin(Tox *m, int groupnum) int i; for (i = group_chat_index; i > 0; --i) { - if (groupchats[i-1].active) + if (groupchats[i-1].chatwin != -1) break; } @@ -139,25 +139,25 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) if (line[0] == '/') { if (close_win = !strncmp(line, "/close", strlen("/close"))) { set_active_window(0); - int group_num = self->num; + int groupnum = self->num; delwin(ctx->linewin); del_window(self); - close_groupchatwin(m, group_num); + close_groupchatwin(m, groupnum); } //else //execute(self, ctx, statusbar, m, line); } else { /* make sure the string has at least non-space character */ if (!string_is_empty(line)) { - uint8_t selfname[TOX_MAX_NAME_LENGTH]; - tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH); + // uint8_t selfname[TOX_MAX_NAME_LENGTH]; + // tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH); - wattron(ctx->history, COLOR_PAIR(CYAN)); - wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); - wattroff(ctx->history, COLOR_PAIR(CYAN)); - wattron(ctx->history, COLOR_PAIR(GREEN)); - wprintw(ctx->history, "%s: ", selfname); - wattroff(ctx->history, COLOR_PAIR(GREEN)); - wprintw(ctx->history, "%s\n", line); + // wattron(ctx->history, COLOR_PAIR(CYAN)); + // wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); + // wattroff(ctx->history, COLOR_PAIR(CYAN)); + // wattron(ctx->history, COLOR_PAIR(GREEN)); + // wprintw(ctx->history, "%s: ", selfname); + // wattroff(ctx->history, COLOR_PAIR(GREEN)); + // wprintw(ctx->history, "%s\n", line); if (tox_group_message_send(m, self->num, line, strlen(line) + 1) == -1) { wattron(ctx->history, COLOR_PAIR(RED)); @@ -193,14 +193,14 @@ static void groupchat_onInit(ToxWindow *self, Tox *m) int x, y; ChatContext *ctx = (ChatContext *) self->chatwin; getmaxyx(self->window, y, x); - ctx->history = subwin(self->window, y-4, x, 0, 0); + ctx->history = subwin(self->window, y-3, x, 0, 0); scrollok(ctx->history, 1); ctx->linewin = subwin(self->window, 2, x, y-4, 0); // print_help(ctx); wmove(self->window, y - CURS_Y_OFFSET, 0); } -ToxWindow new_groupchat(Tox *m, ToxWindow *prompt, int groupnum) +ToxWindow new_group_chat(Tox *m, ToxWindow *prompt, int groupnum) { ToxWindow ret; memset(&ret, 0, sizeof(ret)); diff --git a/src/groupchat.h b/src/groupchat.h index fe2f42c..c31b5f9 100644 --- a/src/groupchat.h +++ b/src/groupchat.h @@ -2,5 +2,5 @@ * Toxic -- Tox Curses Client */ -int init_groupchat_win(ToxWindow *prompt, Tox *m); +int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum); int get_num_groupchats(void); diff --git a/src/prompt.c b/src/prompt.c index 13c0b82..c470663 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -318,7 +318,7 @@ void cmd_groupchat(ToxWindow *self, Tox *m, int argc, char **argv) return; } - if (init_groupchat_win(self, m) == -1) { + if (init_groupchat_win(self, m, groupnum) == -1) { wprintw(self->window, "Group chat failed to initialize.\n"); tox_del_groupchat(m, groupnum); return; @@ -336,10 +336,13 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv) wprintw(self->window, " connect : Connect to DHT server\n"); wprintw(self->window, " add : Add friend with optional message\n"); + wprintw(self->window, " accept : Accept friend request\n"); wprintw(self->window, " status : Set your status with optional note\n"); wprintw(self->window, " note : Set a personal note\n"); wprintw(self->window, " nick : Set your nickname\n"); - wprintw(self->window, " accept : Accept friend request\n"); + wprintw(self->window, " join : Join a group chat (must be invited)\n"); + wprintw(self->window, " invite : Invite friend f to groupchat g\n"); + wprintw(self->window, " groupchat : Create a group chat\n"); wprintw(self->window, " myid : Print your ID\n"); wprintw(self->window, " quit/exit : Exit Toxic\n"); wprintw(self->window, " help : Print this message again\n"); @@ -402,7 +405,7 @@ void cmd_join(ToxWindow *self, Tox *m, int argc, char **argv) return; } - if (init_groupchat_win(self, m) == -1) { + if (init_groupchat_win(self, m, groupnum) == -1) { wprintw(self->window, "Group chat failed to initialize.\n"); tox_del_groupchat(m, groupnum); return;