ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
lang
system
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
// #################################################################################################
7
#include "
alib/alib_precompile.hpp
"
8
9
#if !defined(ALIB_DOX)
10
# if !defined(HPP_ALIB_LANG_CONSOLE)
11
#include "
alib/lang/system/console.hpp
"
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
31
namespace
alib::lang::system
{
32
33
34
// static instance representing current process
35
int
Console::lastReceivedWidth
= -1;
36
37
38
int
Console::GetWidth
(
bool
forceRedetect )
39
{
40
if
(
Console::lastReceivedWidth
>= 0 && !forceRedetect )
41
return
Console::lastReceivedWidth
;
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 )
50
Console::lastReceivedWidth
= -1;
51
else
52
Console::lastReceivedWidth
= w.ws_col;
53
54
#elif defined (__APPLE__)
55
56
#else
57
#pragma message ("Unknown Platform in file: " __FILE__ )
58
#endif
59
60
return
Console::lastReceivedWidth
;
61
}
62
63
}
// namespace [ alib::lang::system]
alib_precompile.hpp
alib::lang::system::Console::GetWidth
static ALIB_API int GetWidth(bool forceRedetect=false)
Definition
console.cpp:38
alib::lang::system::Console::lastReceivedWidth
static ALIB_API int lastReceivedWidth
Definition
console.hpp:29
console.hpp
alib::lang::system
Definition
basecamp.cpp:146