flanders 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,8 +74,9 @@ export declare class BottomBlock {
74
74
  private _scheduleAnimTick;
75
75
  private _scheduleLabelTick;
76
76
  private _scheduleCountdownTick;
77
- private _clearBlock;
78
- private _drawBlock;
77
+ private _redraw;
78
+ private _clearString;
79
+ private _drawString;
79
80
  private _renderHeader;
80
81
  private _renderMetrics;
81
82
  private _resolvePair;
@@ -44,10 +44,9 @@ class BottomBlock {
44
44
  this._workingLabel = (0, voiceVariants_1.pickVariant)(voiceVariants_1.workingPool, this._random);
45
45
  }
46
46
  this._unsubResize = this._io.onResize(() => {
47
- this._clearBlock();
48
- this._drawBlock();
47
+ this._redraw();
49
48
  });
50
- this._drawBlock();
49
+ this._redraw();
51
50
  this._startFooterTimer();
52
51
  }
53
52
  isFinalized() {
@@ -58,8 +57,7 @@ class BottomBlock {
58
57
  return;
59
58
  this._header = fields;
60
59
  if (this._mounted) {
61
- this._clearBlock();
62
- this._drawBlock();
60
+ this._redraw();
63
61
  }
64
62
  }
65
63
  setMetrics(fields) {
@@ -68,8 +66,7 @@ class BottomBlock {
68
66
  this._metrics = fields;
69
67
  this._metricsPauseAccumMs = 0;
70
68
  if (this._mounted) {
71
- this._clearBlock();
72
- this._drawBlock();
69
+ this._redraw();
73
70
  }
74
71
  }
75
72
  setFooter(state) {
@@ -95,8 +92,7 @@ class BottomBlock {
95
92
  this._animFrame = 0;
96
93
  }
97
94
  if (this._mounted) {
98
- this._clearBlock();
99
- this._drawBlock();
95
+ this._redraw();
100
96
  this._startFooterTimer();
101
97
  }
102
98
  }
@@ -107,9 +103,7 @@ class BottomBlock {
107
103
  this._io.write(text);
108
104
  return;
109
105
  }
110
- this._clearBlock();
111
- this._io.write(text);
112
- this._drawBlock();
106
+ this._redraw(text);
113
107
  }
114
108
  finalize(label) {
115
109
  if (this._disposed)
@@ -124,9 +118,7 @@ class BottomBlock {
124
118
  this._unsubResize = null;
125
119
  }
126
120
  if (this._mounted) {
127
- this._clearBlock();
128
- this._drawBlock();
129
- this._io.write("\n");
121
+ this._redraw("", "\n");
130
122
  }
131
123
  }
132
124
  dispose() {
@@ -176,8 +168,7 @@ class BottomBlock {
176
168
  if (this._disposed || this._finalized || (this._footer.kind !== "working" && this._footer.kind !== "reviewing"))
177
169
  return;
178
170
  this._animFrame = (this._animFrame + 1) % FRAMES.length;
179
- this._clearBlock();
180
- this._drawBlock();
171
+ this._redraw();
181
172
  this._scheduleAnimTick();
182
173
  }, FRAME_MS);
183
174
  }
@@ -187,8 +178,7 @@ class BottomBlock {
187
178
  if (this._disposed || this._finalized || this._footer.kind !== "working")
188
179
  return;
189
180
  this._workingLabel = (0, voiceVariants_1.pickVariant)(voiceVariants_1.workingPool, this._random, this._workingLabel);
190
- this._clearBlock();
191
- this._drawBlock();
181
+ this._redraw();
192
182
  this._scheduleLabelTick();
193
183
  }, LABEL_MS);
194
184
  }
@@ -197,14 +187,16 @@ class BottomBlock {
197
187
  this._countdownTimer = null;
198
188
  if (this._disposed || this._finalized || this._footer.kind !== "waiting")
199
189
  return;
200
- this._clearBlock();
201
- this._drawBlock();
190
+ this._redraw();
202
191
  this._scheduleCountdownTick();
203
192
  }, 1000);
204
193
  }
205
- _clearBlock() {
194
+ _redraw(aboveText = "", suffix = "") {
195
+ this._io.write(this._clearString() + aboveText + this._drawString() + suffix);
196
+ }
197
+ _clearString() {
206
198
  if (!this._prevLineWidths)
207
- return;
199
+ return "";
208
200
  const cols = Math.max(1, this._io.columns());
209
201
  let rows = 0;
210
202
  for (const w of this._prevLineWidths) {
@@ -214,16 +206,16 @@ class BottomBlock {
214
206
  if (rows > 4) {
215
207
  clear += `\x1b[${rows - 4}B`;
216
208
  }
217
- this._io.write(clear);
209
+ return clear;
218
210
  }
219
- _drawBlock() {
211
+ _drawString() {
220
212
  const cols = Math.max(0, this._io.columns());
221
213
  const separator = formatters_1.SEPARATOR_GLYPH.repeat(cols);
222
214
  const header = this._renderHeader(cols);
223
215
  const metrics = this._renderMetrics(cols);
224
216
  const footer = this._renderFooter(cols);
225
- this._io.write(AUTOWRAP_OFF + separator + "\n" + header + "\n" + metrics + "\n" + footer + AUTOWRAP_ON);
226
217
  this._prevLineWidths = [cols, (0, formatters_1.stripAnsi)(header).length, (0, formatters_1.stripAnsi)(metrics).length, (0, formatters_1.stripAnsi)(footer).length];
218
+ return AUTOWRAP_OFF + separator + "\n" + header + "\n" + metrics + "\n" + footer + AUTOWRAP_ON;
227
219
  }
228
220
  _renderHeader(cols) {
229
221
  var _a, _b, _c, _d, _e, _f;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flanders",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Flanders never breaks a rule",
5
5
  "main": "lib/",
6
6
  "types": "lib/types",