1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 10:23:26 +01:00

properly flag lines with unread mark

This commit is contained in:
Jfreegman 2014-09-07 22:26:07 -04:00
parent 416ebc9ab8
commit 09f90d095b
3 changed files with 19 additions and 7 deletions

View File

@ -156,15 +156,13 @@ void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uin
/* for type-specific formatting in print function */
switch (type) {
case IN_ACTION:
case OUT_ACTION:
len += 3;
break;
case OUT_ACTION:
len += 5;
break;
case IN_MSG:
case OUT_MSG:
len += 4;
len += 2;
break;
case CONNECTION:
@ -214,6 +212,7 @@ void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uin
new_line->type = type;
new_line->bold = bold;
new_line->colour = colour;
new_line->noread_flag = false;
new_line->timestamp = get_unix_time();
hst->queue[hst->queue_sz++] = new_line;
@ -320,6 +319,11 @@ void line_info_print(ToxWindow *self)
wattron(win, COLOR_PAIR(RED));
wprintw(win, " x", line->msg);
wattroff(win, COLOR_PAIR(RED));
if (line->noread_flag == false) {
line->noread_flag = true;
line->len += 2;
}
}
wprintw(win, "\n", line->msg);
@ -340,6 +344,11 @@ void line_info_print(ToxWindow *self)
wattron(win, COLOR_PAIR(RED));
wprintw(win, " x", line->msg);
wattroff(win, COLOR_PAIR(RED));
if (line->noread_flag == false) {
line->noread_flag = true;
line->len += 2;
}
}
wprintw(win, "\n", line->msg);

View File

@ -52,6 +52,7 @@ struct line_info {
uint8_t type;
uint8_t bold;
uint8_t colour;
uint8_t noread_flag; /* true if a line should be flagged as unread */
uint32_t id;
uint16_t len; /* combined len of entire line */
uint8_t newlines;

View File

@ -70,8 +70,10 @@ static void cqueue_mark_read(ToxWindow *self, uint32_t id, uint8_t type)
if (line->id == id) {
line->type = type == OUT_ACTION ? OUT_ACTION_READ : OUT_MSG_READ;
if (timed_out(line->timestamp, get_unix_time(), CQUEUE_TRY_SEND_INTERVAL))
line->len -= 2; /* removes " x" */
if (line->noread_flag == true) {
line->len -= 2;
line->noread_flag = false;
}
return;
}