YSTest: Consoles.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

Consoles.h
浏览该文件的文档.
1 /*
2 © 2013-2015 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
49 class YF_API WConsole
50 {
51 public:
56 enum Style
57 {
59 Normal = 0,
61 Bright = 0x08
62 };
63
64 private:
66 ::HANDLE h_std;
68 ::WORD saved_attr;
69
70 public:
72 ::WORD Attributes;
73
75
76 WConsole(unsigned long h = STD_OUTPUT_HANDLE);
82 WConsole(::HANDLE);
84 ~WConsole();
86
88
89
91 DefGetter(const, ::COORD, CursorPosition,
92 GetScreenBufferInfo().dwCursorPosition)
93 ::CONSOLE_SCREEN_BUFFER_INFO
94 GetScreenBufferInfo() const;
96 DefGetter(const ynothrow, ::WORD, SavedAttributes, saved_attr)
98
100 void
101 SetBackColor(std::uint8_t) ynothrow;
103 void
104 SetCursorPosition(::COORD);
106 void
107 SetForeColor(std::uint8_t) ynothrow;
108 static PDefH(void, SetSystemColor, )
109 ImplExpr(std::system("COLOR"))
110 static void
111 SetSystemColor(std::uint8_t);
112
113 static PDefH(void, Clear, )
114 ImplExpr(std::system("CLS"))
115
117 static ::WORD
118 ComposeAttributes(std::uint8_t, std::uint8_t) ynothrow;
119
121
122 void
123 CursorUp(size_t);
124
126 static PDefH(array<std::uint8_t YPP_Comma 2>, DecomposeAttributes,
127 ::WORD val) ynothrow
128 ImplRet({{FetchForeColor(val), FetchBackColor(val)}})
129
131
132 void
133 Erase(wchar_t = L' ');
134
136 static PDefH(std::uint8_t, FetchBackColor, ::WORD val) ynothrow
137 ImplRet(std::uint8_t((val >> 4) & 15))
138
139
140 static PDefH(std::uint8_t, FetchForeColor, ::WORD val) ynothrow
141 ImplRet(std::uint8_t(val & 15))
142
144 void
145 Fill(::COORD, unsigned long, wchar_t = L' ');
146
151 void
152 RestoreAttributes();
153
154 void
155 Update();
156 void
157 Update(::WORD);
158
159 void
160 UpdateBackColor(std::uint8_t);
161
162 void
163 UpdateForeColor(std::uint8_t);
165
173 size_t
174 WriteString(string_view);
176 size_t
177 WriteString(string_view, unsigned);
178 size_t
179 WriteString(wstring_view);
180 PDefH(size_t, WriteString, u16string_view sv)
181 ImplRet(WriteString({platform::wcast(sv.data()), sv.length()}))
183
184 };
185
194 YF_API unique_ptr<WConsole>
195 MakeWConsole(unsigned long = STD_OUTPUT_HANDLE);
196
197 } // inline namespace Windows;
198
199 } // namespace platform_ex;
200
201 #endif
202
YSLib::Drawing::Fill
YF_API void Fill(const Graphics &, Color)
使用指定颜色填充图形接口上下文缓冲区。
Definition: YBlit.cpp:94
platform_ex::Windows::WConsole::Style
Style
Definition: Consoles.h:56
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
platform::KeyCodes::DS::L
Definition: Keys.h:227
platform_ex::Windows::Normal
Definition: MinGW32.h:445
platform_ex::Windows::WConsole::h_std
::HANDLE h_std
Definition: Consoles.h:66
ystdex::wstring_view
basic_string_view< wchar_t > wstring_view
Definition: string_view.hpp:418
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:240
platform_ex::Windows::PDefH
PDefH(wstring, FetchCPFileNameFromRegistry, int cp) ImplRet(FetchNLSItemFromRegistry(to_wstring(cp).c_str())) YF_API const unsigned short *FetchDBCSOffset(int) ynothrow
取注册表中指定代码页的 NLS 文件路径。
std
Definition: memory.hpp:1100
platform_ex::Windows::ImplRet
const wchar_t FileAccessRights FileShareMode FileAttributesAndFlags attributes_and_flags ynothrowv ImplRet(MakeFile(path, desired_access, shared_mode, CreationDisposition::OpenExisting, attributes_and_flags)) inline YB_NONNULL(1) PDefH(UniqueHandle
platform_ex
平台扩展命名空间。
Definition: Android.h:45
YModules.h
platform_ex::Windows::WConsole::Attributes
::WORD Attributes
Definition: Consoles.h:72
ystdex::u16string_view
basic_string_view< char16_t > u16string_view
Definition: string_view.hpp:416
YPP_Comma
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:225
YF_API
#define YF_API
Definition: Platform.h:56
platform_ex::Windows::WConsole
Definition: Consoles.h:49
platform_ex::Windows::WConsole::saved_attr
::WORD saved_attr
Definition: Consoles.h:68