Browse Source

Display "NO DEVICES FOUND" line in place of device list, when there are none

Luke Dashjr 12 years ago
parent
commit
2d7a06f091
1 changed files with 18 additions and 8 deletions
  1. 18 8
      miner.c

+ 18 - 8
miner.c

@@ -3728,16 +3728,29 @@ static void curses_print_devstatus(struct cgpu_info *cgpu)
 }
 }
 
 
 static
 static
-void refresh_devstatus() {
-	if (curses_active_locked()) {
+void _refresh_devstatus(const bool already_have_lock) {
+	if ((!opt_compact) && (already_have_lock || curses_active_locked())) {
 		int i;
 		int i;
+		if (unlikely(!total_devices))
+		{
+			const int ypos = devcursor - 1;
+			if (ypos < statusy - 1 && wmove(statuswin, ypos, 0) != ERR)
+			{
+				wattron(statuswin, attr_bad);
+				bfg_waddstr(statuswin, "NO DEVICES FOUND: Press 'M' and '+' to add");
+				wclrtoeol(statuswin);
+				wattroff(statuswin, attr_bad);
+			}
+		}
 		for (i = 0; i < total_devices; i++)
 		for (i = 0; i < total_devices; i++)
 			curses_print_devstatus(get_devices(i));
 			curses_print_devstatus(get_devices(i));
 		touchwin(statuswin);
 		touchwin(statuswin);
 		wrefresh(statuswin);
 		wrefresh(statuswin);
-		unlock_curses();
+		if (!already_have_lock)
+			unlock_curses();
 	}
 	}
 }
 }
+#define refresh_devstatus() _refresh_devstatus(false)
 
 
 #endif
 #endif
 
 
@@ -3806,7 +3819,7 @@ static void switch_logsize(void)
 			logstart = devcursor - 1;
 			logstart = devcursor - 1;
 			logcursor = logstart + 1;
 			logcursor = logstart + 1;
 		} else {
 		} else {
-			total_lines = (opt_show_procs ? total_devices : device_line_id_count);
+			total_lines = (opt_show_procs ? total_devices : device_line_id_count) ?: 1;
 			logstart = devcursor + total_lines;
 			logstart = devcursor + total_lines;
 			logcursor = logstart;
 			logcursor = logstart;
 		}
 		}
@@ -9708,10 +9721,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 		if (curses_active_locked()) {
 		if (curses_active_locked()) {
 			change_logwinsize();
 			change_logwinsize();
 			curses_print_status(ts);
 			curses_print_status(ts);
-			for (i = 0; i < total_devices; i++)
-				curses_print_devstatus(get_devices(i));
-			touchwin(statuswin);
-			wrefresh(statuswin);
+			_refresh_devstatus(true);
 			touchwin(logwin);
 			touchwin(logwin);
 			wrefresh(logwin);
 			wrefresh(logwin);
 			unlock_curses();
 			unlock_curses();