@travetto/terminal
Advanced tools
Comparing version 3.1.0-rc.0 to 3.1.0-rc.1
{ | ||
"name": "@travetto/terminal", | ||
"version": "3.1.0-rc.0", | ||
"version": "3.1.0-rc.1", | ||
"description": "General terminal support", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,4 +8,14 @@ import { IterableUtil } from './iterable'; | ||
/** | ||
* Standard Terminal Operations | ||
*/ | ||
export class TerminalOperation { | ||
static truncateIfNeeded(term: TermState, text: string, suffix = '...'): string { | ||
if (text.length > term.width) { | ||
return `${text.substring(0, term.width - suffix.length)}${suffix}`; | ||
} | ||
return text; | ||
} | ||
/** | ||
@@ -108,3 +118,3 @@ * Allows for writing at top, bottom, or current position while new text is added | ||
.replace(/%pct/, `${Math.trunc(pct * 100)}`); | ||
const full = ` ${line}`.padEnd(term.width); | ||
const full = this.truncateIfNeeded(term, ` ${line}`.padEnd(term.width)); | ||
const mid = Math.trunc(pct * term.width); | ||
@@ -144,3 +154,3 @@ const [l, r] = [full.substring(0, mid), full.substring(mid)]; | ||
pos = await term.getCursorPosition(); | ||
writer = this.streamWaiting(term, msg, { ...cfg, at: pos, clearOnFinish: false }); | ||
writer = this.streamWaiting(term, this.truncateIfNeeded(term, msg), { ...cfg, at: pos, clearOnFinish: false }); | ||
line = msg; | ||
@@ -147,0 +157,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47025
1117