Commit 2e2aa196 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

terminal: add new terminal class

parent 0a2076a5
/** Terminal handling.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLAScommon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
#include <cstdio>
#include <signal.h>
#include <sys/ioctl.h>
namespace villas {
class Terminal {
protected:
static struct winsize window; /**< Size of the terminal window. */
bool isTty;
public:
Terminal();
/** Signal handler for TIOCGWINSZ */
static void resize(int signal, siginfo_t *sinfo, void *ctx);
static int getCols()
{
return window.ws_col;
}
static int getRows()
{
return window.ws_row;
}
};
} // namespace villas
......@@ -62,8 +62,8 @@ static int table_resize(struct table *t, int width)
void table_header(struct table *t)
{
if (t->width != global_log->width)
table_resize(t, global_log->width);
if (t->width != log_get_width())
table_resize(t, log_get_width());
char *line0 = strf("\b");
char *line1 = strf("\b\b" BOX_UD);
......@@ -119,8 +119,8 @@ void table_header(struct table *t)
void table_row(struct table *t, ...)
{
if (t->width != global_log->width) {
table_resize(t, global_log->width);
if (t->width != log_get_width()) {
table_resize(t, log_get_width());
table_header(t);
}
......@@ -152,8 +152,8 @@ void table_row(struct table *t, ...)
void table_footer(struct table *t)
{
if (t->width != global_log->width)
table_resize(t, global_log->width);
if (t->width != log_get_width())
table_resize(t, log_get_width());
char *line = strf("\b");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment