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

📄 ttyin.c

📁 早期freebsd实现
💻 C
字号:
/* * Routines dealing with getting input from the keyboard (i.e. from the user). */#include "less.h"#if __MSDOS__#include <io.h>#include <stdio.h>#include <fcntl.h>#include <signal.h>#endifstatic int tty;/* * Open keyboard for input. */	public voidopen_getchr(){#if __MDDOS__	/*	 * Open a new handle to CON: in binary mode 	 * for unbuffered keyboard read.	 */	tty = open("CON", O_RDONLY|O_BINARY);#else	/*	 * Try /dev/tty.	 * If that doesn't work, use file descriptor 2,	 * which in Unix is usually attached to the screen,	 * but also usually lets you read from the keyboard.	 */	tty = open("/dev/tty", 0);	if (tty < 0)		tty = 2;#endif}/* * Get a character from the keyboard. */	public intgetchr(){	char c;	int result;	do	{		result = iread(tty, &c, sizeof(char));		if (result == READ_INTR)			return (READ_INTR);		if (result < 0)		{			/*			 * Don't call error() here,			 * because error calls getchr!			 */			quit(1);		}#if __MSDOS__		/*		 * In raw read, we don't see ^C so look here for it.		 */		if (c == '\003')			raise(SIGINT);#endif		/*		 * Various parts of the program cannot handle		 * an input character of '\0'.		 * If a '\0' was actually typed, convert it to '\200' here.		 */		if (c == '\0')			c = '\200';	} while (result != 1);	return (c);}

⌨️ 快捷键说明

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