1 #ifndef OOKII_CONSOLE_HELPER_H_
21 #define OOKII_CONSOLE_HELPER_H_
25 #if !defined(OOKII_NO_PLATFORM_HEADERS) && (!defined(OOKII_CONSOLE_NOT_INLINE) || defined(OOKII_CONSOLE_DEFINITION))
28 #define WIN32_LEAN_AND_MEAN
44 #include <sys/ioctl.h>
59 #ifndef OOKII_CONSOLE_NOT_INLINE
63 #if defined(OOKII_CONSOLE_NOT_INLINE) && !defined(OOKII_CONSOLE_DEFINITION)
69 HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
70 CONSOLE_SCREEN_BUFFER_INFO info;
71 if (GetConsoleScreenBufferInfo(handle, &info))
72 return info.srWindow.Right - info.srWindow.Left + 1;
74 #elif defined(TIOCGWINSZ)
78 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
79 return static_cast<short>(ws.ws_col);
93 template<
typename CharType>
103 static inline std::ostream &
cout()
109 static inline std::ostream &
cerr()
115 static inline std::istream &
cin()
126 static inline std::wostream &
cout()
132 static inline std::wostream &
cerr()
138 static inline std::wistream &
cin()
Namespace containing the core Ookii.CommandLine.Cpp types.
Definition: command_line_argument.h:16
short get_console_width(short default_width=80) noexcept
Determines the width of the console.
Definition: console_helper.h:62
static std::ostream & cerr()
Provides access to cerr.
Definition: console_helper.h:109
static std::istream & cin()
Provides access to cin.
Definition: console_helper.h:115
static std::ostream & cout()
Provides access to cout.
Definition: console_helper.h:103
static std::wostream & cout()
Provides access to wcout.
Definition: console_helper.h:126
static std::wistream & cin()
Provides access to wcin.
Definition: console_helper.h:138
static std::wostream & cerr()
Provides access to wcerr.
Definition: console_helper.h:132
Template to determine the correct console streams based on the character type.
Definition: console_helper.h:95