fix infinite check bug
[rofl0r-oopoker.git] / io_terminal.h
blob12cd97bf64e8982a7561630b4d2da5097031d7e4
1 /*
2 OOPoker
4 Copyright (c) 2010 Lode Vandevenne
5 All rights reserved.
7 This file is part of OOPoker.
9 OOPoker is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 OOPoker is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with OOPoker. If not, see <http://www.gnu.org/licenses/>.
23 #pragma once
25 #include <vector>
26 #include <string>
29 This file contains utility methods for using the terminal in Windows
30 and in Linux. It contains functions for detecting if a key was pressed,
31 getting the current date and time as a string, drawing the table using
32 ASCII art, etc...
35 struct Info;
36 class Card;
38 void drawTable(const Info& info);
39 std::string cardsToAsciiArt(const std::vector<Card>& cards);
42 getChar should do the following:
43 When the function is just called, wait, until the user presses a key. Then
44 return the code of that key.
45 Keys pressed before getChar() is called shouldn't have an influence.
46 No pressing enter after pressed the key is required.
48 The correct behaviour of getChar() is guaranteed only if you use only getChar()
49 and getLine() as input functions. If you use std::cin directly, it'll mess up getChar(),
50 so always use getLine() instead of std::cin, even for integers!
52 int getChar();
55 Gets a char without waiting. Returns 0 if no key is pressed so far. For the rest similar to getChar().
57 int getCharNonBlocking();
60 getLine should do the following:
61 allow the user to type characters on the keyboard, and when pressing enter, return
62 that line as a string.
63 To convert this line to a number, use strtoval from util.h
64 Never use std::cin, always use getLine() instead, it's designed to not mess up getChar(), which
65 can have problems with keyboard or input buffers.
67 std::string getLine(); //use this instead of std::cin, or getChar() will not work properly after getting a line
70 Pauses the program until the user presses a key. If the user presses "q" it means he wants to quit.
71 It returns true if the user wants to quit, false otherwise.
72 Also displays a message indicating q will quit.
74 bool pressAnyKeyOrQuit();
77 Shows message "press any key to continue", then waits for key press
79 void pressAnyKey();
82 Pause for that many milliseconds.
84 void sleepMS(int milliSeconds);
86 //returns time and date in human readable format
87 std::string getDateString();