UNPKG

1.97 kBPlain TextView Raw
1Note regarding ENABLE_EXTENDED_FLAGS (2016-05-30)
2
3There is a complicated interaction between the ENABLE_EXTENDED_FLAGS flag
4and the ENABLE_QUICK_EDIT_MODE and ENABLE_INSERT_MODE flags (presumably for
5backwards compatibility?). I studied the behavior on Windows 7 and Windows
610, with both the old and new consoles, and I didn't see any differences
7between versions. Here's what I seemed to observe:
8
9 - The console has three flags internally:
10 - QuickEdit
11 - InsertMode
12 - ExtendedFlags
13
14 - SetConsoleMode psuedocode:
15 void SetConsoleMode(..., DWORD mode) {
16 ExtendedFlags = (mode & (ENABLE_EXTENDED_FLAGS
17 | ENABLE_QUICK_EDIT_MODE
18 | ENABLE_INSERT_MODE )) != 0;
19 if (ExtendedFlags) {
20 QuickEdit = (mode & ENABLE_QUICK_EDIT_MODE) != 0;
21 InsertMode = (mode & ENABLE_INSERT_MODE) != 0;
22 }
23 }
24
25 - Setting QuickEdit or InsertMode from the properties dialog GUI does not
26 affect the ExtendedFlags setting -- it simply toggles the one flag.
27
28 - GetConsoleMode psuedocode:
29 GetConsoleMode(..., DWORD *result) {
30 if (ExtendedFlags) {
31 *result |= ENABLE_EXTENDED_FLAGS;
32 if (QuickEdit) { *result |= ENABLE_QUICK_EDIT_MODE; }
33 if (InsertMode) { *result |= ENABLE_INSERT_MODE; }
34 }
35 }
36
37Effectively, the ExtendedFlags flags controls whether the other two flags
38are visible/controlled by the user application. If they aren't visible,
39though, there is no way for the user application to make them visible,
40except by overwriting their values! Calling SetConsoleMode with just
41ENABLE_EXTENDED_FLAGS would clear the extended flags we want to read.
42
43Consequently, if a program temporarily alters the QuickEdit flag (e.g. to
44enable mouse input), it cannot restore the original values of the QuickEdit
45and InsertMode flags, UNLESS every other console program cooperates by
46keeping the ExtendedFlags flag set.