Make curses display visible right from the beginning and fix the window sizes so the initial messages don't get lost once the status window is drawn.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
diff --git a/cgminer.c b/cgminer.c
index 75ef41f..fc8c683 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1269,6 +1269,21 @@ static inline bool change_logwinsize(void)
return false;
}
+static void check_winsizes(void)
+{
+ if (!use_curses)
+ return;
+ if (curses_active_locked()) {
+ int __maybe_unused y, x;
+
+ getmaxyx(statuswin, y, x);
+ wresize(statuswin, logstart, x);
+ change_logwinsize();
+ doupdate();
+ unlock_curses();
+ }
+}
+
/* For mandatory printing when mutex is already locked */
void wlog(const char *f, ...)
{
@@ -1295,13 +1310,20 @@ void wlogprint(const char *f, ...)
void log_curses(int prio, const char *f, va_list ap)
{
+ bool high_prio;
+
if (opt_quiet && prio != LOG_ERR)
return;
+ high_prio = (prio == LOG_WARNING || prio == LOG_ERR);
+
if (curses_active_locked()) {
- if (!opt_loginput || prio == LOG_ERR || prio == LOG_WARNING) {
+ if (!opt_loginput || high_prio) {
vw_printw(logwin, f, ap);
- wrefresh(logwin);
+ if (high_prio)
+ refresh();
+ else
+ wrefresh(logwin);
}
unlock_curses();
} else
@@ -3654,7 +3676,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
curses_print_status();
for (i = 0; i < mining_threads; i++)
curses_print_devstatus(i);
- clearok(statuswin, true);
+ clearok(curscr, true);
doupdate();
unlock_curses();
}
@@ -4152,6 +4174,10 @@ int main (int argc, char *argv[])
#endif // defined(WIN32)
#endif
+ devcursor = 8;
+ logstart = devcursor + 1;
+ logcursor = logstart + 1;
+
block = calloc(sizeof(struct block), 1);
if (unlikely(!block))
quit (1, "main OOM");
@@ -4181,6 +4207,9 @@ int main (int argc, char *argv[])
if (argc != 1)
quit(1, "Unexpected extra commandline arguments");
+ if (use_curses)
+ enable_curses();
+
applog(LOG_WARNING, "Started %s", packagename);
strcat(opt_kernel_path, "/");
@@ -4276,16 +4305,15 @@ int main (int argc, char *argv[])
load_temp_cutoffs();
- devcursor = 8;
- logstart = devcursor + total_devices + 1;
+ logstart += total_devices;
logcursor = logstart + 1;
+ check_winsizes();
+
if (opt_realquiet)
use_curses = false;
if (!total_pools) {
- if (use_curses)
- enable_curses();
applog(LOG_WARNING, "Need to specify at least one pool server.");
if (!use_curses || (use_curses && !input_pool(false)))
quit(1, "Pool setup failed");
@@ -4396,8 +4424,6 @@ int main (int argc, char *argv[])
}
if (!pools_active) {
- if (use_curses)
- enable_curses();
applog(LOG_ERR, "No servers were found that could be used to get work from.");
applog(LOG_ERR, "Please check the details from the list below of the servers you have input");
applog(LOG_ERR, "Most likely you have input the wrong URL, forgotten to add a port, or have not set up workers");
@@ -4476,9 +4502,6 @@ int main (int argc, char *argv[])
algo_names[opt_algo]);
#endif
- if (use_curses)
- enable_curses();
-
watchpool_thr_id = mining_threads + 3;
thr = &thr_info[watchpool_thr_id];
/* start watchpool thread */