ALib C++ Library
by
Library Version:
2412 R0
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 !DOXYGEN
10
# include "
alib/lang/system/console.hpp
"
11
# include <cstdlib>
12
# if defined( _WIN32 )
13
# elif defined(__GLIBCXX__) || defined(__ANDROID_NDK__)
14
# include <sys/ioctl.h>
15
# include <unistd.h>
16
# elif defined(__APPLE__)
17
# include <unistd.h>
18
# include <sys/sysctl.h>
19
# else
20
# pragma message ("Unknown Platform in file: " __FILE__ )
21
# endif
22
#endif
// !DOXYGEN
23
24
25
namespace
alib::lang::system
{
26
27
28
// static instance representing current process
29
int
Console::lastReceivedWidth
= -1;
30
31
32
int
Console::GetWidth
(
bool
forceRedetect )
33
{
34
if
(
Console::lastReceivedWidth
>= 0 && !forceRedetect )
35
return
Console::lastReceivedWidth
;
36
37
38
#if defined (_WIN32)
39
40
#elif defined(__GLIBC__) && defined(__unix__) || defined(__ANDROID_NDK__)
41
42
struct
winsize w;
43
if
( ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != 0 )
44
Console::lastReceivedWidth
= -1;
45
else
46
Console::lastReceivedWidth
= w.ws_col;
47
48
#elif defined (__APPLE__)
49
50
#else
51
#pragma message ("Unknown Platform in file: " __FILE__ )
52
#endif
53
54
return
Console::lastReceivedWidth
;
55
}
56
57
}
// namespace [ alib::lang::system]
alib_precompile.hpp
alib::lang::system::Console::GetWidth
static ALIB_API int GetWidth(bool forceRedetect=false)
Definition
console.cpp:32
alib::lang::system::Console::lastReceivedWidth
static ALIB_API int lastReceivedWidth
Console text width.
Definition
console.hpp:28
console.hpp
alib::lang::system
This is the reference documentation of sub-namespace system of module ALib BaseCamp.
Definition
basecamp.cpp:75