@@ -5,7 +5,7 @@ use std::{
5
5
6
6
use crossterm:: {
7
7
cursor:: MoveTo ,
8
- style:: { Attribute , Color , ResetColor , SetAttribute , SetForegroundColor } ,
8
+ style:: { Attribute , Color , SetAttribute , SetForegroundColor } ,
9
9
terminal:: { Clear , ClearType } ,
10
10
Command , QueueableCommand ,
11
11
} ;
@@ -93,20 +93,19 @@ pub fn progress_bar<'a>(
93
93
total : u16 ,
94
94
line_width : u16 ,
95
95
) -> io:: Result < ( ) > {
96
+ debug_assert ! ( total < 1000 ) ;
96
97
debug_assert ! ( progress <= total) ;
97
98
98
99
const PREFIX : & [ u8 ] = b"Progress: [" ;
99
100
const PREFIX_WIDTH : u16 = PREFIX . len ( ) as u16 ;
100
- // Leaving the last char empty (_) for `total` > 99.
101
- const POSTFIX_WIDTH : u16 = "] xxx/xx exercises_" . len ( ) as u16 ;
101
+ const POSTFIX_WIDTH : u16 = "] xxx/xxx" . len ( ) as u16 ;
102
102
const WRAPPER_WIDTH : u16 = PREFIX_WIDTH + POSTFIX_WIDTH ;
103
103
const MIN_LINE_WIDTH : u16 = WRAPPER_WIDTH + 4 ;
104
104
105
105
if line_width < MIN_LINE_WIDTH {
106
106
writer. write_ascii ( b"Progress: " ) ?;
107
107
// Integers are in ASCII.
108
- writer. write_ascii ( format ! ( "{progress}/{total}" ) . as_bytes ( ) ) ?;
109
- return writer. write_ascii ( b" exercises" ) ;
108
+ return writer. write_ascii ( format ! ( "{progress}/{total}" ) . as_bytes ( ) ) ;
110
109
}
111
110
112
111
let stdout = writer. stdout ( ) ;
@@ -133,8 +132,9 @@ pub fn progress_bar<'a>(
133
132
}
134
133
}
135
134
136
- stdout. queue ( ResetColor ) ?;
137
- write ! ( stdout, "] {progress:>3}/{total} exercises" )
135
+ stdout. queue ( SetForegroundColor ( Color :: Reset ) ) ?;
136
+
137
+ write ! ( stdout, "] {progress:>3}/{total}" )
138
138
}
139
139
140
140
pub fn clear_terminal ( stdout : & mut StdoutLock ) -> io:: Result < ( ) > {
0 commit comments