终端程序清屏和用背景色绘制柱状图

April 28, 2021 | 0 Minute Read

主要使用“ANSI escape codes”


printf("\e[2J"); // ANSI escape codes (Erase in Display)
printf("\e[H");  // ANSI escape codes (Cursor Position 0 0)

printf("\e[42m"); // yellow color 
for (j = 0; j < len; j++) {
  printf(" ");
}
printf("\e[0m\n");
	
printf("\e[?25l"); // ANSI escape codes (make cursor invisible)
printf("\e[?25h"); // ANSI escape codes (make cursor visible)