@make-u-free/migi 0.4.0 → 0.4.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.
- package/bin/migi.js +15 -15
- package/package.json +1 -1
package/bin/migi.js
CHANGED
|
@@ -92,30 +92,30 @@ async function readChatInput() {
|
|
|
92
92
|
|
|
93
93
|
function draw() {
|
|
94
94
|
const w = process.stdout.columns || 80
|
|
95
|
-
|
|
96
|
-
// 前回描画分をクリア
|
|
97
|
-
if (drawnLines > 0) {
|
|
98
|
-
process.stdout.write(`\x1b[${drawnLines}A\x1b[1G`)
|
|
99
|
-
for (let i = 0; i < drawnLines; i++) {
|
|
100
|
-
process.stdout.write('\x1b[2K\n')
|
|
101
|
-
}
|
|
102
|
-
process.stdout.write(`\x1b[${drawnLines}A\x1b[1G`)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// 入力行 + セパレーター + ガイド を描画
|
|
106
95
|
const allLines = [
|
|
107
96
|
...lines.map((l, i) => chalk.cyan(i === 0 ? PFIRST : PCONT) + l),
|
|
108
97
|
chalk.dim('─'.repeat(w)),
|
|
109
98
|
chalk.dim(` ✦ ${model} · Shift+Enterで改行 / Enterで送信`)
|
|
110
99
|
]
|
|
100
|
+
|
|
101
|
+
// すべての操作を1つのバッファにまとめてから一括書き込み(ちらつき防止)
|
|
102
|
+
let buf = ''
|
|
103
|
+
|
|
104
|
+
if (drawnLines > 0) {
|
|
105
|
+
buf += `\x1b[${drawnLines}A\x1b[1G`
|
|
106
|
+
for (let i = 0; i < drawnLines; i++) buf += '\x1b[2K\n'
|
|
107
|
+
buf += `\x1b[${drawnLines}A\x1b[1G`
|
|
108
|
+
}
|
|
109
|
+
|
|
111
110
|
drawnLines = allLines.length
|
|
112
|
-
|
|
111
|
+
buf += allLines.join('\n') + '\n'
|
|
113
112
|
|
|
114
|
-
// カーソルを入力行の末尾に移動
|
|
115
113
|
const linesBelow = drawnLines - curLine
|
|
116
|
-
if (linesBelow > 0)
|
|
114
|
+
if (linesBelow > 0) buf += `\x1b[${linesBelow}A`
|
|
117
115
|
const col = (curLine === 0 ? PFIRST : PCONT).length + lines[curLine].length + 1
|
|
118
|
-
|
|
116
|
+
buf += `\x1b[${col}G`
|
|
117
|
+
|
|
118
|
+
process.stdout.write(buf)
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
draw()
|