2014-03-24 12:18:58 +01:00
|
|
|
/* line_info.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-06-12 00:06:55 +02:00
|
|
|
#ifndef _line_info_h
|
2014-06-12 02:04:20 +02:00
|
|
|
#define _line_info_h
|
2014-06-12 00:06:55 +02:00
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "toxic.h"
|
|
|
|
|
2014-05-26 01:54:34 +02:00
|
|
|
#define MAX_HISTORY 10000
|
|
|
|
#define MIN_HISTORY 20
|
2014-06-14 07:43:59 +02:00
|
|
|
#define MAX_QUEUE 32
|
2014-03-24 12:18:58 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
SYS_MSG,
|
|
|
|
IN_MSG,
|
|
|
|
OUT_MSG,
|
2014-03-25 08:17:22 +01:00
|
|
|
PROMPT,
|
2014-03-24 12:18:58 +01:00
|
|
|
ACTION,
|
|
|
|
CONNECTION,
|
2014-03-25 13:21:50 +01:00
|
|
|
NAME_CHANGE,
|
2014-03-24 12:18:58 +01:00
|
|
|
} LINE_TYPE;
|
|
|
|
|
|
|
|
struct line_info {
|
|
|
|
uint8_t timestamp[TIME_STR_SIZE];
|
|
|
|
uint8_t name1[TOXIC_MAX_NAME_LENGTH];
|
|
|
|
uint8_t name2[TOXIC_MAX_NAME_LENGTH];
|
2014-04-11 00:16:27 +02:00
|
|
|
uint8_t msg[TOX_MAX_MESSAGE_LENGTH];
|
2014-03-25 13:21:50 +01:00
|
|
|
uint8_t type;
|
2014-03-24 12:18:58 +01:00
|
|
|
uint8_t bold;
|
|
|
|
uint8_t colour;
|
|
|
|
uint32_t id;
|
2014-04-02 10:59:51 +02:00
|
|
|
uint16_t len; /* combined len of all strings */
|
2014-06-14 08:54:58 +02:00
|
|
|
uint8_t newlines;
|
2014-03-24 12:18:58 +01:00
|
|
|
|
|
|
|
struct line_info *prev;
|
|
|
|
struct line_info *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Linked list containing chat history lines */
|
|
|
|
struct history {
|
|
|
|
struct line_info *line_root;
|
|
|
|
struct line_info *line_start; /* the first line we want to start printing at */
|
|
|
|
struct line_info *line_end;
|
|
|
|
uint32_t start_id; /* keeps track of where line_start should be when at bottom of history */
|
2014-03-27 00:14:28 +01:00
|
|
|
|
2014-06-14 07:43:59 +02:00
|
|
|
struct line_info *queue[MAX_QUEUE];
|
2014-06-14 08:54:58 +02:00
|
|
|
int queue_sz;
|
2014-03-24 12:18:58 +01:00
|
|
|
};
|
|
|
|
|
2014-06-14 20:09:20 +02:00
|
|
|
/* creates new line_info line and puts it in the queue */
|
2014-04-19 23:58:13 +02:00
|
|
|
void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *name2, uint8_t *msg,
|
2014-03-25 13:21:50 +01:00
|
|
|
uint8_t type, uint8_t bold, uint8_t colour);
|
2014-03-26 02:43:49 +01:00
|
|
|
|
|
|
|
/* Prints a section of history starting at line_start */
|
|
|
|
void line_info_print(ToxWindow *self);
|
|
|
|
|
|
|
|
/* frees all history lines */
|
2014-03-24 12:18:58 +01:00
|
|
|
void line_info_cleanup(struct history *hst);
|
2014-03-26 02:43:49 +01:00
|
|
|
|
|
|
|
/* clears the screen (does not delete anything) */
|
|
|
|
void line_info_clear(struct history *hst);
|
|
|
|
|
2014-03-28 22:33:23 +01:00
|
|
|
/* puts msg in specified line_info msg buffer */
|
2014-03-28 04:05:50 +01:00
|
|
|
void line_info_set(ToxWindow *self, uint32_t id, uint8_t *msg);
|
|
|
|
|
2014-03-24 12:18:58 +01:00
|
|
|
void line_info_init(struct history *hst);
|
2014-06-13 07:42:20 +02:00
|
|
|
bool line_info_onKey(ToxWindow *self, wint_t key); /* returns true if key is a match */
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-06-12 02:04:20 +02:00
|
|
|
#endif /* #define _line_info_h */
|