Track unreadTotal and unreadWarm separately
Otherwise reflow's calculation of unreadLines is always going to be wrong if there were Cold lines interspersed.master
parent
eb3a92c99e
commit
fbdfb36085
27
ui.c
27
ui.c
|
@ -84,7 +84,8 @@ struct Window {
|
||||||
int scroll;
|
int scroll;
|
||||||
bool mark;
|
bool mark;
|
||||||
enum Heat heat;
|
enum Heat heat;
|
||||||
int unreadCount;
|
int unreadTotal;
|
||||||
|
int unreadWarm;
|
||||||
int unreadLines;
|
int unreadLines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -406,7 +407,7 @@ static void statusUpdate(void) {
|
||||||
const struct Window *window = windows.ptrs[num];
|
const struct Window *window = windows.ptrs[num];
|
||||||
if (!window->heat && num != windows.show) continue;
|
if (!window->heat && num != windows.show) continue;
|
||||||
if (num != windows.show) {
|
if (num != windows.show) {
|
||||||
otherUnread += window->unreadCount;
|
otherUnread += window->unreadWarm;
|
||||||
if (window->heat > otherHeat) otherHeat = window->heat;
|
if (window->heat > otherHeat) otherHeat = window->heat;
|
||||||
}
|
}
|
||||||
int trunc;
|
int trunc;
|
||||||
|
@ -416,20 +417,20 @@ static void statusUpdate(void) {
|
||||||
idColors[window->id], (num == windows.show ? "\26" : ""),
|
idColors[window->id], (num == windows.show ? "\26" : ""),
|
||||||
num, idNames[window->id],
|
num, idNames[window->id],
|
||||||
&trunc, (window->heat > Warm ? White : idColors[window->id]),
|
&trunc, (window->heat > Warm ? White : idColors[window->id]),
|
||||||
window->unreadCount,
|
window->unreadWarm,
|
||||||
idColors[window->id]
|
idColors[window->id]
|
||||||
);
|
);
|
||||||
if (!window->mark || !window->unreadCount) buf[trunc] = '\0';
|
if (!window->mark || !window->unreadWarm) buf[trunc] = '\0';
|
||||||
statusAdd(buf);
|
statusAdd(buf);
|
||||||
}
|
}
|
||||||
wclrtoeol(status);
|
wclrtoeol(status);
|
||||||
|
|
||||||
const struct Window *window = windows.ptrs[windows.show];
|
const struct Window *window = windows.ptrs[windows.show];
|
||||||
snprintf(title, sizeof(title), "%s %s", self.network, idNames[window->id]);
|
snprintf(title, sizeof(title), "%s %s", self.network, idNames[window->id]);
|
||||||
if (window->mark && window->unreadCount) {
|
if (window->mark && window->unreadWarm) {
|
||||||
snprintf(
|
snprintf(
|
||||||
&title[strlen(title)], sizeof(title) - strlen(title),
|
&title[strlen(title)], sizeof(title) - strlen(title),
|
||||||
" (%d%s)", window->unreadCount, (window->heat > Warm ? "!" : "")
|
" (%d%s)", window->unreadWarm, (window->heat > Warm ? "!" : "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (otherUnread) {
|
if (otherUnread) {
|
||||||
|
@ -443,7 +444,8 @@ static void statusUpdate(void) {
|
||||||
static void mark(struct Window *window) {
|
static void mark(struct Window *window) {
|
||||||
if (window->scroll) return;
|
if (window->scroll) return;
|
||||||
window->mark = true;
|
window->mark = true;
|
||||||
window->unreadCount = 0;
|
window->unreadTotal = 0;
|
||||||
|
window->unreadWarm = 0;
|
||||||
window->unreadLines = 0;
|
window->unreadLines = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,12 +590,13 @@ void uiWrite(size_t id, enum Heat heat, const time_t *src, const char *str) {
|
||||||
|
|
||||||
int lines = 1;
|
int lines = 1;
|
||||||
waddch(window->pad, '\n');
|
waddch(window->pad, '\n');
|
||||||
|
window->unreadTotal++;
|
||||||
if (window->mark && heat > Cold) {
|
if (window->mark && heat > Cold) {
|
||||||
if (!window->unreadCount++) {
|
|
||||||
lines++;
|
|
||||||
waddch(window->pad, '\n');
|
|
||||||
}
|
|
||||||
if (window->heat < heat) window->heat = heat;
|
if (window->heat < heat) window->heat = heat;
|
||||||
|
if (!window->unreadWarm++) {
|
||||||
|
waddch(window->pad, '\n');
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
statusUpdate();
|
statusUpdate();
|
||||||
}
|
}
|
||||||
lines += wordWrap(window->pad, str);
|
lines += wordWrap(window->pad, str);
|
||||||
|
@ -625,7 +628,7 @@ static void reflow(struct Window *window) {
|
||||||
const char *line = bufferLine(&window->buffer, i);
|
const char *line = bufferLine(&window->buffer, i);
|
||||||
if (!line) continue;
|
if (!line) continue;
|
||||||
waddch(window->pad, '\n');
|
waddch(window->pad, '\n');
|
||||||
if (i >= (size_t)(BufferCap - window->unreadCount)) {
|
if (i >= (size_t)(BufferCap - window->unreadTotal)) {
|
||||||
window->unreadLines += 1 + wordWrap(window->pad, line);
|
window->unreadLines += 1 + wordWrap(window->pad, line);
|
||||||
} else {
|
} else {
|
||||||
wordWrap(window->pad, line);
|
wordWrap(window->pad, line);
|
||||||
|
|
Loading…
Reference in New Issue