SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
terminal.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
14 #pragma once
15 
16 #ifndef _WIN32
17 # include <sys/ioctl.h>
18 #else
19 # include <windows.h>
20 #endif
21 
22 #include <unistd.h>
23 
24 #include <cstdio>
25 
26 #include <seqan3/core/platform.hpp>
27 
28 namespace seqan3::detail
29 {
30 
31 // ----------------------------------------------------------------------------
32 // Function is_terminal()
33 // ----------------------------------------------------------------------------
34 
38 inline bool is_terminal()
39 {
40 #ifndef _WIN32
41  return isatty(STDOUT_FILENO);
42 #else
43  return false;
44 #endif
45 }
46 
47 // ----------------------------------------------------------------------------
48 // Function get_terminal_size()
49 // ----------------------------------------------------------------------------
50 
60 inline unsigned get_terminal_width()
61 {
62 #ifndef _WIN32
63 
64  struct winsize w;
65  w.ws_row = 0;
66  w.ws_col = 0;
67 
68  ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
69 
70  return w.ws_col;
71 #else
72  return 80; // not implemented in windows
73 #endif
74 }
75 
76 } // namespace seqan::detail
platform.hpp
Provides platform and dependency checks.
cstdio