在printf()语句中出现的终端代码\033 [E和and033 [07]的含义? [英] Meanings of terminal codes \033[E and \033[07, which appear in printf() statements?

查看:484
本文介绍了在printf()语句中出现的终端代码\033 [E和and033 [07]的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在生命游戏程序的C实现中,如此处所示我提到的代码出现在 show()函数中。我根本找不到有关 033 [E 的意思的任何信息,而对于 \033 [07 通常是linux bash终端中的颜色代码,其中以\033 [07 m 我们开始颜色编码,以\033 [ m 我们结束预定义的颜色编码。但是,根据网站的意思是反向。我不确定这是什么意思。

In the C implementation for the Game of Life program, as shown here the codes I mentioned appear in the show() function. I can't find any information at all about what 033[E means and as for \033[07 this is usually a color code in linux bash terminal, where with \033[07m we begin the color coding and with \033[m we end the predefined color coding. However, according to this website it means "reverse". I'm not sure what that means.

我对 \033 [E 代码更感兴趣,但我找不到任何信息。通过在Linux bash上使用gcc测试和调试程序,我看到没有此命令,输出将不会按预期显示。如果任何人都可以分享有关此方面的知识,我将不胜感激。

I'm more interested though in \033[E code, for which I can find no information. From testing and debugging the program with gcc on Linux bash, I see that without this command, the output is not displayed as intended. If anyone can share knowledge on this, I would appreciate it. Thanks in advance.

推荐答案

序列 ESC [E 是错误–或该来源中的超正确版本。代码为 ESC E ,它用于将光标移至下一行 [表示它可以采用可选的数字参数(或更多),在这种情况下没有参数,因此可以省略。 (一个数字参数表示要跳过多少行; 0 1 会显示常规换行符,而较高的值则表示

The sequence ESC [ E is an error – or possibly, a hypercorrect version – in that source. The code is ESC E, and it serves to move the cursor to the next line. The [ indicates it can take an optional numerical parameter (zero or more), and in this case there are none, so it can be omitted. (A numerical parameter would indicate how many lines to skip; 0 or 1 shows a regular newline, and higher values makes it skip lines.)

很难找到定义,因为通常使用 \n –常规换行代码–在终端程序中将光标移动到下一行的开头。

The definition is hard to find because it's more usual to just use \n – the regular newline code – to move the cursor to the start of the next line in a terminal program.

序列 ESC [07m 还包含一个冗余代码, ESC [7m 足以使终端进入反向模式。您可能习惯将其添加到颜色序列的开头,以便设置文本的前景色(数字 30..37 )代替 background 40..47 ),并使用空格绘制彩色块。

The sequence ESC [07m also contains a redundant code, ESC [7m is enough to put the terminal into Reverse mode. You are probably used to adding this to the start of a color sequence so you can set the foreground color of the text (numbers from 30..37) instead of background (40..47), and use spaces to draw a colored block.

这篇关于在printf()语句中出现的终端代码\033 [E和and033 [07]的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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