发信人: daviddvd (置于死地而后生), 信区: ANSI
标 题: 关于简化代码
发信站: 日月光华 (2007年08月07日17:58:55 星期二), 站内信件
现在有几种不同的答案:
1: *[1;4;5;45;31mA*[0m*[45;32mB*[42;32mC*[0m
2: *[1;4;5;45;31mA*[0m*[45;32mB*[0m*[42;32mC*[0m
3: *[1;4;5;31;45mA*[0m*[45;32mB*[0m*[42;32mC*[0m
4: *[1;4;5;33;45;31mA*[0m*[44;45;32mB*[0m*[42;32mC*[0m
5: *[1;4;5;45;31mA*[0;45;32mB*[0;42;32mC*[0m
4出现了一些无意义的代码,比如31前的33,45前的44
其余几个在A的处理上没有什么问题
而在B的处理上
出现了两种*[0;45;32m和
*[0m*[45;32m
这两种处理相差两个字节,应该说在一般的情况下是没有设么问题的,都可以达到正确
的显示效果,但是在某些情况下,需要简短的代码情况下,……
而C的处理,由于前面B的前景和背景分别是32和45,而C的前景也是32,在最简短的要求
下,只用*[45m即可达到同样的效果
*[m和*[0m的差别在于*[m是恢复term默认的效果,而*[0m是恢复低亮,和*[1m相对
在默认高亮的情况下二者会有差别
--
※ 来源:·日月光华 bbs.fudan.edu.cn·[FROM: Astronomy版]
Sender: daviddvd put himself to death and live again, message area: ANSI
Title: About simplifying code
Sending site: Sun and Moon Guanghua Tuesday, August 07, 2007 17:58:55, site mail
Now there are several different answers
1: *[1;4;5;45;31mA*[0m*[45;32mB*[42;32mC*[0m
2: *[1;4;5;45;31mA*[0m*[45;32mB*[0m*[42;32mC*[0m
3: *[1;4;5;31;45mA*[0m*[45;32mB*[0m*[42;32mC*[0m
4: *[1;4;5;33;45;31mA*[0m*[44;45;32mB*[0m*[42;32mC*[0m
5: *[1;4;5;45;31mA*[0;45;32mB*[0;42;32mC*[0m
4 There are some meaningless codes, such as 33 before 31 and 44 before 45.
The remaining ones have no problem in handling A.
And in the processing of B
There are two kinds of *[0;45;32m and
*[0m*[45;32m
The difference between these two processes is two bytes. It should be said that under normal circumstances there is no problem and both can be correct.
display effect, but in some cases, short code is required
As for the processing of C, since the foreground and background of B are 32 and 45 respectively, and the foreground of C is also 32, in the shortest requirement
Next, only use *[45m to achieve the same effect
The difference between *[m and *[0m is that *[m restores the default effect of term, while *[0m restores low brightness, which is opposite to *[1m
In the case of default highlighting, there will be a difference between the two.
Source: Sun and Moon Guanghua bbs.fudan.edu.cn [FROM Astronomy version]