1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-06-26 20:57:48 +02:00

a small fixes

This commit is contained in:
Jfreegman 2013-11-26 17:39:11 -05:00
parent 0a24137a58
commit 8de666a349
6 changed files with 20 additions and 17 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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) {