Pārlūkot izejas kodu

[ui] Add progress dots while waiting on any foreground job

Print one dot per second while waiting in monojob.c (e.g. for DHCP,
for file downloads, etc.), to inform user that the system has not
locked up.

Patch contributed by Andrew Schran <aschran@google.com>, minor
modification by me.
tags/v0.9.4
Michael Brown 16 gadus atpakaļ
vecāks
revīzija
702e0be44e
1 mainītis faili ar 10 papildinājumiem un 3 dzēšanām
  1. 10
    3
      src/core/monojob.c

+ 10
- 3
src/core/monojob.c Parādīt failu

@@ -24,6 +24,7 @@
24 24
 #include <gpxe/keys.h>
25 25
 #include <gpxe/job.h>
26 26
 #include <gpxe/monojob.h>
27
+#include <gpxe/timer.h>
27 28
 
28 29
 /** @file
29 30
  *
@@ -62,9 +63,11 @@ struct job_interface monojob = {
62 63
 int monojob_wait ( const char *string ) {
63 64
 	int key;
64 65
 	int rc;
66
+	tick_t last_progress_dot;
65 67
 
66
-	printf ( "%s... ", string );
68
+	printf ( "%s.", string );
67 69
 	monojob_rc = -EINPROGRESS;
70
+	last_progress_dot = currticks();
68 71
 	while ( monojob_rc == -EINPROGRESS ) {
69 72
 		step();
70 73
 		if ( iskey() ) {
@@ -78,14 +81,18 @@ int monojob_wait ( const char *string ) {
78 81
 				break;
79 82
 			}
80 83
 		}
84
+		if ( ( currticks() - last_progress_dot ) > TICKS_PER_SEC ) {
85
+			printf ( "." );
86
+			last_progress_dot = currticks();
87
+		}
81 88
 	}
82 89
 	rc = monojob_rc;
83 90
 
84 91
 done:
85 92
 	if ( rc ) {
86
-		printf ( "%s\n", strerror ( rc ) );
93
+		printf ( " %s\n", strerror ( rc ) );
87 94
 	} else {
88
-		printf ( "ok\n" );
95
+		printf ( " ok\n" );
89 96
 	}
90 97
 	return rc;
91 98
 }

Notiek ielāde…
Atcelt
Saglabāt