@@ -40,13 +40,13 @@ final class StepManager with TerminalTools {
40
40
int _loadingStep = 0 ;
41
41
bool isInitialStep = true ;
42
42
final bool _colored;
43
+ int _line_count = 0 ;
43
44
44
45
StepManager (this ._terminal, this ._colored);
45
46
46
47
/// Add new step to the task.
47
48
Future <T > step <T >(String message, {FutureOr <T > Function ()? callback}) {
48
49
if (isInitialStep) {
49
- _terminal.enableRawMode ();
50
50
createSpace (_terminal, 1 );
51
51
_position = readCursorPosition (_terminal);
52
52
isInitialStep = false ;
@@ -81,8 +81,12 @@ final class StepManager with TerminalTools {
81
81
void success (String message) {
82
82
final buffer = StringBuffer ();
83
83
84
+ if (Platform .isWindows) {
85
+ _line_count += 1 ;
86
+ }
87
+
84
88
buffer.writeAnsiAll ([
85
- CursorPosition .moveTo (_position! .$2, _position! .$1),
89
+ CursorPosition .moveTo (_position! .$2 + _line_count , _position! .$1),
86
90
SetStyles (Style .foreground (Color .green)),
87
91
Print ('✔ ' ),
88
92
if (! _colored) SetStyles .reset,
@@ -91,15 +95,18 @@ final class StepManager with TerminalTools {
91
95
92
96
_timer? .cancel ();
93
97
stdout.write (buffer.toString ());
94
- _terminal.disableRawMode ();
95
98
}
96
99
97
100
/// Finishes the task with an error message.
98
101
void warn (String message) {
99
102
final buffer = StringBuffer ();
100
103
104
+ if (Platform .isWindows) {
105
+ _line_count += 1 ;
106
+ }
107
+
101
108
buffer.writeAnsiAll ([
102
- CursorPosition .moveTo (_position! .$2, _position! .$1),
109
+ CursorPosition .moveTo (_position! .$2 + _line_count , _position! .$1),
103
110
SetStyles (Style .foreground (Color .yellow)),
104
111
Print ('⚠ ' ),
105
112
if (! _colored) SetStyles .reset,
@@ -108,15 +115,18 @@ final class StepManager with TerminalTools {
108
115
109
116
_timer? .cancel ();
110
117
stdout.write (buffer.toString ());
111
- _terminal.disableRawMode ();
112
118
}
113
119
114
120
/// Finishes the task with an error message.
115
121
void error (String message) {
116
122
final buffer = StringBuffer ();
117
123
124
+ if (Platform .isWindows) {
125
+ _line_count += 1 ;
126
+ }
127
+
118
128
buffer.writeAnsiAll ([
119
- CursorPosition .moveTo (_position! .$2, _position! .$1),
129
+ CursorPosition .moveTo (_position! .$2 + _line_count , _position! .$1),
120
130
SetStyles (Style .foreground (Color .red)),
121
131
Print ('✘ ' ),
122
132
if (! _colored) SetStyles .reset,
@@ -125,7 +135,6 @@ final class StepManager with TerminalTools {
125
135
126
136
_timer? .cancel ();
127
137
stdout.write (buffer.toString ());
128
- _terminal.disableRawMode ();
129
138
}
130
139
131
140
List <Sequence > _messageSequence (String message) {
0 commit comments