1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-06-29 14:27:45 +02:00

a couple bug fixes

This commit is contained in:
Jfreegman 2013-11-27 01:54:22 -05:00
parent 5ad4bca7a9
commit eab41ccd3d
4 changed files with 11 additions and 10 deletions

View File

@ -67,7 +67,7 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
if (num_groupchats >= MAX_GROUPCHAT_NUM) { if (num_groupchats >= MAX_GROUPCHAT_NUM) {
wprintw(window, "\nMaximum number of group chats has been reached.\n"); wprintw(window, "Maximum number of group chats has been reached.\n");
return; return;
} }

View File

@ -153,7 +153,7 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int num, uint8_t *
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num)); friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
} }
static void select_friend(Tox *m, wint_t key) static void select_friend(ToxWindow *self, Tox *m, wint_t key)
{ {
if (key == KEY_UP) { if (key == KEY_UP) {
if (--num_selected < 0) if (--num_selected < 0)
@ -204,7 +204,7 @@ static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key)
} else if (key == 0x107 || key == 0x8 || key == 0x7f) { } else if (key == 0x107 || key == 0x8 || key == 0x7f) {
delete_friend(m, self, f, key); delete_friend(m, self, f, key);
} else { } else {
select_friend(m, key); select_friend(self, m, key);
} }
} }
@ -228,7 +228,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
int i; int i;
for (i = 0; i < num_friends; ++i) { for (i = 0; i < num_friends && i < y-3; ++i) {
int f = friendlist_index[i]; int f = friendlist_index[i];
bool f_selected = false; bool f_selected = false;

View File

@ -178,7 +178,7 @@ void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
if (num_groupchats >= MAX_GROUPCHAT_NUM) { if (num_groupchats >= MAX_GROUPCHAT_NUM) {
wprintw(window, "\nMaximum number of group chats has been reached.\n"); wprintw(window, "Maximum number of group chats has been reached.\n");
return; return;
} }

View File

@ -33,8 +33,8 @@ int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum)
groupchats[i].chatwin = add_window(m, new_group_chat(m, groupnum)); groupchats[i].chatwin = add_window(m, new_group_chat(m, groupnum));
groupchats[i].active = true; groupchats[i].active = true;
groupchats[i].num_peers = 0; groupchats[i].num_peers = 0;
groupchats[i].peer_names = malloc(sizeof(uint8_t *) * TOX_MAX_NAME_LENGTH); groupchats[i].peer_names = malloc(sizeof(uint8_t) * TOX_MAX_NAME_LENGTH);
groupchats[i].oldpeer_names = malloc(sizeof(uint8_t *) * TOX_MAX_NAME_LENGTH); groupchats[i].oldpeer_names = malloc(sizeof(uint8_t) * TOX_MAX_NAME_LENGTH);
memset(groupchats[i].peer_names, 0, sizeof(groupchats[i].peer_names)); memset(groupchats[i].peer_names, 0, sizeof(groupchats[i].peer_names));
memset(groupchats[i].oldpeer_names, 0, sizeof(groupchats[i].oldpeer_names)); memset(groupchats[i].oldpeer_names, 0, sizeof(groupchats[i].oldpeer_names));
@ -131,8 +131,8 @@ static void copy_peernames(int gnum, int npeers, uint8_t tmp_peerlist[][TOX_MAX_
int N = TOX_MAX_NAME_LENGTH; int N = TOX_MAX_NAME_LENGTH;
groupchats[gnum].peer_names = malloc(sizeof(uint8_t *) * npeers * N); groupchats[gnum].peer_names = malloc(sizeof(uint8_t) * npeers * N);
groupchats[gnum].oldpeer_names = malloc(sizeof(uint8_t *) * npeers * N); groupchats[gnum].oldpeer_names = malloc(sizeof(uint8_t) * npeers * N);
if (groupchats[gnum].peer_names == NULL || groupchats[gnum].oldpeer_names == NULL) { if (groupchats[gnum].peer_names == NULL || groupchats[gnum].oldpeer_names == NULL) {
endwin(); endwin();
@ -307,9 +307,10 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
int num_peers = groupchats[self->num].num_peers; int num_peers = groupchats[self->num].num_peers;
int N = TOX_MAX_NAME_LENGTH; int N = TOX_MAX_NAME_LENGTH;
int maxlines = y - CHATBOX_HEIGHT;
int i; int i;
for (i = 0; i < num_peers; ++i) { for (i = 0; i < num_peers && i < maxlines; ++i) {
wmove(ctx->sidebar, i, 1); wmove(ctx->sidebar, i, 1);
groupchats[self->num].peer_names[i * N + SIDEBAR_WIDTH - 2] = '\0'; groupchats[self->num].peer_names[i * N + SIDEBAR_WIDTH - 2] = '\0';
uint8_t *nick = !string_is_empty(&groupchats[self->num].peer_names[i*N])\ uint8_t *nick = !string_is_empty(&groupchats[self->num].peer_names[i*N])\