mirror of
https://github.com/Tha14/toxic.git
synced 2025-02-17 03:07:24 +01:00
more fixes
This commit is contained in:
parent
063bc7ca86
commit
6e0ac744cb
@ -19,7 +19,7 @@
|
|||||||
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
||||||
static int group_chat_index = 0;
|
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 char *DATA_FILE;
|
||||||
extern int store_data(Tox *m, char *path);
|
extern int store_data(Tox *m, char *path);
|
||||||
@ -36,15 +36,15 @@ int get_num_groupchats(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_groupchat_win(ToxWindow *prompt, Tox *m)
|
int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= group_chat_index; ++i) {
|
for (i = 0; i <= group_chat_index; ++i) {
|
||||||
if (!groupchats[i].active) {
|
if (!groupchats[i].active) {
|
||||||
|
groupchats[i].chatwin = add_window(m, new_group_chat(m, prompt, groupnum));
|
||||||
groupchats[i].active = true;
|
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)
|
if (i == group_chat_index)
|
||||||
++group_chat_index;
|
++group_chat_index;
|
||||||
@ -64,7 +64,7 @@ static void close_groupchatwin(Tox *m, int groupnum)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = group_chat_index; i > 0; --i) {
|
for (i = group_chat_index; i > 0; --i) {
|
||||||
if (groupchats[i-1].active)
|
if (groupchats[i-1].chatwin != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,25 +139,25 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
if (line[0] == '/') {
|
if (line[0] == '/') {
|
||||||
if (close_win = !strncmp(line, "/close", strlen("/close"))) {
|
if (close_win = !strncmp(line, "/close", strlen("/close"))) {
|
||||||
set_active_window(0);
|
set_active_window(0);
|
||||||
int group_num = self->num;
|
int groupnum = self->num;
|
||||||
delwin(ctx->linewin);
|
delwin(ctx->linewin);
|
||||||
del_window(self);
|
del_window(self);
|
||||||
close_groupchatwin(m, group_num);
|
close_groupchatwin(m, groupnum);
|
||||||
} //else
|
} //else
|
||||||
//execute(self, ctx, statusbar, m, line);
|
//execute(self, ctx, statusbar, m, line);
|
||||||
} else {
|
} else {
|
||||||
/* make sure the string has at least non-space character */
|
/* make sure the string has at least non-space character */
|
||||||
if (!string_is_empty(line)) {
|
if (!string_is_empty(line)) {
|
||||||
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
// uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
|
// tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(CYAN));
|
// wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
// wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
// wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wattron(ctx->history, COLOR_PAIR(GREEN));
|
// wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "%s: ", selfname);
|
// wprintw(ctx->history, "%s: ", selfname);
|
||||||
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
// wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "%s\n", line);
|
// wprintw(ctx->history, "%s\n", line);
|
||||||
|
|
||||||
if (tox_group_message_send(m, self->num, line, strlen(line) + 1) == -1) {
|
if (tox_group_message_send(m, self->num, line, strlen(line) + 1) == -1) {
|
||||||
wattron(ctx->history, COLOR_PAIR(RED));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
@ -193,14 +193,14 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
|||||||
int x, y;
|
int x, y;
|
||||||
ChatContext *ctx = (ChatContext *) self->chatwin;
|
ChatContext *ctx = (ChatContext *) self->chatwin;
|
||||||
getmaxyx(self->window, y, x);
|
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);
|
scrollok(ctx->history, 1);
|
||||||
ctx->linewin = subwin(self->window, 2, x, y-4, 0);
|
ctx->linewin = subwin(self->window, 2, x, y-4, 0);
|
||||||
// print_help(ctx);
|
// print_help(ctx);
|
||||||
wmove(self->window, y - CURS_Y_OFFSET, 0);
|
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;
|
ToxWindow ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* 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);
|
int get_num_groupchats(void);
|
||||||
|
@ -318,7 +318,7 @@ void cmd_groupchat(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
return;
|
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");
|
wprintw(self->window, "Group chat failed to initialize.\n");
|
||||||
tox_del_groupchat(m, groupnum);
|
tox_del_groupchat(m, groupnum);
|
||||||
return;
|
return;
|
||||||
@ -336,10 +336,13 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
|
wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
|
||||||
wprintw(self->window, " add <id> <message> : Add friend with optional message\n");
|
wprintw(self->window, " add <id> <message> : Add friend with optional message\n");
|
||||||
|
wprintw(self->window, " accept <n> : Accept friend request\n");
|
||||||
wprintw(self->window, " status <type> <message> : Set your status with optional note\n");
|
wprintw(self->window, " status <type> <message> : Set your status with optional note\n");
|
||||||
wprintw(self->window, " note <message> : Set a personal note\n");
|
wprintw(self->window, " note <message> : Set a personal note\n");
|
||||||
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
||||||
wprintw(self->window, " accept <number> : Accept friend request\n");
|
wprintw(self->window, " join <n> : Join a group chat (must be invited)\n");
|
||||||
|
wprintw(self->window, " invite <f> <g> : 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, " myid : Print your ID\n");
|
||||||
wprintw(self->window, " quit/exit : Exit Toxic\n");
|
wprintw(self->window, " quit/exit : Exit Toxic\n");
|
||||||
wprintw(self->window, " help : Print this message again\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;
|
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");
|
wprintw(self->window, "Group chat failed to initialize.\n");
|
||||||
tox_del_groupchat(m, groupnum);
|
tox_del_groupchat(m, groupnum);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user