Discovering remote Terminal for Terminal Escape Codes? (DECDHL in this case)

本小妞迷上赌 提交于 2020-01-06 16:20:58

问题


I am trying to determine WHAT console I am running in. (Exceptionally hard based on the research I have done so far.) The latest feature that I discovered that would be useful is Double High, Double Wide for a couple of scenarios.

The setup is a Kubuntu 15.04 machine with native (lower) and remote access via Terminal.app on OS X 10.10.4.

Based on vt100.net Apple is doing the right thing.

#!/bin/bash

# Cool effect with OS X Terminal.app
# Not as much on others (Like Konsole)
function embiggen()
{
    # Yellow (Darker) foreground
    #                 |       Black backround
    #                 |             |
    printf "\x1b[38;5;226m\x1b[48;5;0m"

    #  Double high 'top anchor'
    #            |       line down
    #            |       |     Start of line
    #            |       |     |
    printf "\x1b#3$1\x1b[B\x1b[G"

    # Yellow (Bright) foreground
    #                 |         Red background
    #                 |    (Bright) |
    printf "\x1b[38;5;229m\x1b[48;5;196m"

    #  Double high 'bottom anchor'
    #            |       line down
    #            |       |     Start of line
    #            |       |     |
    printf "\x1b#4$1\x1b[B\x1b[G\n\n"
}

clear
embiggen "Hello, World"

With Konsole

With Konsole the rendering seems to be controlled from bottom to top. i.e. each line is drawn bottom to top basically topmost line wins. However, repaints are less than predictable.

Is it remotely possible to use some of the extended features in a reasonably gracefully degraded way when the terminal doesn't support extended formating?

Best 'solution' I have thought of is using a custom entry point with ssh -i ... usr@svr.dom bash --init-file osx_remote -i


回答1:


The short answer, is "no" - this is not possible using just escape sequences.

  • You cannot tell whether the terminal actually displays double-sized characters. Using the cursor-position report, you can tell (except for buggy implementations) if the terminal used two cells on the screen to represent a double-width character. xterm did that long ago; other terminals do that.
  • Double-sized characters are a VT100 feature, so they are not listed in a device attributes response either. That would be of limited use, since some terminal emulator developers simply cut/paste responses to make them satisfy applications which check for specific features.

If you were running locally (rather than via ssh), conceivably you could write a program which did an X Window dump and analyzed that picture.



来源:https://stackoverflow.com/questions/32019235/discovering-remote-terminal-for-terminal-escape-codes-decdhl-in-this-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!