mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 20:13:04 +01:00
add ability to toggle groupchat peerlist with ctrl-b
This commit is contained in:
parent
cc0145d561
commit
e6b18231c0
@ -128,6 +128,42 @@ static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
||||
kill_groupchat_window(self);
|
||||
}
|
||||
|
||||
/* destroys and re-creates groupchat window with or without the peerlist */
|
||||
void redraw_groupchat_win(ToxWindow *self)
|
||||
{
|
||||
ChatContext *ctx = self->chatwin;
|
||||
|
||||
endwin();
|
||||
refresh();
|
||||
clear();
|
||||
|
||||
int x2, y2;
|
||||
getmaxyx(stdscr, y2, x2);
|
||||
y2 -= 2;
|
||||
|
||||
if (ctx->sidebar) {
|
||||
delwin(ctx->sidebar);
|
||||
ctx->sidebar = NULL;
|
||||
}
|
||||
|
||||
delwin(ctx->linewin);
|
||||
delwin(ctx->history);
|
||||
delwin(self->window);
|
||||
|
||||
self->window = newwin(y2, x2, 0, 0);
|
||||
ctx->linewin = subwin(self->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0);
|
||||
|
||||
if (self->show_peerlist) {
|
||||
ctx->history = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, x2 - SIDEBAR_WIDTH - 1, 0, 0);
|
||||
ctx->sidebar = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, SIDEBAR_WIDTH, 0, x2 - SIDEBAR_WIDTH);
|
||||
} else {
|
||||
ctx->history = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0);
|
||||
}
|
||||
|
||||
scrollok(ctx->history, 0);
|
||||
|
||||
}
|
||||
|
||||
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
|
||||
const char *msg, uint16_t len)
|
||||
{
|
||||
@ -458,8 +494,9 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
||||
mvwprintw(ctx->linewin, 1, 0, "%ls", &ctx->line[ctx->start]);
|
||||
|
||||
wclear(ctx->sidebar);
|
||||
|
||||
mvwhline(self->window, y2 - CHATBOX_HEIGHT, 0, ACS_HLINE, x2);
|
||||
|
||||
if (self->show_peerlist) {
|
||||
mvwvline(ctx->sidebar, 0, 0, ACS_VLINE, y2 - CHATBOX_HEIGHT);
|
||||
mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE);
|
||||
|
||||
@ -489,6 +526,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
||||
|
||||
wprintw(ctx->sidebar, "%s\n", tmpnck);
|
||||
}
|
||||
}
|
||||
|
||||
int y, x;
|
||||
getyx(self->window, y, x);
|
||||
@ -560,6 +598,7 @@ ToxWindow new_group_chat(Tox *m, int groupnum)
|
||||
ret.help = help;
|
||||
|
||||
ret.num = groupnum;
|
||||
ret.show_peerlist = true;
|
||||
ret.active_box = -1;
|
||||
|
||||
return ret;
|
||||
|
@ -43,6 +43,10 @@ typedef struct {
|
||||
|
||||
void kill_groupchat_window(ToxWindow *self);
|
||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum);
|
||||
|
||||
/* destroys and re-creates groupchat window with or without the peerlist */
|
||||
void redraw_groupchat_win(ToxWindow *self);
|
||||
|
||||
ToxWindow new_group_chat(Tox *m, int groupnum);
|
||||
|
||||
#endif /* #define GROUPCHAT_H */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "toxic_strings.h"
|
||||
#include "line_info.h"
|
||||
#include "notify.h"
|
||||
#include "groupchat.h"
|
||||
|
||||
/* add a char to input field and buffer */
|
||||
void input_new_char(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y)
|
||||
@ -255,6 +256,14 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y)
|
||||
force_refresh(self->chatwin->history);
|
||||
break;
|
||||
|
||||
case T_KEY_C_B:
|
||||
if (self->is_groupchat) {
|
||||
self->show_peerlist ^= 1;
|
||||
redraw_groupchat_win(self);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
match = false;
|
||||
break;
|
||||
|
@ -59,7 +59,7 @@ void line_info_reset_start(ToxWindow *self, struct history *hst)
|
||||
int y2, x2;
|
||||
getmaxyx(self->window, y2, x2);
|
||||
|
||||
int side_offst = self->is_groupchat ? SIDEBAR_WIDTH : 0;
|
||||
int side_offst = self->show_peerlist ? SIDEBAR_WIDTH : 0;
|
||||
int top_offst = self->is_chat || self->is_prompt ? 2 : 0;
|
||||
int max_y = (y2 - CHATBOX_HEIGHT - top_offst);
|
||||
|
||||
@ -246,7 +246,7 @@ static void line_info_check_queue(ToxWindow *self)
|
||||
if (x2 <= SIDEBAR_WIDTH)
|
||||
return;
|
||||
|
||||
int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */
|
||||
int offst = self->show_peerlist ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */
|
||||
int lines = 1 + line->newlines + (line->len / (x2 - offst));
|
||||
int max_y = y2 - CHATBOX_HEIGHT;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define TOXIC_H
|
||||
|
||||
#ifndef TOXICVER
|
||||
#define TOXICVER "NOVER_" /* Use the -D flag to set this */
|
||||
#define TOXICVER "NOVERS" /* Use the -D flag to set this */
|
||||
#endif
|
||||
|
||||
#ifndef SIGWINCH
|
||||
@ -64,6 +64,7 @@
|
||||
#define T_KEY_C_Y 0x19 /* ctrl-y */
|
||||
#define T_KEY_C_L 0x0C /* ctrl-l */
|
||||
#define T_KEY_C_W 0x17 /* ctrl-w */
|
||||
#define T_KEY_C_B 0x02 /* ctrl-b */
|
||||
#define T_KEY_TAB 0x09 /* TAB key */
|
||||
|
||||
#define ONLINE_CHAR "*"
|
||||
|
@ -152,9 +152,10 @@ struct ToxWindow {
|
||||
int x;
|
||||
|
||||
bool is_chat;
|
||||
bool is_groupchat;
|
||||
bool is_prompt;
|
||||
bool is_friendlist;
|
||||
bool is_groupchat;
|
||||
int show_peerlist; /* used to toggle groupchat peerlist */
|
||||
|
||||
WINDOW_ALERTS alert;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user