mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
[lldb] [Host] Refactor TerminalState
Refactor TerminalState to make the code simpler. Move 'struct termios' to a PImpl-style subclass. Add an RAII interface to automatically store and restore the state. Differential revision: https://reviews.llvm.org/D110721
This commit is contained in:
@@ -355,7 +355,6 @@ private:
|
||||
PyEval_InitThreads();
|
||||
}
|
||||
|
||||
TerminalState m_stdin_tty_state;
|
||||
PyGILState_STATE m_gil_state = PyGILState_UNLOCKED;
|
||||
bool m_was_already_initialized = false;
|
||||
};
|
||||
|
||||
@@ -430,11 +430,9 @@ public:
|
||||
int stdin_fd = GetInputFD();
|
||||
if (stdin_fd >= 0) {
|
||||
Terminal terminal(stdin_fd);
|
||||
TerminalState terminal_state;
|
||||
const bool is_a_tty = terminal.IsATerminal();
|
||||
TerminalState terminal_state(terminal);
|
||||
|
||||
if (is_a_tty) {
|
||||
terminal_state.Save(stdin_fd, false);
|
||||
if (terminal.IsATerminal()) {
|
||||
terminal.SetCanonical(false);
|
||||
terminal.SetEcho(true);
|
||||
}
|
||||
@@ -464,9 +462,6 @@ public:
|
||||
run_string.Printf("run_python_interpreter (%s)",
|
||||
m_python->GetDictionaryName());
|
||||
PyRun_SimpleString(run_string.GetData());
|
||||
|
||||
if (is_a_tty)
|
||||
terminal_state.Restore();
|
||||
}
|
||||
}
|
||||
SetIsDone(true);
|
||||
|
||||
Reference in New Issue
Block a user