ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
console.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !defined(ALIB_DOX)
10# if !defined(HPP_ALIB_LANG_CONSOLE)
12# endif
13
14# if !defined(_GLIBCXX_CSTDLIB) && !defined(_CSTDLIB_)
15# include <cstdlib>
16# endif
17
18# if defined( _WIN32 )
19# elif defined(__GLIBCXX__) || defined(__ANDROID_NDK__)
20# include <sys/ioctl.h>
21# include <unistd.h>
22# elif defined(__APPLE__)
23# include <unistd.h>
24# include <sys/sysctl.h>
25# else
26# pragma message ("Unknown Platform in file: " __FILE__ )
27# endif
28#endif // !defined(ALIB_DOX)
29
30
31namespace alib::lang::system {
32
33
34// static instance representing current process
36
37
38int Console::GetWidth( bool forceRedetect )
39{
40 if( Console::lastReceivedWidth >= 0 && !forceRedetect )
42
43
44 #if defined (_WIN32)
45
46 #elif defined(__GLIBC__) && defined(__unix__) || defined(__ANDROID_NDK__)
47
48 struct winsize w;
49 if( ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != 0 )
51 else
53
54 #elif defined (__APPLE__)
55
56 #else
57 #pragma message ("Unknown Platform in file: " __FILE__ )
58 #endif
59
61}
62
63} // namespace [ alib::lang::system]
static ALIB_API int GetWidth(bool forceRedetect=false)
Definition console.cpp:38
static ALIB_API int lastReceivedWidth
Definition console.hpp:29