diff --git a/src/line_info.c b/src/line_info.c index a6057c0..c83e4b3 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -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); diff --git a/src/line_info.h b/src/line_info.h index a7024fc..7f1b262 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -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; diff --git a/src/message_queue.c b/src/message_queue.c index 3b34bed..45b8c8a 100644 --- a/src/message_queue.c +++ b/src/message_queue.c @@ -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; }