History

move setterm() to kern/posix.c and kern/win32.c (thanks j-xy)

cinap_lenrek committed 8 years ago

Commit fe1f7fa1 parent d06ed885 files · +33 −39Browse files

Unified · Split

5 files
  1. gui-cocoa/screen.m +0 −5
  2. gui-win32/screen.c +0 −18
  3. gui-x11/x11.c +0 −16
  4. kern/posix.c +15 −0
  5. kern/win32.c +18 −0
gui-cocoa/screen.m+0−5
@@ -157,11 +157,6 @@ mouseset(Point p) · 156 unmodified lines
157 });157 });
158}158}
159 159
160void
161setterm(int x)
162{
163}
164
165@interface AppDelegate : NSObject <NSApplicationDelegate>160@interface AppDelegate : NSObject <NSApplicationDelegate>
166@end161@end
167 162
gui-win32/screen.c+0−18
@@ -672,24 +672,6 @@ clipwrite(char *buf) · 671 unmodified lines
672 return n;672 return n;
673}673}
674 674
675void
676setterm(int raw)
677{
678 DWORD mode;
679 HANDLE h;
680
681 h = GetStdHandle(STD_INPUT_HANDLE);
682 if(!GetConsoleMode(h, &mode))
683 return;
684 if(raw)
685 mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
686 else
687 mode |= (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
688 SetConsoleMode(h, mode);
689 FlushConsoleInputBuffer(h);
690 _setmode(0, raw? _O_BINARY: _O_TEXT);
691}
692
693void675void
694guimain(void)676guimain(void)
695{677{
gui-x11/x11.c+0−16
@@ -10,8 +10,6 @@ · 9 unmodified lines
10#include <cursor.h>10#include <cursor.h>
11#include "screen.h"11#include "screen.h"
12 12
13#include <termios.h>
14
15typedef struct Cursor Cursor;13typedef struct Cursor Cursor;
16 14
17#undef long15#undef long
@@ -1187,20 +1185,6 @@ clipwrite(char *buf) · 1169 unmodified lines
1187 return 0;1185 return 0;
1188}1186}
1189 1187
1190void
1191setterm(int raw)
1192{
1193 struct termios t;
1194
1195 if(tcgetattr(0, &t) < 0)
1196 return;
1197 if(raw)
1198 t.c_lflag &= ~(ECHO|ICANON);
1199 else
1200 t.c_lflag |= (ECHO|ICANON);
1201 tcsetattr(0, TCSAFLUSH, &t);
1202}
1203
1204void1188void
1205guimain(void)1189guimain(void)
1206{1190{
kern/posix.c+15−0
@@ -15,6 +15,7 @@ · 14 unmodified lines
15#include <signal.h>15#include <signal.h>
16#include <pwd.h>16#include <pwd.h>
17#include <errno.h>17#include <errno.h>
18#include <termios.h>
18 19
19#include "lib.h"20#include "lib.h"
20#include "dat.h"21#include "dat.h"
@@ -211,3 +212,17 @@ showfilewrite(char *a, int n) · 190 unmodified lines
211 error("not implemented");212 error("not implemented");
212 return -1;213 return -1;
213}214}
215
216void
217setterm(int raw)
218{
219 struct termios t;
220
221 if(tcgetattr(0, &t) < 0)
222 return;
223 if(raw)
224 t.c_lflag &= ~(ECHO|ICANON);
225 else
226 t.c_lflag |= (ECHO|ICANON);
227 tcsetattr(0, TCSAFLUSH, &t);
228}
kern/win32.c+18−0
@@ -316,3 +316,21 @@ showfilewrite(char *a, int n) · 315 unmodified lines
316 free(cmd);316 free(cmd);
317 return n;317 return n;
318}318}
319
320void
321setterm(int raw)
322{
323 DWORD mode;
324 HANDLE h;
325
326 h = GetStdHandle(STD_INPUT_HANDLE);
327 if(!GetConsoleMode(h, &mode))
328 return;
329 if(raw)
330 mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
331 else
332 mode |= (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
333 SetConsoleMode(h, mode);
334 FlushConsoleInputBuffer(h);
335 _setmode(0, raw? _O_BINARY: _O_TEXT);
336}

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