TERM=哑终端必须具备的功能

ana*_*nik 8 linux shell terminal go

我期待实现远程客户端它通过连接到Linuxnc和开始bash。所以我需要告诉bash我可以从stdout它发送给我的 中解析哪些功能,以及我将如何向它发送键码和其他东西stdin,以便它也可以解析它们。

这是通过TERM=something环境变量完成的,我需要将其设置为某个值。如果我不设置它,那么各种程序开始抱怨:

$ mc
The TERM environment variable is unset!
Run Code Online (Sandbox Code Playgroud)

我发现我可以设置 TERMdumb来表示我的客户真的很有限。而且似乎我还是错过了一些东西。

$ export TERM=dumb
$ mc
Your terminal lacks the ability to clear the screen or position the cursor.
Run Code Online (Sandbox Code Playgroud)

从这里看dumb终端似乎没有这两个能力,但它还有什么能力呢?是否有关于它的规范或一些事实上的标准?

Tho*_*key 8

去源头会有所帮助。终端数据库有评论。这是其中的一部分

#### Specials
#
# Special "terminals".  These are used to label tty lines when you don't
# know what kind of terminal is on it.  The characteristics of an unknown
# terminal are the lowest common denominator - they look about like a ti 700.
#

dumb|80-column dumb tty,
        am,
        cols#80,
        bel=^G, cr=^M, cud1=^J, ind=^J,
unknown|unknown terminal type,
        gn, use=dumb,
Run Code Online (Sandbox Code Playgroud)

假设“哑”和“未知”终端类型,但很少使用:

  • “dumb”有自动边距(文本在右边距处“换行”),假定有 80 列,以及一个 ASCII BEL 和回车。由于缺少更好的东西,cud1(光标向下)是一个 ASCII 换行符。该ind(指数)值是相同的,这意味着文本滚动,当你到达屏幕的底部了。

    没有游标寻址 ( cup) 或替代(例如任意沿行或列移动)。

  • “unknown”添加了“generic”标志,将其标记为不适合用于curses 应用程序。把它想象成一台打印机。

至于最低要求,这实际上取决于个别应用程序。ncurses 可以设法在屏幕上移动而实际上没有cup. 它适用于六种策略。如果您阅读 的源代码mvcur,您可以了解它需要什么。

但是,诸如此类的应用程序mc并不仅仅依赖于 ncurses 来决定它是否有效,因为(在这种情况下)它可能与俚语相关联(它不会仔细检查)。所以,mc做自己的检查,这可能会增加限制。

在实践中,除非您选择“哑”等有限的终端描述,否则您可能遇到的大多数终端都可以工作。

进一步阅读:


fvu*_*fvu 6

您最好的信息来源是 terminfo 条目,可以使用infocmp工具轻松查看:

infocmp dumb
#       Reconstructed via infocmp from file: /lib/terminfo/d/dumb
dumb|80-column dumb tty,
        am,
        cols#80,
        bel=^G, cr=^M, cud1=^J, ind=^J,
Run Code Online (Sandbox Code Playgroud)

这很明显,哑终端非常有限......