Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_04
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c44db125
authored
Feb 27, 2019
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_WINX
parent
392b94f3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
console.cpp
+6
-6
console.h
+5
-6
No files found.
console.cpp
View file @
c44db125
...
...
@@ -9,10 +9,10 @@
#include <iostream>
#include <iomanip>
#if
_WINX
#if
defined(_WINX)
#include <conio.h>
#include <windows.h>
#elif
_UNIX
#elif
defined(_UNIX)
#include <termios.h> //termios, TCSANOW, ECHO, ICANON
#include <unistd.h> //STDIN_FILENO
#endif
...
...
@@ -22,7 +22,7 @@
/// Noname névtér.
/// Csak ebből a fájlból érhető el
namespace
{
#if
_WINX
#if
defined(_WINX)
void
clrscr
()
{
HANDLE
hstdout
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
CONSOLE_SCREEN_BUFFER_INFO
csbi
;
...
...
@@ -44,7 +44,7 @@ void gotoxy(int x, int y) {
SetConsoleCursorPosition
(
hstdout
,
dwCursorPosition
);
}
#elif
_UNIX
#elif
defined(_UNIX)
/// Kihasználjuk, hogy ANSI terminál
void
clrscr
()
{
...
...
@@ -113,14 +113,14 @@ Console::~Console() {
int
Console
::
getch
()
{
/// segédmakró
#define C(c, k) {c,k}
#if
_WINX
#if
defined(_WINX)
static
keyCodes
arrows
[]
=
{
C
(
72
,
KEY_UP
),
C
(
80
,
KEY_DOWN
),
C
(
77
,
KEY_RIGHT
),
C
(
75
,
KEY_LEFT
),
C
(
0
,
0
)
};
int
ch
=
::
_getch
();
if
(
ch
==
0xE0
)
{
/// windows ezt a kódot adja a nyílbillentyűk előtt
ch
=
::
_getch
();
/// utána jön a billentyű kódja
return
trCode
(
ch
,
arrows
);
}
#elif
_UNIX
#elif
defined(_UNIX)
static
keyCodes
arrows
[]
=
{
C
(
'A'
,
KEY_UP
),
C
(
'B'
,
KEY_DOWN
),
C
(
'C'
,
KEY_RIGHT
),
C
(
'D'
,
KEY_LEFT
),
C
(
0
,
0
)
};
int
ch
=
::
_getch
();
if
(
ch
==
0x1b
)
{
/// ANSI módban ezt adja be a terminál a nyilak előtt
...
...
console.h
View file @
c44db125
...
...
@@ -6,12 +6,11 @@
#ifndef CONSOLE_H
#define CONSOLE_H
// VS: alatt nem megy #define _UNIX defined(__linux__) || defined(__sun)
#if defined(__linux__) || defined(__sun)
#define _UNIX
#endif
#if defined(_WIN32) || defined(_WIN64)
#define _WINX
#define _WINX defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#define _UNIX defined(__linux__) || defined(__sun)
#if !defined(_WINX) && !defined(_UNIX)
# error "OS?"
#endif
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment