code: drawterm

Download patch

ref: 65d683ba937ab076b094d50266cd159ce11c5387
parent: c38bce1159b6edee799618f49f700ac3616fd2b0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 28 16:07:43 EDT 2016

provide dummy _getch() function for unix, fix mouseinit() crash

--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -11,6 +11,16 @@
 #undef write
 #undef read
 
+#ifndef WINDOWS
+/* get raw character from console without echo */
+static int
+_getch(void)
+{
+	/* TODO */
+	return -1;
+}
+#endif
+
 void	(*consdebug)(void) = 0;
 void	(*screenputs)(char*, int) = 0;
 
@@ -568,6 +578,7 @@
 	}
 }
 
+
 static int
 readcons(Queue *q, char *buf, int n)
 {
@@ -574,10 +585,8 @@
 	while(screenputs==0 && !qcanread(q)){
 		int c;
 
-		if(!isatty(0))
-			return read(0, buf, n);
 		if((c = _getch()) == -1)
-			break;
+			return read(0, buf, n);
 		if(c == '\r')
 			c = '\n';
 		kbdputc(q, c);
--- a/kern/devmouse.c
+++ b/kern/devmouse.c
@@ -47,12 +47,12 @@
 mouseinit(void)
 {
 	cursor = arrow;
-	setcursor();
 }
 
 static Chan*
 mouseattach(char *spec)
 {
+	setcursor();
 	return devattach('m', spec);
 }