[PATCH 2/5] [WineConsole]: in line mode, save (resp restore) terminal settings upon startup (resp exit)
Eric Pouech
eric.pouech at orange.fr
Mon Dec 3 15:12:09 CST 2012
A+
---
programs/wineconsole/line.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/programs/wineconsole/line.c b/programs/wineconsole/line.c
index 4b7fd29..2bc29ea 100644
--- a/programs/wineconsole/line.c
+++ b/programs/wineconsole/line.c
@@ -31,6 +31,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
@@ -48,6 +51,7 @@ struct inner_data_line
int sync_pipe[2];
HANDLE input_thread;
CRITICAL_SECTION lock;
+ struct termios termios;
};
/******************************************************************
@@ -262,6 +266,8 @@ static void WCLINE_DeleteBackend(struct inner_data* data)
{
if (!PRIVATE(data)) return;
+ /* restore initial termios settings */
+ tcsetattr(0, TCSANOW, &PRIVATE(data)->termios);
if (PRIVATE(data)->input_thread)
{
close(PRIVATE(data)->sync_pipe[1]);
@@ -282,11 +288,28 @@ static void WCLINE_DeleteBackend(struct inner_data* data)
*/
static int WCLINE_MainLoop(struct inner_data* data)
{
- DWORD id;
+ DWORD id;
+ struct termios term;
WCLINE_Resize(data);
if (pipe(PRIVATE(data)->sync_pipe) == -1) return 0;
+
+ /* put console into raw mode */
+ term = PRIVATE(data)->termios;
+ term.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
+ term.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+ term.c_cflag &= ~(CSIZE | PARENB);
+ term.c_cflag |= CS8;
+ /* FIXME: we should actually disable output processing here
+ * and let kernel32/console.c do the job (with support of enable/disable of
+ * processed output)
+ */
+ /* term.c_oflag &= ~(OPOST); */
+ term.c_cc[VMIN] = 1;
+ term.c_cc[VTIME] = 0;
+ if (tcsetattr(0, TCSANOW, &term) == -1) return 0;
+
PRIVATE(data)->input_thread = CreateThread(NULL, 0, input_thread, data, 0, &id);
while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0)
@@ -328,6 +351,8 @@ enum init_return WCLINE_InitBackend(struct inner_data* data)
InitializeCriticalSection(&PRIVATE(data)->lock);
PRIVATE(data)->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": line");
+ /* save initial termios settings */
+ if (tcgetattr(0, &PRIVATE(data)->termios) == -1) return 0;
return init_success;
}
More information about the wine-patches
mailing list