VT100转义序列:光标移动环绕到行尾 [英] VT100 escape sequences: Cursor movement wrap around to end of line

查看:168
本文介绍了VT100转义序列:光标移动环绕到行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个由VT100转义序列控制的Telnet CLI应用程序.所以例如在"ESC" [D转义序列从Telnet服务器发送到客户端(可能是Putty或Gnome终端)的左侧,将光标移至左侧.不幸的是,对于比Putty行长更长的行,上面的转义序列将不允许将光标导航到当前行之上的行.

I'm creating a Telnet CLI application that is controlled with VT100 escape sequences. So to e.g. navigate the cursor left the <ESC>[D escape sequence is sent from the Telnet server to the client, which may be Putty or Gnome-terminal. Unfortunately, with lines that are longer than the Putty line length, the escape sequence above will not permit navigating the cursor to the line above the current line.

一个例子.光标为"|".注释标记为"//"

An example. Cursor is '|'. Comments are marked with '//'

----------------
>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
----------------

我一直在寻找在边缘时会回绕的任何其他转义序列,但没有找到.我都没有发现任何将终端模式更改为允许换行的转义序列.

I have been searching for any other escape sequence that would wrap around when at the edge, but found none. I have neither found any escape sequence that changes the terminal mode to something that allows wrapping.

那么通常如何处理这种终端导航?

So how is terminal navigation like this commonly handled?

推荐答案

termcap终端描述中的bw功能说明是否在屏幕边缘向左移动会绕到上一行.在我检查过的PuTTy说明中(在ncurses下为infocmp putty),但在其他很多情况下(例如,不在infocmp gnome中).

The bw capability in a termcap terminal description says whether moving left at the edge of a screen wraps to the previous line. It was present in a PuTTy description I checked (infocmp putty under ncurses), but not in many others (e.g. not in infocmp gnome).

您可以尝试跟踪光标在哪一列中,并在需要环绕到上一行时使用移动控制序列.您必须知道用户屏幕的宽度,这可以通过他们设置LINESCOLS环境变量来完成.

You could try to keep track of which column the cursor is in and use movement control sequences when you want to wrap round to the previous line. You would have to know the width of the user's screen, which can be done by them setting the LINES and COLS environmental variables.

这篇关于VT100转义序列:光标移动环绕到行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆