64 lines · 982 B · C
RawDownload
/* * Terminal support (standard input/output). */ #include	"u.h"#include	<termios.h>#include	<sys/termios.h>#include	"lib.h"#include	"mem.h"#include	"dat.h"#include	"fns.h"#include	"error.h" static int ttyprint = 0;static int ttyecho = 0; /* * Normal prints and console output go to standard output. */voiduartputs(char *buf, int n){	if(!ttyprint)		return;	write(1, buf, n);} voiduartreader(void *v){	char buf[256];	int n;	static struct termios ttmode;		/*	 * Try to disable host echo. 	 * If successful, remember to echo	 * what gets typed ourselves.	 */	if(tcgetattr(0, &ttmode) >= 0){		ttmode.c_lflag &= ~(ECHO|ICANON);		if(tcsetattr(0, TCSANOW, &ttmode) >= 0)			ttyecho = 1;	}	while((n = read(0, buf, sizeof buf)) > 0)		echo(buf, n);} voiduartinit(int usetty){	ttyprint = usetty;	kbdq = qopen(4*1024, 0, 0, 0);	if(usetty)		kproc("*tty*", uartreader, nil);} voiduartecho(char *buf, int n){	if(ttyecho)		write(1, buf, n);} 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t