Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Node.js:防止光标环绕_Javascript_Node.js_Terminal_Newline_Ansi - Fatal编程技术网

Javascript Node.js:防止光标环绕

Javascript Node.js:防止光标环绕,javascript,node.js,terminal,newline,ansi,Javascript,Node.js,Terminal,Newline,Ansi,使用process.stdout.write,光标将留在输出的字符串末尾。 但是,当您在终端的右边框上写入任何内容时,光标将放置在下一行的开头 如果您希望通过填充整个终端为应用程序提供背景,这会导致出现问题,因为它会滚动窗口 有一种解决方法,您可以在写入右下角字符槽后向上滚动一行,但这似乎并不适用于所有平台,即cmd。从描述中可以看出,它(如中所述)依赖于库,例如 该库实现了适量的转义序列。但对于,它使用escape[S]作为向上滚动功能。该escape序列不是由libuv处理的 libuv中的

使用
process.stdout.write
,光标将留在输出的字符串末尾。
但是,当您在终端的右边框上写入任何内容时,光标将放置在下一行的开头

如果您希望通过填充整个终端为应用程序提供背景,这会导致出现问题,因为它会滚动窗口


有一种解决方法,您可以在写入右下角字符槽后向上滚动一行,但这似乎并不适用于所有平台,即cmd。

从描述中可以看出,它(如中所述)依赖于库,例如

该库实现了适量的转义序列。但对于,它使用escape[S]作为向上滚动功能。该escape序列不是由
libuv
处理的

libuv
中的A解释了以下原因:

 * Normally cursor movement in windows is relative to the console screen buffer,
 * e.g. the application is allowed to overwrite the 'history'. This is very
 * inconvenient, it makes absolute cursor movement pretty useless. There is
 * also the concept of 'client rect' which is defined by the actual size of
 * the console window and the scroll position of the screen buffer, but it's
 * very volatile because it changes when the user scrolls.
在curses应用程序中,这类操作是通过在下一列的右下角写入字符,然后使用插入字符将其放置到位来完成的。但是无论是
ansi.js
还是
libuv
都无法实现这一点