我有一个设置为 ~(ICANON) 模式的终端,我想知道如何将我获得的数据用于退格(这是 ^?)所以我可以发送一个 putchar('\b') 到控制台去退一格。
编辑:
struct termios new;
newt.c_lflag &= ~(ICANON);
tcsetattr(STDIN_FILENO, TCSANOW, &newt); // Set the console to send each char straight away.
char c;
while ((c = getchar()) != '\n){
// If the backspace key is pressed, the symbols ^? appear on the screen. How do I
// Interpret the backspace to send back a '\b' char to the screen. I don't want the ^?
// to appear on the screen when the backspace is pressed but rather the cursor move one
// space to the left.
}
谢谢