【发布时间】:2014-09-22 04:33:00
【问题描述】:
我正在创建一个使用 VT100 转义序列控制的 Telnet CLI 应用程序。所以例如将光标向左导航
一个例子。光标是“|”。评论用'//'标记
----------------
>potato| // Now I press left arrow which sends esc sequence to application
----------------
>potat|o // Works as expected. The cursor moved left
----------------
另一个例子
----------------
>potatopotatopot // This is a long command which goes over two lines
|ato // Now I press left arrow which sends esc sequence to application
----------------
>potatopotatopot // The cursor didn't move, since the escape sequence
|ato // does nothing if the cursor is at the edge
----------------
我一直在寻找在边缘时会环绕的任何其他转义序列,但没有找到。我还没有找到任何将终端模式更改为允许换行的转义序列。
那么这种终端导航一般是怎么处理的呢?
【问题讨论】:
-
我想 Esc [ Line;ColumnH - “将光标移动到屏幕位置 v,h”(来自 ascii-table.com/ansi-escape-sequences-vt-100 对你很有用。
-
我已经想到了,但这意味着我必须跟踪服务器应用程序中的列号。我想避免这种情况,因为将终端窗口大小更改为 80 以外的任何值都会使客户端输出看起来很奇怪。