@retrovm/terminal 0.1.1 → 0.1.2

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/dist/node.js CHANGED
@@ -341,9 +341,12 @@ class TerminalCore {
341
341
  const color = typeof c === "string" ? new Color(c) : c;
342
342
  return this.style(color.toAnsiBackgroundRGB(), fmt, args);
343
343
  }
344
- reset(fmt = "", ...args) {
344
+ resetText(fmt = "", ...args) {
345
345
  return this.style("\x1B[0m", fmt, args);
346
346
  }
347
+ reset(fmt = "", ...args) {
348
+ return this.cursor(true).alt(false).style("\x1B[0m", fmt, args);
349
+ }
347
350
  resetInk(fmt = "", ...args) {
348
351
  return this.style("\x1B[39m", fmt, args);
349
352
  }
@@ -56,7 +56,24 @@ declare class TerminalCore {
56
56
  ink(c: string | Color, fmt?: string, ...args: unknown[]): this;
57
57
  /** Sets the background color and optionally writes formatted text. */
58
58
  paper(c: string | Color, fmt?: string, ...args: unknown[]): this;
59
- /** Resets all attributes (color, background, intensity, …). */
59
+ /**
60
+ * Resets all text attributes (color, background, bold, dim, italic,
61
+ * underline, blink, reverse, …) by emitting `\x1b[0m`.
62
+ *
63
+ * Unlike {@link reset}, this does **not** touch the cursor visibility
64
+ * or the alternate screen buffer.
65
+ */
66
+ resetText(fmt?: string, ...args: unknown[]): this;
67
+ /**
68
+ * Fully resets the terminal to a clean state.
69
+ *
70
+ * In order:
71
+ * 1. Shows the cursor (`cursor(true)`)
72
+ * 2. Exits the alternate screen buffer (`alt(false)`)
73
+ * 3. Resets all text attributes — color, background, intensity, etc. (`\x1b[0m`)
74
+ *
75
+ * Safe to call as a teardown step after any TUI or interactive session.
76
+ */
60
77
  reset(fmt?: string, ...args: unknown[]): this;
61
78
  /** Resets only the foreground color. */
62
79
  resetInk(fmt?: string, ...args: unknown[]): this;
package/dist/terminal.js CHANGED
@@ -341,9 +341,12 @@ class TerminalCore {
341
341
  const color = typeof c === "string" ? new Color(c) : c;
342
342
  return this.style(color.toAnsiBackgroundRGB(), fmt, args);
343
343
  }
344
- reset(fmt = "", ...args) {
344
+ resetText(fmt = "", ...args) {
345
345
  return this.style("\x1B[0m", fmt, args);
346
346
  }
347
+ reset(fmt = "", ...args) {
348
+ return this.cursor(true).alt(false).style("\x1B[0m", fmt, args);
349
+ }
347
350
  resetInk(fmt = "", ...args) {
348
351
  return this.style("\x1B[39m", fmt, args);
349
352
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrovm/terminal",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Fluent ANSI terminal library — 24-bit color, cursor control and screen management for Bun and Node.js",
5
5
  "author": "Juan Carlos González Amestoy",
6
6
  "license": "MIT",
package/src/terminal.ts CHANGED
@@ -116,11 +116,31 @@ class TerminalCore {
116
116
  return this.style(color.toAnsiBackgroundRGB(), fmt, args)
117
117
  }
118
118
 
119
- /** Resets all attributes (color, background, intensity, …). */
120
- reset(fmt: string = '', ...args: unknown[]): this {
119
+ /**
120
+ * Resets all text attributes (color, background, bold, dim, italic,
121
+ * underline, blink, reverse, …) by emitting `\x1b[0m`.
122
+ *
123
+ * Unlike {@link reset}, this does **not** touch the cursor visibility
124
+ * or the alternate screen buffer.
125
+ */
126
+ resetText(fmt: string = '', ...args: unknown[]): this {
121
127
  return this.style('\x1b[0m', fmt, args)
122
128
  }
123
129
 
130
+ /**
131
+ * Fully resets the terminal to a clean state.
132
+ *
133
+ * In order:
134
+ * 1. Shows the cursor (`cursor(true)`)
135
+ * 2. Exits the alternate screen buffer (`alt(false)`)
136
+ * 3. Resets all text attributes — color, background, intensity, etc. (`\x1b[0m`)
137
+ *
138
+ * Safe to call as a teardown step after any TUI or interactive session.
139
+ */
140
+ reset(fmt: string = '', ...args: unknown[]): this {
141
+ return this.cursor(true).alt(false).style('\x1b[0m', fmt, args)
142
+ }
143
+
124
144
  /** Resets only the foreground color. */
125
145
  resetInk(fmt: string = '', ...args: unknown[]): this {
126
146
  return this.style('\x1b[39m', fmt, args)