ref: fe1f7fac39b177bc4f3b3b8d39034c23be447f4e
parent: d06ed886c61c93037129a6693ab3db07c070f291
author: cinap_lenrek <[email protected]>
date: Wed Oct 3 15:29:18 EDT 2018
move setterm() to kern/posix.c and kern/win32.c (thanks j-xy)
--- a/gui-cocoa/screen.m
+++ b/gui-cocoa/screen.m
@@ -157,11 +157,6 @@
});
}
-void
-setterm(int x)
-{
-}
-
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end
--- a/gui-win32/screen.c
+++ b/gui-win32/screen.c
@@ -673,24 +673,6 @@
}
void
-setterm(int raw)
-{
- DWORD mode;
- HANDLE h;
-
- h = GetStdHandle(STD_INPUT_HANDLE);
- if(!GetConsoleMode(h, &mode))
- return;
- if(raw)
- mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
- else
- mode |= (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
- SetConsoleMode(h, mode);
- FlushConsoleInputBuffer(h);
- _setmode(0, raw? _O_BINARY: _O_TEXT);
-}
-
-void
guimain(void)
{
cpubody();
--- a/gui-x11/x11.c
+++ b/gui-x11/x11.c
@@ -10,8 +10,6 @@
#include <cursor.h>
#include "screen.h"
-#include <termios.h>
-
typedef struct Cursor Cursor;
#undef long
@@ -1185,20 +1183,6 @@
{
_xputsnarf(xsnarfcon, buf);
return 0;
-}
-
-void
-setterm(int raw)
-{
- struct termios t;
-
- if(tcgetattr(0, &t) < 0)
- return;
- if(raw)
- t.c_lflag &= ~(ECHO|ICANON);
- else
- t.c_lflag |= (ECHO|ICANON);
- tcsetattr(0, TCSAFLUSH, &t);
}
void
--- a/kern/posix.c
+++ b/kern/posix.c
@@ -15,6 +15,7 @@
#include <signal.h>
#include <pwd.h>
#include <errno.h>
+#include <termios.h>
#include "lib.h"
#include "dat.h"
@@ -210,4 +211,18 @@
{
error("not implemented");
return -1;
+}
+
+void
+setterm(int raw)
+{
+ struct termios t;
+
+ if(tcgetattr(0, &t) < 0)
+ return;
+ if(raw)
+ t.c_lflag &= ~(ECHO|ICANON);
+ else
+ t.c_lflag |= (ECHO|ICANON);
+ tcsetattr(0, TCSAFLUSH, &t);
}
--- a/kern/win32.c
+++ b/kern/win32.c
@@ -316,3 +316,21 @@
free(cmd);
return n;
}
+
+void
+setterm(int raw)
+{
+ DWORD mode;
+ HANDLE h;
+
+ h = GetStdHandle(STD_INPUT_HANDLE);
+ if(!GetConsoleMode(h, &mode))
+ return;
+ if(raw)
+ mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
+ else
+ mode |= (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
+ SetConsoleMode(h, mode);
+ FlushConsoleInputBuffer(h);
+ _setmode(0, raw? _O_BINARY: _O_TEXT);
+}