cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
screen.cpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
11
12#ifdef _WIN32
13 #pragma warning(push)
14 #pragma warning(disable : 4668)
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 #pragma warning(pop)
18#else
19 #include <sys/ioctl.h>
20#endif
21
23
25{
26#ifdef _WIN32
27 CONSOLE_SCREEN_BUFFER_INFO inf;
28 if(GetConsoleScreenBufferInfo(Private::out.handle(), &inf)) return Term::Screen({Term::Rows(inf.srWindow.Bottom - inf.srWindow.Top + 1), Term::Columns(inf.srWindow.Right - inf.srWindow.Left + 1)});
29 return {};
30#else
31 struct winsize window{0, 0, 0, 0};
32 if(ioctl(Private::out.fd(), TIOCGWINSZ, &window) != -1) return Term::Screen({Term::Rows(window.ws_row), Term::Columns(window.ws_col)});
33 return {};
34#endif
35}
Screen screen_size()
Definition screen.cpp:24