YSTest: Consoles.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

Consoles.h
浏览该文件的文档.
1 /*
2 © 2013-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
29 #ifndef YCL_MinGW32_INC_Consoles_h_
30 #define YCL_MinGW32_INC_Consoles_h_
31
32 #include "YCLib/YModules.h"
33 #include YFM_Win32_YCLib_MinGW32
34 #include <cstdlib> // for std::system;
35 #include YFM_YCLib_Container // for array;
36 #include YFM_YCLib_Video
37 #include <Wincon.h>
38
39 namespace platform_ex
40 {
41
42 inline namespace Windows
43 {
44
61 YF_API void
62 FixConsoleHandler(int(WINAPI*)(unsigned long) = {}, bool = true);
63
64
69 class YF_API WConsole
70 {
71 public:
76 enum Style
77 {
79 Normal = 0,
81 Bright = 0x08
82 };
83
84 private:
86 ::HANDLE h_std;
88 ::WORD saved_attr;
89
90 public:
92 ::WORD Attributes;
93
95
96 WConsole(unsigned long h = STD_OUTPUT_HANDLE);
102 WConsole(::HANDLE);
104 ~WConsole();
106
108
109
111 DefGetter(const, ::COORD, CursorPosition,
112 GetScreenBufferInfo().dwCursorPosition)
113 ::CONSOLE_SCREEN_BUFFER_INFO
114 GetScreenBufferInfo() const;
116 DefGetter(const ynothrow, ::WORD, SavedAttributes, saved_attr)
118
120 void
121 SetBackColor(std::uint8_t) ynothrow;
123 void
124 SetCursorPosition(::COORD);
126 void
127 SetForeColor(std::uint8_t) ynothrow;
128 static PDefH(void, SetSystemColor, )
129 ImplExpr(std::system("COLOR"))
130 static void
131 SetSystemColor(std::uint8_t);
132
133 static PDefH(void, Clear, )
134 ImplExpr(std::system("CLS"))
135
137 static ::WORD
138 ComposeAttributes(std::uint8_t, std::uint8_t) ynothrow;
139
141
142 void
143 CursorUp(size_t);
144
146 static PDefH(array<std::uint8_t YPP_Comma 2>, DecomposeAttributes,
147 ::WORD val) ynothrow
148 ImplRet({{FetchForeColor(val), FetchBackColor(val)}})
149
151
152 void
153 Erase(wchar_t = L' ');
154
156 static PDefH(std::uint8_t, FetchBackColor, ::WORD val) ynothrow
157 ImplRet(std::uint8_t((val >> 4) & 15))
158
159
160 static PDefH(std::uint8_t, FetchForeColor, ::WORD val) ynothrow
161 ImplRet(std::uint8_t(val & 15))
162
164 void
165 Fill(::COORD, unsigned long, wchar_t = L' ');
166
171 void
172 RestoreAttributes();
173
174 void
175 Update();
176 void
177 Update(::WORD);
178
179 void
180 UpdateBackColor(std::uint8_t);
181
182 void
183 UpdateForeColor(std::uint8_t);
185
193 size_t
194 WriteString(string_view);
196 size_t
197 WriteString(string_view, unsigned);
198 size_t
199 WriteString(wstring_view);
200 PDefH(size_t, WriteString, u16string_view sv)
201 ImplRet(WriteString(wstring(sv.cbegin(), sv.cend())))
203
204 };
205
214 YF_API unique_ptr<WConsole>
215 MakeWConsole(unsigned long = STD_OUTPUT_HANDLE);
216
217 } // inline namespace Windows;
218
219 } // namespace platform_ex;
220
221 #endif
222
platform::containers::wstring
basic_string< wchar_t > wstring
Definition: Container.h:108
platform_ex::Windows::ImplRet
yconstfnconst::WIN32_FIND_DATAA &d ynothrow ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes))) inline PDefH(bool
判断 ::WIN32_FIND_DATAW 指定的节点是否为目录。
ystdex::u16string_view
basic_string_view< char16_t > u16string_view
Definition: string_view.hpp:416
platform_ex::Windows::WConsole::Style
Style
Definition: Consoles.h:76
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
platform::KeyCodes::DS::L
Definition: Keys.h:227
ystdex::wstring_view
basic_string_view< wchar_t > wstring_view
Definition: string_view.hpp:418
platform_ex::Windows::WConsole::Attributes
::WORD Attributes
Definition: Consoles.h:92
YSLib::Drawing::Fill
YF_API void Fill(const Graphics &, Color)
使用指定颜色填充图形接口上下文缓冲区。
Definition: YBlit.cpp:94
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
platform_ex::Windows::FixConsoleHandler
YF_API void FixConsoleHandler(int(WINAPI *)(unsigned long)={}, bool=true)
安装控制台处理器。
YF_API
#define YF_API
Definition: Platform.h:56
platform_ex::Windows::WConsole
Definition: Consoles.h:69
YModules.h
platform_ex::Windows::WConsole::saved_attr
::WORD saved_attr
Definition: Consoles.h:88
std
Definition: memory.hpp:1183
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
platform_ex
平台扩展命名空间。
Definition: Android.h:45
platform_ex::Windows::PDefH
PDefH(platform::NodeCategory, CategorizeNode, const ::WIN32_FIND_DATAA &d) ynothrow ImplRet(CategorizeNode(FileAttributes(d.dwFileAttributes)
按 ::WIN32_FIND_DATAA 归类节点类别。
YPP_Comma
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:225
platform_ex::Windows::WConsole::h_std
::HANDLE h_std
Definition: Consoles.h:86
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
platform_ex::Windows::Normal
Definition: MinGW32.h:455