ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
console.cpp
1//##################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6//##################################################################################################
7#include "alib_precompile.hpp"
8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14//========================================= Global Fragment ========================================
16
17#if !DOXYGEN
18# include <cstdlib>
19# if defined( _WIN32 )
20# elif defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__ANDROID_NDK__)
21# include <sys/ioctl.h>
22# include <unistd.h>
23# elif defined(__APPLE__)
24# include <unistd.h>
25# include <sys/sysctl.h>
26# else
27# pragma message ("Unknown Platform in file: " __FILE__ )
28# endif
29#endif // !DOXYGEN
30//============================================== Module ============================================
31#if ALIB_C20_MODULES
32 module ALib.System;
33#else
34# include "ALib.System.H"
35#endif
36//========================================== Implementation ========================================
37namespace alib::system {
38
39// static instance representing current process
41
42
43int Console::GetWidth( bool forceRedetect ) {
44 if( Console::lastReceivedWidth >= 0 && !forceRedetect )
46
47
48 #if defined (_WIN32)
49
50 #elif defined(__GLIBC__) && defined(__unix__) || defined(__ANDROID_NDK__)
51
52 struct winsize w;
53 if( ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != 0 )
55 else
57
58 #elif defined (__APPLE__)
59
60 #else
61 #pragma message ("Unknown Platform in file: " __FILE__ )
62 #endif
63
65}
66
67} // namespace [ alib::system]
static ALIB_DLL int lastReceivedWidth
Console text width.
Definition console.inl:18
static ALIB_DLL int GetWidth(bool forceRedetect=false)
Definition console.cpp:43