Unified · Split
| @@ -157,11 +157,6 @@ mouseset(Point p) · 156 unmodified lines | |||
| 157 | }); | 157 | }); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | void | ||
| 161 | setterm(int x) | ||
| 162 | { | ||
| 163 | } | ||
| 164 | |||
| 165 | @interface AppDelegate : NSObject <NSApplicationDelegate> | 160 | @interface AppDelegate : NSObject <NSApplicationDelegate> |
| 166 | @end | 161 | @end |
| 167 | 162 | ||
| @@ -672,24 +672,6 @@ clipwrite(char *buf) · 671 unmodified lines | |||
| 672 | return n; | 672 | return n; |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | void | ||
| 676 | setterm(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 | |||
| 693 | void | 675 | void |
| 694 | guimain(void) | 676 | guimain(void) |
| 695 | { | 677 | { |
| @@ -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 | |||
| 15 | typedef struct Cursor Cursor; | 13 | typedef struct Cursor Cursor; |
| 16 | 14 | ||
| 17 | #undef long | 15 | #undef long |
| @@ -1187,20 +1185,6 @@ clipwrite(char *buf) · 1169 unmodified lines | |||
| 1187 | return 0; | 1185 | return 0; |
| 1188 | } | 1186 | } |
| 1189 | 1187 | ||
| 1190 | void | ||
| 1191 | setterm(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 | |||
| 1204 | void | 1188 | void |
| 1205 | guimain(void) | 1189 | guimain(void) |
| 1206 | { | 1190 | { |
| @@ -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 | |||
| 216 | void | ||
| 217 | setterm(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 | } | ||
| @@ -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 | |||
| 320 | void | ||
| 321 | setterm(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 | } | ||