-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstream.hpp
More file actions
137 lines (119 loc) · 3.1 KB
/
constream.hpp
File metadata and controls
137 lines (119 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/** @file constream
* A constream implementation for Mingw/Dev-C++.
* @warning There is not implemented constream class, only manipulators
* for iostream, so use them on cin/cout.
*
* @author Michal Molhanec <michal@molhanec.net>
*
* Offered for use in the public domain without any warranty.
*/
#ifndef _CONSTREAM_
#define _CONSTREAM_
#include <iostream>
#include <conio.h>
/// This namespace contain all C++ specific things.
namespace conio {
struct _Setxy { int x,y; };
/// setxy manipulator
/// @see gotoxy
inline _Setxy setxy (int x, int y) {
_Setxy z; z.x = x; z.y = y; return z;
}
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& o, _Setxy f) {
::gotoxy (f.x, f.y);
return o;
}
struct _Setclr { int color; };
/// setclr manipulator
/// @see textcolor
inline _Setclr setclr (int color) {
_Setclr x; x.color = color; return x;
}
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& o, _Setclr f) {
::textcolor (f.color);
return o;
}
struct _Setbk { int color; };
/// setbk manipulator
/// @see textbackground
inline _Setbk setbk (int color) {
_Setbk x; x.color = color; return x;
}
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& o, _Setbk f) {
::textbackground (f.color);
return o;
}
struct _Setattr { int _attr; };
/// setattr manipulator
/// @see textattr
inline _Setattr setattr (int _attr) {
_Setattr x; x._attr = _attr; return x;
}
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& o, _Setattr f) {
::textattr (f._attr);
return o;
}
struct _Setcrsrtype { int type; };
/// setcrsrtype manipulator
/// @see _setcursortype
inline _Setcrsrtype setcrsrtype (int type) {
_Setcrsrtype x; x.type = type; return x;
}
template<typename CharT, typename Traits>
inline std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& o, _Setcrsrtype f) {
::_setcursortype (f.type);
return o;
}
/// clrscr manipulator
/// @see ::clrscr(void)
inline std::ostream& clrscr (std::ostream& o) {
::clrscr();
return o;
}
/// clreol manipulator
/// @see ::clreol(void)
inline std::ostream& clreol (std::ostream& o) {
::clreol();
return o;
}
/// highvideo manipulator
/// @see ::highvideo(void)
inline std::ostream& highvideo (std::ostream& o) {
::highvideo();
return o;
}
/// lowvideo manipulator
/// @see ::lowvideo(void)
inline std::ostream& lowvideo (std::ostream& o) {
::lowvideo();
return o;
}
/// normvideo manipulator
/// @see ::normvideo(void)
inline std::ostream& normvideo (std::ostream& o) {
::normvideo();
return o;
}
/// delline manipulator
/// @see ::delline(void)
inline std::ostream& delline (std::ostream& o) {
::delline();
return o;
}
/// insline manipulator
/// @see ::insline(void)
inline std::ostream& insline (std::ostream& o) {
::insline();
return o;
}
}
#endif /* not defined _CONSTREAM_ */