【发布时间】:2012-09-22 05:43:12
【问题描述】:
有没有办法将命令提示符(只是 question 提示符或类似的提示符)固定在终端底部,并使用 Node.js 在其上方记录输出。
一个非常糟糕的例子:
Your favourite food is sushi.
Your favourite food is chicken.
Your favourite food is okra.
--> What is your favourite food?
所以本质上,我希望用户始终能够输入,并在提示上方回显输入。
interface.question("What is your favourite food?", function(answer) {
// output the answer above where this prompt was
// and somehow keep this same prompt where is is
});
我希望在其中使用它的特定应用程序是一个简单的 IRC 客户端,我有一个位置供用户输入,并拥有所有输出(用户输入的内容,以及其他人也输入的内容)在用户输入的地方输出。下图中的线条是虚构的。
----------------------------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| Stuff |
| Stuff |
| Stuff |
----------------------------------------------------------------------
| --> The user can type here |
----------------------------------------------------------------------
【问题讨论】:
-
你找到解决办法了吗?
-
显然不是。所提出的答案都没有解决这个问题。
-
@ThomasDickey 尝试或在评论中说出答案不好的原因。
标签: javascript node.js terminal command-line-interface