1 module progress.counter; 2 3 import progress; 4 5 import std.algorithm : min; 6 import std.conv : to; 7 8 class Counter : Infinite 9 { 10 this() 11 { 12 this.hide_cursor = true; 13 super(); 14 } 15 16 override void force_update() 17 { 18 this.write(this.index.to!string); 19 } 20 } 21 22 class Countdown : Progress 23 { 24 this() 25 { 26 this.hide_cursor = true; 27 super(); 28 } 29 30 override void force_update() 31 { 32 this.write(this.remaining.to!string); 33 } 34 } 35 36 class Stack : Progress 37 { 38 string[] phases; 39 this() 40 { 41 this.hide_cursor = true; 42 this.phases = [" ", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]; 43 super(); 44 } 45 46 override void force_update() 47 { 48 size_t nphases = this.phases.length; 49 size_t index = min(nphases - 1, cast(size_t)(this.progress * nphases)); 50 this.write(this.phases[index]); 51 } 52 } 53 54 class Pie : Stack 55 { 56 this() 57 { 58 super(); 59 this.phases = ["○", "◔", "◑", "◕", "●"]; 60 } 61 }