⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getch.c

📁 一个实现基本功能的shell命令解释器
💻 C
字号:
#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <termios.h>#include <fcntl.h>int getch(void){	struct termios tm, tm_old;	int fd = STDIN_FILENO;	char c;	if(tcgetattr(fd, &tm) < 0)		printf("error!\n");	if(tcgetattr(fd, &tm_old) < 0)		printf("error!\n");	cfmakeraw(&tm);	if(tcsetattr(fd, TCSANOW, &tm) < 0)		printf("error!\n");	c = fgetc(stdin);	if(tcsetattr(fd, TCSANOW, &tm_old) < 0)		printf("error!\n");	if(c == 0x38 || c == 0x32)	{		if(c == 0x38)		{			return -2;		}		else		{			return -1;		}	}	else	{		return c;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -