Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
console.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <string>
3
4namespace fc {
5
6#ifdef WIN32
7#include <windows.h>
8
9void set_console_echo( bool enable_echo )
10{
11 auto stdin_handle = GetStdHandle( STD_INPUT_HANDLE );
12 DWORD mode = 0;
13 GetConsoleMode( stdin_handle, &mode );
14 if( enable_echo )
15 {
16 SetConsoleMode( stdin_handle, mode | ENABLE_ECHO_INPUT );
17 }
18 else
19 {
20 SetConsoleMode( stdin_handle, mode & (~ENABLE_ECHO_INPUT) );
21 }
22}
23
24#else // NOT WIN32
25#include <termios.h>
26#include <unistd.h>
27
28void set_console_echo( bool enable_echo )
29{
30 termios oldt;
31 tcgetattr(STDIN_FILENO, &oldt);
32 termios newt = oldt;
33 if( enable_echo )
34 {
35 newt.c_lflag |= ECHO;
36 }
37 else
38 {
39 newt.c_lflag &= ~ECHO;
40 }
41 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
42}
43
44#endif // WIN32
45
46} // namespace fc
namespace sysio::chain
Definition authority.cpp:3
void set_console_echo(bool enable_echo)
Definition console.cpp:28