Cygwin BASH 和 ANSI 控制序列

发布于 2024-07-21 07:36:53 字数 151 浏览 6 评论 0原文

这里有几件事:

  1. 任何人都可以向我指出用于解码 ANSI 控制台转义序列的 C 代码吗?
  2. 有没有办法让 Cygwin BASH 模拟一个愚蠢的老 TTY?

也许这应该是两个问题。

谢谢。

Several things here:

  1. Can anyone point me at C code to decode ANSI console escape sequences?
  2. Is there a way to get Cygwin BASH to emulate a dumb old TTY?

Maybe this should be 2 questions.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

懵少女 2024-07-28 07:36:53

这是一个有点间接的答案,但 GNU ncurses 库可以处理各种终端。 找出哪些控制序列适用于 ANSI 终端的一种方法是反编译 ANSI 终端描述:

infocmp ansi

这将为您提供一组 terminfo 属性,curses 程序使用这些属性来在 ANSI 终端上实现效果。 当然,你必须知道这些象形文字的含义。

在 Cygwin 上,我得到:

$ infocmp ansi
#       Reconstructed via infocmp from file: /usr/share/terminfo/61/ansi
ansi|ansi/pc-term compatible with color,
    am, mc5i, mir, msgr,
    colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
    acsc=+\020\,\021\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
    bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
    cr=^M, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
    cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
    cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
    dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
    el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, ht=\E[I, hts=\EH,
    ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J,
    indn=\E[%p1%dS, invis=\E[8m, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
    kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L,
    mc4=\E[4i, mc5=\E[5i, nel=\r\E[S, op=\E[39;49m,
    rep=%p1%c\E[%p2%{1}%-%db, rev=\E[7m, rin=\E[%p1%dT,
    rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m,
    s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B,
    setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
    sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
    sgr0=\E[0;10m, smacs=\E[11m, smpch=\E[11m, smso=\E[7m,
    smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
    u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,

$

'\E' 表示法指的是 ESC 字符。

如果做不到这一点,您可以查找标准本身。

It's a somewhat indirect answer, but the GNU ncurses library handles terminals of all sorts. One way of finding out which control sequences are applicable to ANSI terminals would be to decompile an ANSI terminal description:

infocmp ansi

This would give you the set of terminfo attributes that are used by curses programs to achieve effects on an ANSI terminal. Of course, you then have to know what those hieroglyphs mean.

On Cygwin, I got:

$ infocmp ansi
#       Reconstructed via infocmp from file: /usr/share/terminfo/61/ansi
ansi|ansi/pc-term compatible with color,
    am, mc5i, mir, msgr,
    colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
    acsc=+\020\,\021\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
    bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
    cr=^M, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
    cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
    cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
    dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
    el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, ht=\E[I, hts=\EH,
    ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J,
    indn=\E[%p1%dS, invis=\E[8m, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
    kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L,
    mc4=\E[4i, mc5=\E[5i, nel=\r\E[S, op=\E[39;49m,
    rep=%p1%c\E[%p2%{1}%-%db, rev=\E[7m, rin=\E[%p1%dT,
    rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m,
    s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B,
    setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
    sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
    sgr0=\E[0;10m, smacs=\E[11m, smpch=\E[11m, smso=\E[7m,
    smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
    u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,

$

The '\E' notation refers to the ESC character.

Failing that, you could look up the standard itself.

辞慾 2024-07-28 07:36:53

调整 TERM 环境变量可能会使基于 terminfo/termcap 的应用程序避免使用高级转义序列。 (导出术语=哑)
但我不确定这就是你想要的。

Tweaking the TERM environment variable might make applications based on terminfo/termcap avoid using advanced escape sequences. (export TERM=dumb)
I am not sure that's what you want, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文