ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
console.cpp
1//##################################################################################################
2// ALib C++ Framework
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 "Configuration MACRO 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, int defaultWidth ) {
44 if( Console::lastReceivedWidth > 0 && !forceRedetect )
46
47 #if defined (_WIN32)
48
49 #elif defined(__GLIBC__) && defined(__unix__) || defined(__ANDROID_NDK__)
50
51 struct winsize w;
52 if( ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != 0 )
54 else
56
57 #elif defined (__APPLE__)
58
59 #else
60 #pragma message ("Unknown Platform in file: " __FILE__ )
61 #endif
62
64}
65
66} // namespace [ alib::system]
static int GetWidth(bool forceRedetect=false, int defaultWidth=80)
Definition console.cpp:43
static int lastReceivedWidth
Console text width.
Definition console.inl:18