ALib C++ Library
by
Library Version:
2510 R0
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
system
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 ======================================
15
#include "
alib/system/system.prepro.hpp
"
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 =======================================
37
namespace
alib::system
{
38
39
// static instance representing current process
40
int
Console::lastReceivedWidth
= -1;
41
42
43
int
Console::GetWidth
(
bool
forceRedetect )
44
{
45
if
(
Console::lastReceivedWidth
>= 0 && !forceRedetect )
46
return
Console::lastReceivedWidth
;
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 )
55
Console::lastReceivedWidth
= -1;
56
else
57
Console::lastReceivedWidth
= w.ws_col;
58
59
#elif defined (__APPLE__)
60
61
#else
62
#pragma message ("Unknown Platform in file: " __FILE__ )
63
#endif
64
65
return
Console::lastReceivedWidth
;
66
}
67
68
}
// namespace [ alib::system]
ALib.System.H
alib_precompile.hpp
alib::system::Console::lastReceivedWidth
static ALIB_DLL int lastReceivedWidth
Console text width.
Definition
console.inl:18
alib::system::Console::GetWidth
static ALIB_DLL int GetWidth(bool forceRedetect=false)
Definition
console.cpp:43
ALib.System
alib::system
Definition
exception.cpp:217
system.prepro.hpp