1 #ifndef OOKII_CONSOLE_HELPER_H_
4 #define OOKII_CONSOLE_HELPER_H_
47 template<
typename CharType>
57 static inline std::ostream &
cout()
63 static inline std::ostream &
cerr()
69 static inline std::istream &
cin()
80 static inline std::wostream &
cout()
86 static inline std::wostream &
cerr()
92 static inline std::wistream &
cin()
116 #ifdef OOKII_PLATFORM_FUNC_HAS_BODY
122 return GetStdHandle(STD_INPUT_HANDLE);
125 return GetStdHandle(STD_ERROR_HANDLE);
128 return GetStdHandle(STD_OUTPUT_HANDLE);
135 return _fileno(get_stream_file(stream));
139 #ifdef OOKII_PLATFORM_FUNC_HAS_BODY
141 return _isatty(get_stream_fd(stream));
148 return fileno(get_stream_file(stream));
152 #ifdef OOKII_PLATFORM_FUNC_HAS_BODY
154 return isatty(get_stream_fd(stream));
186 #ifdef OOKII_PLATFORM_FUNC_HAS_BODY
188 auto handle = details::get_stream_handle(stream);
190 if (!GetConsoleMode(handle, &mode))
196 ? ENABLE_VIRTUAL_TERMINAL_INPUT
197 : ENABLE_VIRTUAL_TERMINAL_PROCESSING;
199 auto old_mode = mode;
209 if (mode == old_mode)
214 if (!SetConsoleMode(handle, mode))
Namespace containing the core Ookii.CommandLine.Cpp types.
Definition: command_line_argument.h:16
standard_stream
Represents one of the standard console streams.
Definition: console_helper.h:32
@ output
The standard output stream.
@ input
The standard input stream.
@ error
The standard error stream.
vt_result
Indicates the result of the set_console_vt_support operation.
Definition: console_helper.h:162
@ no_change
No action was taken, because the value already matched the requested setting.
@ success
Virtual terminal sequences were successfully enabled.
@ failed
Virtual terminal sequences could not be enabled.
vt_result set_console_vt_support([[maybe_unused]] standard_stream stream, [[maybe_unused]] bool enable) noexcept
Enables or disables console support for virtual terminal sequences.
Definition: console_helper.h:223
short get_console_width(short default_width=80) noexcept
Determines the width of the console.
Definition: console_helper.h:19
static std::ostream & cerr()
Provides access to cerr.
Definition: console_helper.h:63
static std::istream & cin()
Provides access to cin.
Definition: console_helper.h:69
static std::ostream & cout()
Provides access to cout.
Definition: console_helper.h:57
static std::wostream & cout()
Provides access to wcout.
Definition: console_helper.h:80
static std::wistream & cin()
Provides access to wcin.
Definition: console_helper.h:92
static std::wostream & cerr()
Provides access to wcerr.
Definition: console_helper.h:86
Template to determine the correct console streams based on the character type.
Definition: console_helper.h:49