secrez 2.2.0-beta.2 → 2.2.0-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "2.2.0-beta.2",
3
+ "version": "2.2.0-beta.3",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
@@ -15,6 +15,14 @@ const insert = (s, x, c) => s.slice(0, x) + c + s.slice(x);
15
15
  const EDITOR_STATUS =
16
16
  "Ctrl-d save · Ctrl-c abort · Ctrl-k del line · Ctrl-a home · Ctrl-e end · Ctrl-g reset";
17
17
 
18
+ // ansi-escapes `clearScreen` is RIS (\u001bc). Terminal.app answers that
19
+ // reset with a blue background and a foreground that does not contrast, so
20
+ // the file text is drawn and then invisible. Erase the viewport, home the
21
+ // cursor, and restore the default colors before painting the buffer.
22
+ function clearViewport() {
23
+ return "\u001b[0m" + esc.eraseScreen + esc.cursorTo(0, 0);
24
+ }
25
+
18
26
  function terminalRows() {
19
27
  return process.stdout.rows || 24;
20
28
  }
@@ -55,7 +63,7 @@ const Editor = {
55
63
  abort(c) {
56
64
  this.done = true;
57
65
  this.aborted = !(c.ctrl && c.name === "d");
58
- this.out.write(esc.clearScreen + esc.cursorTo(0, 0));
66
+ this.out.write(clearViewport());
59
67
  this.close();
60
68
  },
61
69
 
@@ -176,16 +184,11 @@ const Editor = {
176
184
  },
177
185
 
178
186
  render() {
179
- if (this.firstRender) {
180
- this.firstRender = false;
181
- this.out.write("\n".repeat(terminalRows()));
182
- }
183
-
184
187
  const rows = terminalRows();
185
188
  const statusRow = Math.max(0, rows - 1);
186
189
  const { lines, cursorX, cursorY } = this;
187
190
  this.out.write(
188
- esc.clearScreen +
191
+ clearViewport() +
189
192
  lines.join("\n") +
190
193
  esc.cursorTo(0, statusRow) +
191
194
  "\x1b[2m" +
@@ -207,7 +210,6 @@ function createEditor(text) {
207
210
  initialLines: [],
208
211
  cursorX: 0,
209
212
  cursorY: 0,
210
- firstRender: true,
211
213
  done: false,
212
214
  aborted: false,
213
215
  value: "",