SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
terminal.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
11#pragma once
12
13#ifndef _WIN32
14# include <sys/ioctl.h>
15#else
16# include <windows.h>
17#endif
18
19#include <cstdio>
20#include <unistd.h>
21
23
24namespace seqan3::detail
25{
26
27// ----------------------------------------------------------------------------
28// Function is_terminal()
29// ----------------------------------------------------------------------------
30
34inline bool is_terminal()
35{
36#ifndef _WIN32
37 return isatty(STDOUT_FILENO);
38#else
39 return false;
40#endif
41}
42
43// ----------------------------------------------------------------------------
44// Function get_terminal_size()
45// ----------------------------------------------------------------------------
46
56inline unsigned get_terminal_width()
57{
58#ifndef _WIN32
59
60 struct winsize w;
61 w.ws_row = 0;
62 w.ws_col = 0;
63
64 ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
65
66 return w.ws_col;
67#else
68 return 80; // not implemented in windows
69#endif
70}
71
72} // namespace seqan3::detail
Provides platform and dependency checks.
Hide me