2014-03-24 12:18:58 +01:00
|
|
|
/* line_info.c
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Toxic.
|
|
|
|
*
|
|
|
|
* Toxic is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Toxic is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-04-18 02:00:00 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
2014-03-24 12:18:58 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
#include "conference.h"
|
2020-04-18 02:00:00 +02:00
|
|
|
#include "line_info.h"
|
2014-09-07 21:06:40 +02:00
|
|
|
#include "message_queue.h"
|
|
|
|
#include "misc_tools.h"
|
2020-04-18 02:00:00 +02:00
|
|
|
#include "notify.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "toxic.h"
|
|
|
|
#include "windows.h"
|
2014-05-26 01:54:34 +02:00
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
extern struct user_settings *user_settings;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
|
|
|
void line_info_init(struct history *hst)
|
|
|
|
{
|
2014-07-06 07:46:07 +02:00
|
|
|
hst->line_root = calloc(1, sizeof(struct line_info));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (hst->line_root == NULL) {
|
2015-07-04 07:19:16 +02:00
|
|
|
exit_toxic_err("failed in line_info_init", FATALERR_MEMORY);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
|
|
|
hst->line_start = hst->line_root;
|
|
|
|
hst->line_end = hst->line_start;
|
2020-11-23 18:45:46 +01:00
|
|
|
hst->queue_size = 0;
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2014-09-25 06:42:08 +02:00
|
|
|
/* resets line_start (moves to end of chat history) */
|
|
|
|
void line_info_reset_start(ToxWindow *self, struct history *hst)
|
2014-03-24 12:18:58 +01:00
|
|
|
{
|
2014-07-06 07:46:07 +02:00
|
|
|
struct line_info *line = hst->line_end;
|
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->prev == NULL) {
|
2014-07-06 07:46:07 +02:00
|
|
|
return;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-07-06 07:46:07 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
int y2;
|
|
|
|
int x2;
|
2014-06-13 21:37:04 +02:00
|
|
|
getmaxyx(self->window, y2, x2);
|
2020-11-23 18:45:46 +01:00
|
|
|
UNUSED_VAR(x2);
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-09 23:01:22 +01:00
|
|
|
int top_offst = (self->type == WINDOW_TYPE_CHAT) || (self->type == WINDOW_TYPE_PROMPT) ? 2 : 0;
|
2020-11-23 18:45:46 +01:00
|
|
|
int max_y = y2 - CHATBOX_HEIGHT - top_offst;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-07-06 07:46:07 +02:00
|
|
|
int curlines = 0;
|
|
|
|
|
|
|
|
do {
|
2020-11-23 18:45:46 +01:00
|
|
|
curlines += line->format_lines;
|
2014-03-24 12:18:58 +01:00
|
|
|
line = line->prev;
|
2020-11-25 01:47:04 +01:00
|
|
|
} while (line->prev && curlines + line->format_lines <= max_y);
|
2014-06-13 21:37:04 +02:00
|
|
|
|
|
|
|
hst->line_start = line;
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void line_info_cleanup(struct history *hst)
|
|
|
|
{
|
|
|
|
struct line_info *tmp1 = hst->line_root;
|
|
|
|
|
|
|
|
while (tmp1) {
|
|
|
|
struct line_info *tmp2 = tmp1->next;
|
|
|
|
free(tmp1);
|
|
|
|
tmp1 = tmp2;
|
|
|
|
}
|
2014-07-09 01:24:44 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
for (size_t i = 0; i < hst->queue_size; ++i) {
|
2018-07-18 17:33:16 +02:00
|
|
|
if (hst->queue[i]) {
|
2014-07-09 01:24:44 +02:00
|
|
|
free(hst->queue[i]);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-07-09 01:24:44 +02:00
|
|
|
}
|
2014-09-06 19:18:42 +02:00
|
|
|
|
|
|
|
free(hst);
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 03:26:09 +02:00
|
|
|
/* moves root forward and frees previous root */
|
|
|
|
static void line_info_root_fwd(struct history *hst)
|
|
|
|
{
|
|
|
|
struct line_info *tmp = hst->line_root->next;
|
|
|
|
tmp->prev = NULL;
|
|
|
|
|
|
|
|
if (hst->line_start->prev == NULL) { /* if line_start is root move it forward as well */
|
|
|
|
hst->line_start = hst->line_start->next;
|
|
|
|
hst->line_start->prev = NULL;
|
|
|
|
++hst->start_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(hst->line_root);
|
|
|
|
hst->line_root = tmp;
|
|
|
|
}
|
|
|
|
|
2014-09-25 06:42:08 +02:00
|
|
|
/* returns ptr to queue item 0 and removes it from queue. Returns NULL if queue is empty. */
|
2014-06-14 07:43:59 +02:00
|
|
|
static struct line_info *line_info_ret_queue(struct history *hst)
|
|
|
|
{
|
2020-11-23 18:45:46 +01:00
|
|
|
if (hst->queue_size == 0) {
|
2014-06-14 07:43:59 +02:00
|
|
|
return NULL;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-06-14 07:43:59 +02:00
|
|
|
|
2014-09-25 06:42:08 +02:00
|
|
|
struct line_info *line = hst->queue[0];
|
2014-06-14 07:43:59 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
for (size_t i = 0; i < hst->queue_size; ++i) {
|
2014-06-14 07:43:59 +02:00
|
|
|
hst->queue[i] = hst->queue[i + 1];
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-06-14 07:43:59 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
--hst->queue_size;
|
2014-06-14 07:43:59 +02:00
|
|
|
|
2014-09-25 06:42:08 +02:00
|
|
|
return line;
|
2014-06-14 07:43:59 +02:00
|
|
|
}
|
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
/* Prints a maximum of `n` chars from `s` to `win`.
|
2020-11-23 00:41:12 +01:00
|
|
|
*
|
|
|
|
* Return true if the string contains a newline or tab byte.
|
|
|
|
*/
|
|
|
|
static bool print_n_chars(WINDOW *win, const char *s, size_t n)
|
|
|
|
{
|
|
|
|
bool newline = false;
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < n && (ch = s[i]); ++i) {
|
2020-11-23 18:45:46 +01:00
|
|
|
if (win) {
|
|
|
|
wprintw(win, "%c", ch);
|
|
|
|
}
|
2020-11-23 00:41:12 +01:00
|
|
|
|
|
|
|
if (ch == '\n') {
|
|
|
|
newline = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the index of the last space character in `s` found before `limit`.
|
|
|
|
* Returns -1 if no space is found.
|
|
|
|
*/
|
|
|
|
static int rspace_index(const char *s, int limit)
|
|
|
|
{
|
|
|
|
for (int i = limit; i >= 0; --i) {
|
|
|
|
if (s[i] == ' ') {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
/* Returns the first index in `s` containing a newline byte found before `limit`.
|
|
|
|
* Returns -1 if no newline is found.
|
|
|
|
*/
|
|
|
|
static int newline_index(const char *s, int limit)
|
|
|
|
{
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
for (int i = 0; i < limit && (ch = s[i]); ++i) {
|
|
|
|
if (ch == '\n') {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the number of newline bytes in `s` */
|
|
|
|
static unsigned int newline_count(const char *s)
|
|
|
|
{
|
|
|
|
char ch;
|
|
|
|
unsigned int count = 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; (ch = s[i]); ++i) {
|
|
|
|
if (ch == '\n') {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2020-11-23 00:41:12 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
/* Prints `line` message to window, wrapping at the last word that fits on the current line.
|
|
|
|
* This function updates the `format_lines` field of `line` according to current window dimensions.
|
2020-11-23 00:41:12 +01:00
|
|
|
*
|
2020-11-23 18:45:46 +01:00
|
|
|
* If `win` is null nothing will be printed to the window. This is useful to set the
|
|
|
|
* `format_lines` field on initialization.
|
2020-11-23 00:41:12 +01:00
|
|
|
*/
|
|
|
|
static void print_wrap(WINDOW *win, struct line_info *line, int max_x)
|
|
|
|
{
|
|
|
|
const char *msg = line->msg;
|
|
|
|
uint16_t length = line->msg_len;
|
2020-11-25 01:47:04 +01:00
|
|
|
uint16_t lines = 0;
|
2020-11-23 00:41:12 +01:00
|
|
|
const int x_start = line->len - line->msg_len - 1; // manually keep track of x position because ncurses sucks
|
2020-11-25 01:47:04 +01:00
|
|
|
int x_limit = max_x - x_start;
|
2020-11-23 00:41:12 +01:00
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
if (x_limit <= 0) {
|
|
|
|
fprintf(stderr, "Warning: x_limit <= 0 in print_wrap(): %d\n", x_limit);
|
|
|
|
return;
|
|
|
|
}
|
2020-11-23 00:41:12 +01:00
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
while (msg) {
|
|
|
|
if (length < x_limit) {
|
|
|
|
if (print_n_chars(win, msg, length)) {
|
|
|
|
lines += newline_count(msg);
|
2020-11-23 18:45:46 +01:00
|
|
|
}
|
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
++lines;
|
2020-11-23 00:41:12 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
int newline_idx = newline_index(msg, x_limit - 1);
|
|
|
|
|
|
|
|
if (newline_idx >= 0) {
|
|
|
|
print_n_chars(win, msg, newline_idx + 1);
|
|
|
|
msg += newline_idx + 1;
|
|
|
|
length -= (newline_idx + 1);
|
|
|
|
x_limit = max_x; // if we find a newline we stop adding column padding for rest of message
|
|
|
|
++lines;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
int space_idx = rspace_index(msg, x_limit - 1);
|
|
|
|
|
|
|
|
if (space_idx >= 1) {
|
2020-11-25 01:47:04 +01:00
|
|
|
print_n_chars(win, msg, space_idx);
|
|
|
|
msg += space_idx + 1;
|
|
|
|
length -= (space_idx + 1);
|
2020-11-25 19:27:47 +01:00
|
|
|
waddch(win, '\n');
|
2020-11-23 00:41:12 +01:00
|
|
|
} else {
|
|
|
|
print_n_chars(win, msg, x_limit);
|
|
|
|
msg += x_limit;
|
|
|
|
length -= x_limit;
|
|
|
|
}
|
2020-11-25 01:47:04 +01:00
|
|
|
|
|
|
|
// Add padding to the start of the next line
|
|
|
|
if (win && x_limit < max_x) {
|
|
|
|
for (size_t i = 0; i < x_start; ++i) {
|
|
|
|
waddch(win, ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++lines;
|
2020-11-23 00:41:12 +01:00
|
|
|
}
|
|
|
|
|
2020-11-25 19:27:47 +01:00
|
|
|
if (win && line->noread_flag) {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
UNUSED_VAR(y);
|
|
|
|
|
|
|
|
getyx(win, y, x);
|
|
|
|
|
|
|
|
if (x >= max_x - 1 || x == x_start) {
|
|
|
|
++lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
wattron(win, COLOR_PAIR(RED));
|
|
|
|
wprintw(win, " x");
|
|
|
|
wattroff(win, COLOR_PAIR(RED));
|
|
|
|
}
|
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
line->format_lines = lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void line_info_init_line(WINDOW *win, struct line_info *line)
|
|
|
|
{
|
|
|
|
int max_y;
|
|
|
|
int max_x;
|
|
|
|
UNUSED_VAR(max_y);
|
|
|
|
|
|
|
|
getmaxyx(win, max_y, max_x);
|
|
|
|
|
|
|
|
print_wrap(NULL, line, max_x);
|
2020-11-23 00:41:12 +01:00
|
|
|
}
|
|
|
|
|
2017-06-01 22:46:12 +02:00
|
|
|
/* creates new line_info line and puts it in the queue.
|
|
|
|
*
|
|
|
|
* Returns the id of the new line.
|
|
|
|
* Returns -1 on failure.
|
|
|
|
*/
|
|
|
|
int line_info_add(ToxWindow *self, const char *timestr, const char *name1, const char *name2, uint8_t type,
|
|
|
|
uint8_t bold, uint8_t colour, const char *msg, ...)
|
2014-03-24 12:18:58 +01:00
|
|
|
{
|
2018-07-18 17:33:16 +02:00
|
|
|
if (!self) {
|
2017-06-01 22:46:12 +02:00
|
|
|
return -1;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2015-08-27 09:38:08 +02:00
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
struct history *hst = self->chatwin->hst;
|
2014-09-05 12:17:10 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
if (hst->queue_size >= MAX_LINE_INFO_QUEUE) {
|
2017-06-01 22:46:12 +02:00
|
|
|
return -1;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-09-05 12:17:10 +02:00
|
|
|
|
2014-07-06 07:46:07 +02:00
|
|
|
struct line_info *new_line = calloc(1, sizeof(struct line_info));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (new_line == NULL) {
|
2015-07-04 07:19:16 +02:00
|
|
|
exit_toxic_err("failed in line_info_add", FATALERR_MEMORY);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-25 01:47:04 +01:00
|
|
|
char frmt_msg[MAX_LINE_INFO_MSG_SIZE];
|
|
|
|
frmt_msg[0] = 0;
|
2014-07-25 04:43:32 +02:00
|
|
|
|
2014-08-02 21:35:57 +02:00
|
|
|
va_list args;
|
|
|
|
va_start(args, msg);
|
|
|
|
vsnprintf(frmt_msg, sizeof(frmt_msg), msg, args);
|
|
|
|
va_end(args);
|
2014-07-25 04:43:32 +02:00
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
int len = 1; /* there will always be a newline */
|
|
|
|
|
|
|
|
/* for type-specific formatting in print function */
|
2014-03-25 13:21:50 +01:00
|
|
|
switch (type) {
|
2014-09-08 03:43:16 +02:00
|
|
|
case IN_ACTION:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-09-07 08:43:53 +02:00
|
|
|
case OUT_ACTION:
|
2015-02-08 13:49:05 +01:00
|
|
|
len += strlen(user_settings->line_normal) + 2;
|
2014-09-07 08:43:53 +02:00
|
|
|
break;
|
|
|
|
|
2014-09-08 04:26:07 +02:00
|
|
|
case IN_MSG:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-09-07 08:43:53 +02:00
|
|
|
case OUT_MSG:
|
2015-02-08 13:49:05 +01:00
|
|
|
len += strlen(user_settings->line_normal) + 3;
|
2014-09-07 08:43:53 +02:00
|
|
|
break;
|
|
|
|
|
2014-06-14 20:09:20 +02:00
|
|
|
case CONNECTION:
|
2015-02-08 13:49:05 +01:00
|
|
|
len += strlen(user_settings->line_join) + 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISCONNECTION:
|
|
|
|
len += strlen(user_settings->line_quit) + 2;
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
|
|
|
|
2014-06-14 20:09:20 +02:00
|
|
|
case SYS_MSG:
|
|
|
|
break;
|
|
|
|
|
2014-09-25 10:31:45 +02:00
|
|
|
case NAME_CHANGE:
|
2015-02-08 13:49:05 +01:00
|
|
|
len += strlen(user_settings->line_alert) + 1;
|
2014-09-25 10:31:45 +02:00
|
|
|
break;
|
|
|
|
|
2014-06-14 20:09:20 +02:00
|
|
|
case PROMPT:
|
|
|
|
++len;
|
|
|
|
break;
|
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
default:
|
|
|
|
len += 2;
|
|
|
|
break;
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
uint16_t msg_len = 0;
|
|
|
|
|
2014-07-25 04:43:32 +02:00
|
|
|
if (frmt_msg[0]) {
|
|
|
|
snprintf(new_line->msg, sizeof(new_line->msg), "%s", frmt_msg);
|
2020-11-23 00:41:12 +01:00
|
|
|
msg_len = strlen(new_line->msg);
|
|
|
|
len += msg_len;
|
2014-04-19 23:58:13 +02:00
|
|
|
}
|
|
|
|
|
2014-09-07 21:06:40 +02:00
|
|
|
if (timestr) {
|
|
|
|
snprintf(new_line->timestr, sizeof(new_line->timestr), "%s", timestr);
|
2015-02-20 00:20:38 +01:00
|
|
|
len += strlen(new_line->timestr) + 1;
|
2014-04-19 23:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name1) {
|
2014-06-01 18:54:45 +02:00
|
|
|
snprintf(new_line->name1, sizeof(new_line->name1), "%s", name1);
|
|
|
|
len += strlen(new_line->name1);
|
2014-04-19 23:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name2) {
|
2014-06-01 18:54:45 +02:00
|
|
|
snprintf(new_line->name2, sizeof(new_line->name2), "%s", name2);
|
|
|
|
len += strlen(new_line->name2);
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
new_line->id = (hst->line_end->id + 1 + hst->queue_size) % INT_MAX;
|
2014-03-24 12:18:58 +01:00
|
|
|
new_line->len = len;
|
2020-11-23 00:41:12 +01:00
|
|
|
new_line->msg_len = msg_len;
|
2014-03-25 13:21:50 +01:00
|
|
|
new_line->type = type;
|
2014-03-24 12:18:58 +01:00
|
|
|
new_line->bold = bold;
|
|
|
|
new_line->colour = colour;
|
2014-09-08 04:26:07 +02:00
|
|
|
new_line->noread_flag = false;
|
2014-09-07 21:06:40 +02:00
|
|
|
new_line->timestamp = get_unix_time();
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
line_info_init_line(self->chatwin->history, new_line);
|
|
|
|
|
|
|
|
hst->queue[hst->queue_size++] = new_line;
|
2017-06-01 22:46:12 +02:00
|
|
|
|
|
|
|
return new_line->id;
|
2014-06-14 07:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* adds a single queue item to hst if possible. only called once per call to line_info_print() */
|
2015-03-26 03:56:45 +01:00
|
|
|
static void line_info_check_queue(ToxWindow *self)
|
2014-06-14 07:43:59 +02:00
|
|
|
{
|
|
|
|
struct history *hst = self->chatwin->hst;
|
|
|
|
struct line_info *line = line_info_ret_queue(hst);
|
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line == NULL) {
|
2014-06-14 07:43:59 +02:00
|
|
|
return;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (hst->start_id > user_settings->history_size) {
|
2014-04-01 03:26:09 +02:00
|
|
|
line_info_root_fwd(hst);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
line->prev = hst->line_end;
|
|
|
|
hst->line_end->next = line;
|
|
|
|
hst->line_end = line;
|
2017-06-01 22:46:12 +02:00
|
|
|
hst->line_end->id = line->id;
|
2014-03-26 02:43:49 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
int y;
|
|
|
|
int y2;
|
|
|
|
int x;
|
|
|
|
int x2;
|
2014-03-24 12:18:58 +01:00
|
|
|
getmaxyx(self->window, y2, x2);
|
2014-03-25 08:17:22 +01:00
|
|
|
getyx(self->chatwin->history, y, x);
|
2020-03-30 18:56:42 +02:00
|
|
|
|
|
|
|
UNUSED_VAR(x);
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (x2 <= SIDEBAR_WIDTH) {
|
2014-03-27 00:14:28 +01:00
|
|
|
return;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-27 00:14:28 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
int lines = line->format_lines;
|
2014-06-29 00:40:22 +02:00
|
|
|
int max_y = y2 - CHATBOX_HEIGHT;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-03-26 02:43:49 +01:00
|
|
|
/* move line_start forward proportionate to the number of new lines */
|
2020-11-23 18:45:46 +01:00
|
|
|
if (y + lines > max_y) {
|
2014-06-14 08:54:58 +02:00
|
|
|
while (lines > 0 && hst->line_start->next) {
|
2020-11-23 18:45:46 +01:00
|
|
|
lines -= hst->line_start->next->format_lines;
|
2014-06-14 08:54:58 +02:00
|
|
|
hst->line_start = hst->line_start->next;
|
2014-03-24 12:18:58 +01:00
|
|
|
++hst->start_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-10 22:18:37 +02:00
|
|
|
#define NOREAD_FLAG_TIMEOUT 5 /* seconds before a sent message with no read receipt is flagged as unread */
|
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
void line_info_print(ToxWindow *self)
|
|
|
|
{
|
|
|
|
ChatContext *ctx = self->chatwin;
|
2014-06-01 09:38:20 +02:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (ctx == NULL) {
|
2014-06-01 09:38:20 +02:00
|
|
|
return;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-06-01 09:38:20 +02:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
struct history *hst = ctx->hst;
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
/* Only allow one new item to be added to chat window per call to this function */
|
|
|
|
line_info_check_queue(self);
|
2014-03-28 22:33:23 +01:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
WINDOW *win = ctx->history;
|
2018-07-18 17:33:16 +02:00
|
|
|
|
2014-03-24 12:37:52 +01:00
|
|
|
wclear(win);
|
2018-07-18 17:33:16 +02:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
int y2;
|
|
|
|
|
|
|
|
int x2;
|
2018-07-18 17:33:16 +02:00
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
getmaxyx(self->window, y2, x2);
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
if (x2 - 1 <= SIDEBAR_WIDTH) { // leave room on x axis for sidebar padding
|
2014-03-27 00:14:28 +01:00
|
|
|
return;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-27 00:14:28 +01:00
|
|
|
|
2020-11-09 23:01:22 +01:00
|
|
|
if (self->type == WINDOW_TYPE_CONFERENCE) {
|
2014-03-25 13:21:50 +01:00
|
|
|
wmove(win, 0, 0);
|
2018-07-18 17:33:16 +02:00
|
|
|
} else {
|
2014-03-25 13:21:50 +01:00
|
|
|
wmove(win, 2, 0);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
struct line_info *line = hst->line_start->next;
|
2018-07-18 17:33:16 +02:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
const int max_x = self->show_peerlist ? x2 - 1 - SIDEBAR_WIDTH : x2;
|
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
int numlines = 0;
|
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
while (line && numlines++ <= y2) {
|
2014-03-25 13:21:50 +01:00
|
|
|
uint8_t type = line->type;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
|
|
|
switch (type) {
|
2014-04-19 23:58:13 +02:00
|
|
|
case OUT_MSG:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-09-07 08:43:53 +02:00
|
|
|
case OUT_MSG_READ:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-04-19 23:58:13 +02:00
|
|
|
case IN_MSG:
|
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
int nameclr = GREEN;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->colour) {
|
2014-04-19 23:58:13 +02:00
|
|
|
nameclr = line->colour;
|
2018-07-18 17:33:16 +02:00
|
|
|
} else if (type == IN_MSG) {
|
2014-04-19 23:58:13 +02:00
|
|
|
nameclr = CYAN;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, COLOR_PAIR(nameclr));
|
2015-02-08 13:49:05 +01:00
|
|
|
wprintw(win, "%s %s: ", user_settings->line_normal, line->name1);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(nameclr));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
if (line->msg[0] == 0) {
|
|
|
|
waddch(win, '\n');
|
|
|
|
break;
|
|
|
|
}
|
2016-02-29 01:46:48 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
if (line->msg[0] == '>') {
|
|
|
|
wattron(win, COLOR_PAIR(GREEN));
|
|
|
|
} else if (line->msg[0] == '<') {
|
|
|
|
wattron(win, COLOR_PAIR(RED));
|
|
|
|
}
|
2016-02-29 01:46:48 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
2016-02-29 01:46:48 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
if (line->msg[0] == '>') {
|
|
|
|
wattroff(win, COLOR_PAIR(GREEN));
|
|
|
|
} else if (line->msg[0] == '<') {
|
|
|
|
wattroff(win, COLOR_PAIR(RED));
|
2016-02-29 01:46:48 +01:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-25 19:27:47 +01:00
|
|
|
if (type == OUT_MSG && !line->read_flag) {
|
|
|
|
if (timed_out(line->timestamp, NOREAD_FLAG_TIMEOUT)) {
|
2014-09-08 04:26:07 +02:00
|
|
|
line->noread_flag = true;
|
|
|
|
}
|
2014-09-07 08:43:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
waddch(win, '\n');
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-09-07 08:43:53 +02:00
|
|
|
case OUT_ACTION_READ:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-09-07 08:43:53 +02:00
|
|
|
case OUT_ACTION:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2016-10-05 11:55:45 +02:00
|
|
|
/* fallthrough */
|
2014-09-07 08:43:53 +02:00
|
|
|
case IN_ACTION:
|
2014-03-24 12:37:52 +01:00
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2014-03-24 12:37:52 +01:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, COLOR_PAIR(YELLOW));
|
2020-11-23 00:41:12 +01:00
|
|
|
wprintw(win, "%s %s ", user_settings->line_normal, line->name1);
|
|
|
|
print_wrap(win, line, max_x);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(YELLOW));
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-25 19:27:47 +01:00
|
|
|
if (type == OUT_ACTION && !line->read_flag) {
|
|
|
|
if (timed_out(line->timestamp, NOREAD_FLAG_TIMEOUT)) {
|
2014-09-08 04:26:07 +02:00
|
|
|
line->noread_flag = true;
|
|
|
|
}
|
2014-09-07 08:43:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
waddch(win, '\n');
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
case SYS_MSG:
|
2014-09-07 21:06:40 +02:00
|
|
|
if (line->timestr[0]) {
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->bold) {
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, A_BOLD);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->colour) {
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, COLOR_PAIR(line->colour));
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
|
|
|
waddch(win, '\n');
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->bold) {
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, A_BOLD);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->colour) {
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(line->colour));
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
2014-03-25 08:17:22 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
case PROMPT:
|
|
|
|
wattron(win, COLOR_PAIR(GREEN));
|
|
|
|
wprintw(win, "$ ");
|
|
|
|
wattroff(win, COLOR_PAIR(GREEN));
|
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (line->msg[0]) {
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
waddch(win, '\n');
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
case CONNECTION:
|
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, COLOR_PAIR(line->colour));
|
2015-02-08 13:49:05 +01:00
|
|
|
wprintw(win, "%s ", user_settings->line_join);
|
|
|
|
|
|
|
|
wattron(win, A_BOLD);
|
|
|
|
wprintw(win, "%s ", line->name1);
|
|
|
|
wattroff(win, A_BOLD);
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
|
|
|
waddch(win, '\n');
|
|
|
|
|
2015-02-08 13:49:05 +01:00
|
|
|
wattroff(win, COLOR_PAIR(line->colour));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISCONNECTION:
|
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2015-02-08 13:49:05 +01:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
|
|
|
|
|
|
|
wattron(win, COLOR_PAIR(line->colour));
|
|
|
|
wprintw(win, "%s ", user_settings->line_quit);
|
2014-09-25 10:31:45 +02:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, A_BOLD);
|
2014-09-25 10:31:45 +02:00
|
|
|
wprintw(win, "%s ", line->name1);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, A_BOLD);
|
2014-09-25 10:31:45 +02:00
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
|
|
|
waddch(win, '\n');
|
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(line->colour));
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
break;
|
2014-03-25 13:21:50 +01:00
|
|
|
|
2014-04-19 23:58:13 +02:00
|
|
|
case NAME_CHANGE:
|
|
|
|
wattron(win, COLOR_PAIR(BLUE));
|
2015-02-20 00:20:38 +01:00
|
|
|
wprintw(win, "%s ", line->timestr);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, COLOR_PAIR(BLUE));
|
|
|
|
|
|
|
|
wattron(win, COLOR_PAIR(MAGENTA));
|
2015-02-08 13:49:05 +01:00
|
|
|
wprintw(win, "%s ", user_settings->line_alert);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattron(win, A_BOLD);
|
2014-09-25 10:31:45 +02:00
|
|
|
wprintw(win, "%s", line->name1);
|
2014-04-19 23:58:13 +02:00
|
|
|
wattroff(win, A_BOLD);
|
|
|
|
|
2020-11-23 00:41:12 +01:00
|
|
|
print_wrap(win, line, max_x);
|
2014-04-19 23:58:13 +02:00
|
|
|
|
|
|
|
wattron(win, A_BOLD);
|
|
|
|
wprintw(win, "%s\n", line->name2);
|
|
|
|
wattroff(win, A_BOLD);
|
|
|
|
wattroff(win, COLOR_PAIR(MAGENTA));
|
|
|
|
|
|
|
|
break;
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
line = line->next;
|
|
|
|
}
|
2014-06-14 07:43:59 +02:00
|
|
|
|
|
|
|
/* keep calling until queue is empty */
|
2020-11-23 18:45:46 +01:00
|
|
|
if (hst->queue_size > 0) {
|
2014-06-14 07:43:59 +02:00
|
|
|
line_info_print(self);
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2014-09-07 08:43:53 +02:00
|
|
|
/* puts msg in specified line_info msg buffer */
|
2014-07-07 04:15:35 +02:00
|
|
|
void line_info_set(ToxWindow *self, uint32_t id, char *msg)
|
2014-03-28 04:05:50 +01:00
|
|
|
{
|
|
|
|
struct line_info *line = self->chatwin->hst->line_end;
|
|
|
|
|
|
|
|
while (line) {
|
|
|
|
if (line->id == id) {
|
2020-11-26 21:35:04 +01:00
|
|
|
size_t new_len = strlen(msg);
|
|
|
|
line->len = line->len - line->msg_len + new_len;
|
|
|
|
line->msg_len = new_len;
|
2014-03-28 04:05:50 +01:00
|
|
|
snprintf(line->msg, sizeof(line->msg), "%s", msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = line->prev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
static void line_info_scroll_up(struct history *hst)
|
|
|
|
{
|
2018-07-18 17:33:16 +02:00
|
|
|
if (hst->line_start->prev) {
|
2014-03-24 12:18:58 +01:00
|
|
|
hst->line_start = hst->line_start->prev;
|
2018-07-18 17:33:16 +02:00
|
|
|
} else {
|
|
|
|
sound_notify(NULL, notif_error, NT_ALWAYS, NULL);
|
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void line_info_scroll_down(struct history *hst)
|
|
|
|
{
|
2018-07-18 17:33:16 +02:00
|
|
|
if (hst->line_start->next) {
|
2014-03-24 12:18:58 +01:00
|
|
|
hst->line_start = hst->line_start->next;
|
2018-07-18 17:33:16 +02:00
|
|
|
} else {
|
|
|
|
sound_notify(NULL, notif_error, NT_ALWAYS, NULL);
|
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void line_info_page_up(ToxWindow *self, struct history *hst)
|
|
|
|
{
|
|
|
|
int x2, y2;
|
|
|
|
getmaxyx(self->window, y2, x2);
|
2020-03-30 18:56:42 +02:00
|
|
|
|
|
|
|
UNUSED_VAR(x2);
|
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
size_t jump_dist = y2 / 2;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
for (size_t i = 0; i < jump_dist && hst->line_start->prev; ++i) {
|
2014-03-24 12:18:58 +01:00
|
|
|
hst->line_start = hst->line_start->prev;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void line_info_page_down(ToxWindow *self, struct history *hst)
|
|
|
|
{
|
|
|
|
int x2, y2;
|
|
|
|
getmaxyx(self->window, y2, x2);
|
2020-03-30 18:56:42 +02:00
|
|
|
|
|
|
|
UNUSED_VAR(x2);
|
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
size_t jump_dist = y2 / 2;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2020-11-23 18:45:46 +01:00
|
|
|
for (size_t i = 0; i < jump_dist && hst->line_start->next; ++i) {
|
2014-03-24 12:18:58 +01:00
|
|
|
hst->line_start = hst->line_start->next;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-24 12:18:58 +01:00
|
|
|
}
|
|
|
|
|
2014-06-13 07:42:20 +02:00
|
|
|
bool line_info_onKey(ToxWindow *self, wint_t key)
|
2014-03-24 12:18:58 +01:00
|
|
|
{
|
|
|
|
struct history *hst = self->chatwin->hst;
|
2014-06-13 07:42:20 +02:00
|
|
|
bool match = true;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
2015-02-08 11:26:36 +01:00
|
|
|
if (key == user_settings->key_half_page_up) {
|
|
|
|
line_info_page_up(self, hst);
|
2016-09-25 03:07:04 +02:00
|
|
|
} else if (key == user_settings->key_half_page_down) {
|
2015-02-08 11:26:36 +01:00
|
|
|
line_info_page_down(self, hst);
|
2016-09-25 03:07:04 +02:00
|
|
|
} else if (key == user_settings->key_scroll_line_up) {
|
2015-02-08 11:26:36 +01:00
|
|
|
line_info_scroll_up(hst);
|
2016-09-25 03:07:04 +02:00
|
|
|
} else if (key == user_settings->key_scroll_line_down) {
|
2015-02-08 11:26:36 +01:00
|
|
|
line_info_scroll_down(hst);
|
2016-09-25 03:07:04 +02:00
|
|
|
} else if (key == user_settings->key_page_bottom) {
|
2015-02-08 11:26:36 +01:00
|
|
|
line_info_reset_start(self, hst);
|
2016-09-25 03:07:04 +02:00
|
|
|
} else {
|
2015-02-08 11:26:36 +01:00
|
|
|
match = false;
|
|
|
|
}
|
2014-03-27 10:08:48 +01:00
|
|
|
|
2014-06-13 07:42:20 +02:00
|
|
|
return match;
|
2014-03-27 10:08:48 +01:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:43:49 +01:00
|
|
|
void line_info_clear(struct history *hst)
|
|
|
|
{
|
|
|
|
hst->line_start = hst->line_end;
|
2014-03-27 00:14:28 +01:00
|
|
|
hst->start_id = hst->line_start->id;
|
2014-03-26 02:43:49 +01:00
|
|
|
}
|