mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:13:01 +01:00
a few more fixes
This commit is contained in:
parent
c218e104e7
commit
bd5453002e
@ -42,6 +42,10 @@ extern uint8_t max_file_senders_index;
|
|||||||
|
|
||||||
void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
|
struct history *hst = self->chatwin->hst;
|
||||||
|
line_info_clear(hst);
|
||||||
|
struct line_info *start = hst->line_start;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (!strcmp(argv[1], "global")) {
|
if (!strcmp(argv[1], "global")) {
|
||||||
execute(window, self, m, "/help", GLOBAL_COMMAND_MODE);
|
execute(window, self, m, "/help", GLOBAL_COMMAND_MODE);
|
||||||
@ -84,6 +88,8 @@ void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
|||||||
|
|
||||||
msg = " * Use ESC key to toggle history scroll mode\n";
|
msg = " * Use ESC key to toggle history scroll mode\n";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
||||||
|
|
||||||
|
hst->line_start = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
|
@ -372,6 +372,10 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
|
struct history *hst = self->chatwin->hst;
|
||||||
|
line_info_clear(hst);
|
||||||
|
struct line_info *start = hst->line_start;
|
||||||
|
|
||||||
uint8_t *msg = "Global commands:";
|
uint8_t *msg = "Global commands:";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
||||||
|
|
||||||
@ -409,6 +413,8 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
|
|||||||
msg = " * Argument messages must be enclosed in quotation marks.\n"
|
msg = " * Argument messages must be enclosed in quotation marks.\n"
|
||||||
" * Use ctrl-o and ctrl-p to navigate through the tabs.\n";
|
" * Use ctrl-o and ctrl-p to navigate through the tabs.\n";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
||||||
|
|
||||||
|
hst->line_start = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_quit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_quit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
|
@ -106,6 +106,10 @@ static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
|||||||
|
|
||||||
static void print_groupchat_help(ToxWindow *self)
|
static void print_groupchat_help(ToxWindow *self)
|
||||||
{
|
{
|
||||||
|
struct history *hst = self->chatwin->hst;
|
||||||
|
line_info_clear(hst);
|
||||||
|
struct line_info *start = hst->line_start;
|
||||||
|
|
||||||
uint8_t *msg = "Group chat commands:";
|
uint8_t *msg = "Group chat commands:";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
||||||
|
|
||||||
@ -136,6 +140,8 @@ static void print_groupchat_help(ToxWindow *self)
|
|||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
||||||
msg = " * Notice, some friends will be missing names while finding peers\n";
|
msg = " * Notice, some friends will be missing names while finding peers\n";
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, 0);
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, 0);
|
||||||
|
|
||||||
|
hst->line_start = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
|
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
|
||||||
|
@ -168,14 +168,18 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na
|
|||||||
getmaxyx(self->window, y2, x2);
|
getmaxyx(self->window, y2, x2);
|
||||||
getyx(self->chatwin->history, y, x);
|
getyx(self->chatwin->history, y, x);
|
||||||
|
|
||||||
|
if (x2 <= SIDEBAR_WIDTH)
|
||||||
|
return;
|
||||||
|
|
||||||
int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */
|
int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */
|
||||||
int lines = (1 + newlines + (len / (x2 - offst)));
|
int lines = (1 + newlines + (len / (x2 - offst)));
|
||||||
hst->queue += lines;
|
hst->queue_lns += lines;
|
||||||
|
++hst->queue;
|
||||||
|
|
||||||
int max_y = self->is_prompt ? y2 : y2 - CHATBOX_HEIGHT;
|
int max_y = self->is_prompt ? y2 : y2 - CHATBOX_HEIGHT;
|
||||||
|
|
||||||
/* move line_start forward proportionate to the number of new lines */
|
/* move line_start forward proportionate to the number of new lines */
|
||||||
if (y + hst->queue - 1 >= max_y) {
|
if (y + hst->queue_lns - hst->queue >= max_y) {
|
||||||
while (lines > 0 && hst->line_start->next) {
|
while (lines > 0 && hst->line_start->next) {
|
||||||
lines -= (1 + hst->line_start->len / (x2 - offst));
|
lines -= (1 + hst->line_start->len / (x2 - offst));
|
||||||
hst->line_start = hst->line_start->next;
|
hst->line_start = hst->line_start->next;
|
||||||
@ -193,7 +197,11 @@ void line_info_print(ToxWindow *self)
|
|||||||
int y2, x2;
|
int y2, x2;
|
||||||
getmaxyx(self->window, y2, x2);
|
getmaxyx(self->window, y2, x2);
|
||||||
|
|
||||||
|
if (x2 <= SIDEBAR_WIDTH)
|
||||||
|
return;
|
||||||
|
|
||||||
ctx->hst->queue = 0;
|
ctx->hst->queue = 0;
|
||||||
|
ctx->hst->queue_lns = 0;
|
||||||
|
|
||||||
if (self->is_groupchat)
|
if (self->is_groupchat)
|
||||||
wmove(win, 0, 0);
|
wmove(win, 0, 0);
|
||||||
@ -201,11 +209,12 @@ void line_info_print(ToxWindow *self)
|
|||||||
wmove(win, 2, 0);
|
wmove(win, 2, 0);
|
||||||
|
|
||||||
struct line_info *line = ctx->hst->line_start->next;
|
struct line_info *line = ctx->hst->line_start->next;
|
||||||
|
int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0;
|
||||||
int numlines = 0;
|
int numlines = 0;
|
||||||
|
|
||||||
while(line && numlines <= y2) {
|
while(line && numlines <= y2) {
|
||||||
uint8_t type = line->type;
|
uint8_t type = line->type;
|
||||||
numlines += line->len / x2;
|
numlines += line->len / (x2 - offst);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OUT_MSG:
|
case OUT_MSG:
|
||||||
@ -386,4 +395,5 @@ void line_info_onKey(ToxWindow *self, wint_t key)
|
|||||||
void line_info_clear(struct history *hst)
|
void line_info_clear(struct history *hst)
|
||||||
{
|
{
|
||||||
hst->line_start = hst->line_end;
|
hst->line_start = hst->line_end;
|
||||||
|
hst->start_id = hst->line_start->id;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HISTORY 200
|
#define MAX_HISTORY 1000
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SYS_MSG,
|
SYS_MSG,
|
||||||
@ -55,7 +55,10 @@ struct history {
|
|||||||
uint32_t start_id; /* keeps track of where line_start should be when at bottom of history */
|
uint32_t start_id; /* keeps track of where line_start should be when at bottom of history */
|
||||||
uint32_t line_items;
|
uint32_t line_items;
|
||||||
bool scroll_mode;
|
bool scroll_mode;
|
||||||
uint8_t queue; /* keeps track of lines added between window refreshes */
|
|
||||||
|
/* keeps track of lines added between window refreshes */
|
||||||
|
uint8_t queue;
|
||||||
|
uint8_t queue_lns;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* adds a line to history (also moves line_start and/or line_root forward if necessary) */
|
/* adds a line to history (also moves line_start and/or line_root forward if necessary) */
|
||||||
|
Loading…
Reference in New Issue
Block a user