📄 termios.c.texi
字号:
#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <termios.h>/* @r{Use this variable to remember original terminal attributes.} */struct termios saved_attributes;void reset_input_mode (void)@{ tcsetattr (STDIN_FILENO, TCSANOW, &saved_attributes);@}void set_input_mode (void)@{ struct termios tattr; char *name; /* @r{Make sure stdin is a terminal.} */ if (!isatty (STDIN_FILENO)) @{ fprintf (stderr, "Not a terminal.\n"); exit (EXIT_FAILURE); @} /* @r{Save the terminal attributes so we can restore them later.} */ tcgetattr (STDIN_FILENO, &saved_attributes); atexit (reset_input_mode);@group /* @r{Set the funny terminal modes.} */ tcgetattr (STDIN_FILENO, &tattr); tattr.c_lflag &= ~(ICANON|ECHO); /* @r{Clear ICANON and ECHO.} */ tattr.c_cc[VMIN] = 1; tattr.c_cc[VTIME] = 0; tcsetattr (STDIN_FILENO, TCSAFLUSH, &tattr);@}@end groupintmain (void)@{ char c; set_input_mode (); while (1) @{ read (STDIN_FILENO, &c, 1); if (c == '\004') /* @r{@kbd{C-d}} */ break; else putchar (c); @} return EXIT_SUCCESS;@}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -