File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,15 @@ impl ProgressBar {
235
235
}
236
236
}
237
237
238
+ /// Decrease the position of the progress bar by `delta`
239
+ pub fn dec ( & self , delta : u64 ) {
240
+ self . pos . dec ( delta) ;
241
+ let now = Instant :: now ( ) ;
242
+ if self . pos . allow ( now) {
243
+ self . tick_inner ( now) ;
244
+ }
245
+ }
246
+
238
247
/// A quick convenience check if the progress bar is hidden
239
248
pub fn is_hidden ( & self ) -> bool {
240
249
self . state ( ) . draw_target . is_hidden ( )
@@ -290,6 +299,11 @@ impl ProgressBar {
290
299
self . state ( ) . inc_length ( Instant :: now ( ) , delta) ;
291
300
}
292
301
302
+ /// Decrease the length of the progress bar
303
+ pub fn dec_length ( & self , delta : u64 ) {
304
+ self . state ( ) . dec_length ( Instant :: now ( ) , delta) ;
305
+ }
306
+
293
307
/// Sets the current prefix of the progress bar
294
308
///
295
309
/// For the prefix to be visible, the `{prefix}` placeholder must be present in the template
Original file line number Diff line number Diff line change @@ -114,6 +114,13 @@ impl BarState {
114
114
self . update_estimate_and_draw ( now) ;
115
115
}
116
116
117
+ pub ( crate ) fn dec_length ( & mut self , now : Instant , delta : u64 ) {
118
+ if let Some ( len) = self . state . len {
119
+ self . state . len = Some ( len. saturating_sub ( delta) ) ;
120
+ }
121
+ self . update_estimate_and_draw ( now) ;
122
+ }
123
+
117
124
pub ( crate ) fn set_tab_width ( & mut self , tab_width : usize ) {
118
125
self . tab_width = tab_width;
119
126
self . state . message . set_tab_width ( tab_width) ;
@@ -585,6 +592,10 @@ impl AtomicPosition {
585
592
self . pos . fetch_add ( delta, Ordering :: SeqCst ) ;
586
593
}
587
594
595
+ pub ( crate ) fn dec ( & self , delta : u64 ) {
596
+ self . pos . fetch_sub ( delta, Ordering :: SeqCst ) ;
597
+ }
598
+
588
599
pub ( crate ) fn set ( & self , pos : u64 ) {
589
600
self . pos . store ( pos, Ordering :: Release ) ;
590
601
}
You can’t perform that action at this time.
0 commit comments