ALib C++ Library
Library Version: 2510 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{
45 if( Console::lastReceivedWidth >= 0 && !forceRedetect )
47
48
49 #if defined (_WIN32)
50
51 #elif defined(__GLIBC__) && defined(__unix__) || defined(__ANDROID_NDK__)
52
53 struct winsize w;
54 if( ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != 0 )
56 else
58
59 #elif defined (__APPLE__)
60
61 #else
62 #pragma message ("Unknown Platform in file: " __FILE__ )
63 #endif
64
66}
67
68} // 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