1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/common/include/villas/terminal.hpp
Steffen Vogel dfc24cf534 use C++ instead of C comment style
Signed-off-by: Steffen Vogel <steffen.vogel@opal-rt.com>
2024-02-29 18:58:07 +01:00

53 lines
876 B
C++

/** Terminal handling.
*
* @file
* @author Steffen Vogel <post@steffenvogel.de>
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
* @license Apache License 2.0
*********************************************************************************/
#pragma once
#include <cstdio>
#include <signal.h>
#include <sys/ioctl.h>
namespace villas {
class Terminal {
protected:
struct winsize window; // Size of the terminal window.
bool isTty;
static class Terminal *current;
public:
Terminal();
// Signal handler for TIOCGWINSZ
static
void resize(int signal, siginfo_t *sinfo, void *ctx);
static
int getCols()
{
if (!current)
current = new Terminal();
return current->window.ws_col;
}
static
int getRows()
{
if (!current)
current = new Terminal();
return current->window.ws_row;
}
};
} // namespace villas