[英]Node.js: Prevent cursor wrapping
使用process.stdout.write
,將光標留在輸出字符串的末尾。
但是,當您在終端的右邊框上書寫任何內容時,光標將位於下一行的開頭。
如果您希望通過填充整個終端為應用程序提供背景,則會引起問題,因為它將滾動窗口。
有一種解決方法,在寫入右下角字符插槽后,您可以向后滾動一行,但這似乎不適用於所有平台,即cmd。
從描述中看來,您似乎在談論ansi.js
,后者(如ANSI轉義序列中所述,未在Windows上的標准 答案中 打印為stdout )依賴於libuv
的庫。
該庫實現了適量的轉義序列。 但是,在引用ansi.js的源代碼時 ,它使用轉義 [ S表示向上滾動功能。 該轉義序列不是由libuv
處理的。
libuv
的注釋解釋了以下原因:
* 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
都ansi.js
實現這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.