crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
getch.h
Go to the documentation of this file.
1
/*
2
*
3
* ---
4
*
5
* Copyright (C) 2020 Anselm Schmidt (ans[ät]ohai.su)
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version in addition to the terms of any
11
* licences already herein identified.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*
21
* ---
22
*
23
* getch.h
24
*
25
* Plattform-independent getch()
26
*
27
* Created on: Oct 11, 2018
28
* Author: ans
29
*/
30
31
#ifndef HELPER_PORTABILITY_GETCH_HPP_
32
#define HELPER_PORTABILITY_GETCH_HPP_
33
34
#include <cctype>
35
36
#ifdef __unix
37
#include <termios.h>
38
#include <stdio.h>
39
#else
40
#include <conio.h>
41
#endif
/* __unix */
42
44
namespace
crawlservpp::Helper::Portability
{
45
46
static
struct
termios
oldT
;
47
static
struct
termios
newT
;
48
50
53
inline
char
getch
() {
54
55
#ifdef __unix
56
char
ch = 0;
57
58
tcgetattr(0, &
oldT
);
59
60
newT
=
oldT
;
61
62
newT
.c_lflag &= ~ICANON;
63
newT
.c_lflag &= ~ECHO;
64
65
tcsetattr(0, TCSANOW, &
newT
);
66
67
ch = getchar();
68
69
tcsetattr(0, TCSANOW, &
oldT
);
70
71
return
ch;
72
#else
73
return ::getch
();
74
#endif
/* __ unix */
75
76
}
77
78
}
/* namespace crawlservpp::Helper::Portability */
79
80
#endif
/* HELPER_PORTABILITY_GETCH_HPP_ */
crawlservpp::Helper::Portability
Namespace for global portability functions.
Definition:
getch.h:44
crawlservpp::Helper::Portability::newT
static struct termios newT
Definition:
getch.h:47
crawlservpp::Helper::Portability::oldT
static struct termios oldT
Definition:
getch.h:46
crawlservpp::Helper::Portability::getch
char getch()
Gets a character from the user via the terminal.
Definition:
getch.h:53
Helper
Portability
getch.h
Generated on Tue Dec 19 2023 13:58:06 for crawlserv++ by
1.8.13