@make-u-free/migi 0.4.1 → 0.4.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/bin/migi.js +11 -2
- package/package.json +1 -1
package/bin/migi.js
CHANGED
|
@@ -86,21 +86,30 @@ async function readChatInput() {
|
|
|
86
86
|
const lines = ['']
|
|
87
87
|
let curLine = 0
|
|
88
88
|
let drawnLines = 0
|
|
89
|
+
let lastLineCount = 0
|
|
89
90
|
|
|
90
91
|
emitKeypressEvents(process.stdin)
|
|
91
92
|
if (process.stdin.isTTY) process.stdin.setRawMode(true)
|
|
92
93
|
|
|
93
94
|
function draw() {
|
|
94
95
|
const w = process.stdout.columns || 80
|
|
96
|
+
|
|
97
|
+
// 行数が変わっていない(通常の文字入力)→ 現在行だけ上書き。セパレーター・ガイドは触らない
|
|
98
|
+
if (lines.length === lastLineCount && drawnLines > 0) {
|
|
99
|
+
const prefix = curLine === 0 ? PFIRST : PCONT
|
|
100
|
+
process.stdout.write('\r\x1b[K' + chalk.cyan(prefix) + lines[curLine])
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 行数変化 or 初回 → 全体を再描画
|
|
105
|
+
lastLineCount = lines.length
|
|
95
106
|
const allLines = [
|
|
96
107
|
...lines.map((l, i) => chalk.cyan(i === 0 ? PFIRST : PCONT) + l),
|
|
97
108
|
chalk.dim('─'.repeat(w)),
|
|
98
109
|
chalk.dim(` ✦ ${model} · Shift+Enterで改行 / Enterで送信`)
|
|
99
110
|
]
|
|
100
111
|
|
|
101
|
-
// すべての操作を1つのバッファにまとめてから一括書き込み(ちらつき防止)
|
|
102
112
|
let buf = ''
|
|
103
|
-
|
|
104
113
|
if (drawnLines > 0) {
|
|
105
114
|
buf += `\x1b[${drawnLines}A\x1b[1G`
|
|
106
115
|
for (let i = 0; i < drawnLines; i++) buf += '\x1b[2K\n'
|