linux output terminal c language font color change

Linux under the C to change the font color output

Example:

#include

int main ()

{

    printf("\033[31mThis is RED.\n\033[0m");

    return 0;

}

31m on behalf of the font is red, 0m close all property represents.


Commonly used ANSI control codes are as follows (some do not):

\ 033 [0m close all properties 

\ 033 [1m Highlight

\ 033 [2m luminance half

\ 033 [3m italic

\ 033 [4m underscore 

\ 033 [5m flashes 

\ 033 [6m flash

\ 033 [7m black reverse 

\ 033 [8m blanking 

\ 033 [9m middle of a horizontal line

10-19 about fonts

21-29 substantially 1-9 opposite

30-37 Set the foreground color

40-47 Set the background color

30: Black

31: Red

32: Green

33: Yellow

34: Blue

35: Purple

36: dark green

37: White

38 Open underline , set the default foreground color 

39 closed underline , set the default foreground color 

40 black background 

41 red background 

42 green background 

43 brown background 

44 blue background 

45 magenta background 

46 peacock blue background 

47 white background 

48 do not know what

49 Set the default background color

50-89 useless

90-109 is set foreground background, the color of light than before

\ 033 [nA the cursor n rows 

\ 033 [nB cursor down n rows 

\ 033 [nC cursor right n rows 

\033[nD 光标左移n行 

\033[y;xH设置光标位置 

\033[2J 清屏 

\033[K 清除从光标到行尾的内容 

\033[s 保存光标位置 

\033[u 恢复光标位置 

\033[?25l 隐藏光标 

\033[?25h 显示光标


Guess you like

Origin www.cnblogs.com/lttdxuexizhilu/p/11609389.html