mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-27 02:13:28 +01:00
a small fixes
This commit is contained in:
parent
0a24137a58
commit
8de666a349
@ -415,6 +415,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wprintw(statusbar->topline, "\n");
|
wprintw(statusbar->topline, "\n");
|
||||||
|
|
||||||
mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x);
|
mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x);
|
||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
}
|
}
|
||||||
@ -438,9 +439,9 @@ static void chat_onInit(ToxWindow *self, Tox *m)
|
|||||||
/* Init subwindows */
|
/* Init subwindows */
|
||||||
ChatContext *ctx = (ChatContext *) self->chatwin;
|
ChatContext *ctx = (ChatContext *) self->chatwin;
|
||||||
statusbar->topline = subwin(self->window, 2, x, 0, 0);
|
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);
|
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");
|
wprintw(ctx->history, "\n\n");
|
||||||
execute(ctx->history, self, m, "/help", CHAT_COMMAND_MODE);
|
execute(ctx->history, self, m, "/help", CHAT_COMMAND_MODE);
|
||||||
wmove(self->window, y - CURS_Y_OFFSET, 0);
|
wmove(self->window, y - CURS_Y_OFFSET, 0);
|
||||||
|
@ -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])
|
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 1) {
|
if (argc < 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -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 */
|
nick[TOXIC_MAX_NAME_LENGTH] = '\0'; /* enforce client max name length */
|
||||||
|
|
||||||
print_time(ctx->history);
|
print_time(ctx->history);
|
||||||
wattron(ctx->history, COLOR_PAIR(4));
|
wattron(ctx->history, COLOR_PAIR(BLUE));
|
||||||
wprintw(ctx->history, "%s: ", nick);
|
wprintw(ctx->history, "%s: ", nick);
|
||||||
wattroff(ctx->history, COLOR_PAIR(4));
|
wattroff(ctx->history, COLOR_PAIR(BLUE));
|
||||||
|
|
||||||
if (msg[0] == '>') {
|
if (msg[0] == '>') {
|
||||||
wattron(ctx->history, COLOR_PAIR(GREEN));
|
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||||
@ -120,8 +120,10 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
|
|||||||
if (self->num != groupnum)
|
if (self->num != groupnum)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum);
|
||||||
|
|
||||||
/* Temporary */
|
/* Temporary */
|
||||||
if (peernum < 0 || peernum > MAX_GROUP_PEERS)
|
if (peernum < 0 || groupchats[groupnum].num_peers > MAX_GROUP_PEERS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* get old peer name before updating name list */
|
/* 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))
|
if (string_is_empty(oldpeername))
|
||||||
strcpy(oldpeername, (uint8_t *) UNKNOWN_NAME);
|
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 */
|
/* 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].peer_names, groupchats[groupnum].num_peers);
|
||||||
tox_group_copy_names(m, groupnum, groupchats[groupnum].oldpeer_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.onInit = &groupchat_onInit;
|
||||||
ret.onGroupMessage = &groupchat_onGroupMessage;
|
ret.onGroupMessage = &groupchat_onGroupMessage;
|
||||||
ret.onGroupNamelistChange = &groupchat_onGroupNamelistChange;
|
ret.onGroupNamelistChange = &groupchat_onGroupNamelistChange;
|
||||||
// ret.onNickChange = &groupchat_onNickChange;
|
|
||||||
// ret.onStatusChange = &groupchat_onStatusChange;
|
|
||||||
// ret.onAction = &groupchat_onAction;
|
// ret.onAction = &groupchat_onAction;
|
||||||
|
|
||||||
snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum);
|
snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum);
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIDEBAR_WIDTH 16
|
#define SIDEBAR_WIDTH 16
|
||||||
#define CHATBOX_HEIGHT 4
|
|
||||||
|
|
||||||
/* Limits # of peers in sidepanel (make this go away) */
|
/* If this limit is reached the chat will still work
|
||||||
#define MAX_GROUP_PEERS 500
|
but the side panel and channel updates will be frozen.
|
||||||
|
|
||||||
|
TODO: Make this not necessary */
|
||||||
|
#define MAX_GROUP_PEERS 1000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int chatwin;
|
int chatwin;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define TOXIC_MAX_NAME_LENGTH 30 /* Must be <= TOX_MAX_NAME_LENGTH */
|
#define TOXIC_MAX_NAME_LENGTH 30 /* Must be <= TOX_MAX_NAME_LENGTH */
|
||||||
#define N_DEFAULT_WINS 2 /* number of permanent default windows */
|
#define N_DEFAULT_WINS 2 /* number of permanent default windows */
|
||||||
#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */
|
#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */
|
||||||
|
#define CHATBOX_HEIGHT 4
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
|
@ -263,10 +263,11 @@ ToxWindow *init_windows(Tox *mToAssign)
|
|||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TAB_BLINKRATE 30
|
||||||
|
|
||||||
static void draw_bar(void)
|
static void draw_bar(void)
|
||||||
{
|
{
|
||||||
static int odd = 0;
|
static int odd = 0;
|
||||||
int blinkrate = 30;
|
|
||||||
|
|
||||||
attron(COLOR_PAIR(BLUE));
|
attron(COLOR_PAIR(BLUE));
|
||||||
mvhline(LINES - 2, 0, '_', COLS);
|
mvhline(LINES - 2, 0, '_', COLS);
|
||||||
@ -290,15 +291,15 @@ static void draw_bar(void)
|
|||||||
attron(A_BOLD);
|
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));
|
attron(COLOR_PAIR(RED));
|
||||||
|
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
printw(" [%s]", windows[i].name);
|
printw(" [%s]", windows[i].name);
|
||||||
|
|
||||||
if (windows[i].blink && (odd < (blinkrate / 2)))
|
if (windows[i].blink && (odd < (TAB_BLINKRATE / 2)))
|
||||||
attroff(COLOR_PAIR(RED));
|
attroff(COLOR_PAIR(RED));
|
||||||
|
|
||||||
if (windows + i == active_window) {
|
if (windows + i == active_window) {
|
||||||
|
Loading…
Reference in New Issue
Block a user