export function clearScreen() { process.stdout.write("\x1Bc"); } export function strWidth(str = "") { let width = 0; for (const char of String(str)) { width += char.charCodeAt(0) > 127 ? 2 : 1; } return width; } export function padEnd(str, width) { const value = String(str); return value + " ".repeat(Math.max(0, width - strWidth(value))); } export function centerPad(text, totalWidth) { const pad = Math.max(0, Math.floor((totalWidth - strWidth(text)) / 2)); return " ".repeat(pad); }