@make-u-free/migi 0.4.2 → 0.4.3
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 +6 -1
- package/package.json +1 -1
package/bin/migi.js
CHANGED
|
@@ -87,6 +87,7 @@ async function readChatInput() {
|
|
|
87
87
|
let curLine = 0
|
|
88
88
|
let drawnLines = 0
|
|
89
89
|
let lastLineCount = 0
|
|
90
|
+
let cursorLine = 0 // カーソルが実際にいる物理行(drawn area 先頭からの offset)
|
|
90
91
|
|
|
91
92
|
emitKeypressEvents(process.stdin)
|
|
92
93
|
if (process.stdin.isTTY) process.stdin.setRawMode(true)
|
|
@@ -98,6 +99,7 @@ async function readChatInput() {
|
|
|
98
99
|
if (lines.length === lastLineCount && drawnLines > 0) {
|
|
99
100
|
const prefix = curLine === 0 ? PFIRST : PCONT
|
|
100
101
|
process.stdout.write('\r\x1b[K' + chalk.cyan(prefix) + lines[curLine])
|
|
102
|
+
cursorLine = curLine
|
|
101
103
|
return
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -111,7 +113,9 @@ async function readChatInput() {
|
|
|
111
113
|
|
|
112
114
|
let buf = ''
|
|
113
115
|
if (drawnLines > 0) {
|
|
114
|
-
|
|
116
|
+
// cursorLine = カーソルの現在位置。先頭行まで戻ってから全行クリア
|
|
117
|
+
if (cursorLine > 0) buf += `\x1b[${cursorLine}A`
|
|
118
|
+
buf += `\x1b[1G`
|
|
115
119
|
for (let i = 0; i < drawnLines; i++) buf += '\x1b[2K\n'
|
|
116
120
|
buf += `\x1b[${drawnLines}A\x1b[1G`
|
|
117
121
|
}
|
|
@@ -124,6 +128,7 @@ async function readChatInput() {
|
|
|
124
128
|
const col = (curLine === 0 ? PFIRST : PCONT).length + lines[curLine].length + 1
|
|
125
129
|
buf += `\x1b[${col}G`
|
|
126
130
|
|
|
131
|
+
cursorLine = curLine
|
|
127
132
|
process.stdout.write(buf)
|
|
128
133
|
}
|
|
129
134
|
|