| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | #ifndef _APISETCONSOLE_ |
| 8 | #define _APISETCONSOLE_ |
| 9 | |
| 10 | #include <_mingw_unicode.h> |
| 11 | |
| 12 | #include <apiset.h> |
| 13 | #include <apisetcconv.h> |
| 14 | #include <minwinbase.h> |
| 15 | #include <minwindef.h> |
| 16 | |
| 17 | #include <wincontypes.h> |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) |
| 24 | |
| 25 | WINBASEAPI WINBOOL WINAPI AllocConsole(void); |
| 26 | |
| 27 | #if (NTDDI_VERSION >= NTDDI_WIN11_GE) |
| 28 | |
| 29 | typedef enum ALLOC_CONSOLE_MODE { |
| 30 | ALLOC_CONSOLE_MODE_DEFAULT = 0, |
| 31 | ALLOC_CONSOLE_MODE_NEW_WINDOW = 1, |
| 32 | ALLOC_CONSOLE_MODE_NO_WINDOW = 2 |
| 33 | } ALLOC_CONSOLE_MODE; |
| 34 | |
| 35 | typedef struct ALLOC_CONSOLE_OPTIONS { |
| 36 | ALLOC_CONSOLE_MODE mode; |
| 37 | WINBOOL useShowWindow; |
| 38 | WORD showWindow; |
| 39 | } ALLOC_CONSOLE_OPTIONS, *PALLOC_CONSOLE_OPTIONS; |
| 40 | |
| 41 | typedef enum ALLOC_CONSOLE_RESULT { |
| 42 | ALLOC_CONSOLE_RESULT_NO_CONSOLE = 0, |
| 43 | ALLOC_CONSOLE_RESULT_NEW_CONSOLE = 1, |
| 44 | ALLOC_CONSOLE_RESULT_EXISTING_CONSOLE = 2 |
| 45 | } ALLOC_CONSOLE_RESULT, *PALLOC_CONSOLE_RESULT; |
| 46 | |
| 47 | WINBASEAPI HRESULT WINAPI AllocConsoleWithOptions(PALLOC_CONSOLE_OPTIONS options, PALLOC_CONSOLE_RESULT result); |
| 48 | |
| 49 | #endif /* NTDDI_VERSION >= NTDDI_WIN11_GE */ |
| 50 | |
| 51 | WINBASEAPI WINBOOL WINAPI FreeConsole(void); |
| 52 | |
| 53 | #if (_WIN32_WINNT >= 0x0500) |
| 54 | |
| 55 | WINBASEAPI WINBOOL WINAPI AttachConsole(DWORD process_id); |
| 56 | |
| 57 | #define ATTACH_PARENT_PROCESS ((DWORD)-1) |
| 58 | |
| 59 | #endif /* _WIN32_WINNT >= 0x0500 */ |
| 60 | |
| 61 | WINBASEAPI UINT WINAPI GetConsoleCP(void); |
| 62 | WINBASEAPI UINT WINAPI GetConsoleOutputCP(void); |
| 63 | |
| 64 | #define ENABLE_PROCESSED_INPUT 0x0001 |
| 65 | #define ENABLE_LINE_INPUT 0x0002 |
| 66 | #define ENABLE_ECHO_INPUT 0x0004 |
| 67 | #define ENABLE_WINDOW_INPUT 0x0008 |
| 68 | #define ENABLE_MOUSE_INPUT 0x0010 |
| 69 | #define ENABLE_INSERT_MODE 0x0020 |
| 70 | #define ENABLE_QUICK_EDIT_MODE 0x0040 |
| 71 | #define ENABLE_EXTENDED_FLAGS 0x0080 |
| 72 | #define ENABLE_AUTO_POSITION 0x0100 |
| 73 | #define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 |
| 74 | |
| 75 | #define ENABLE_PROCESSED_OUTPUT 0x0001 |
| 76 | #define ENABLE_WRAP_AT_EOL_OUTPUT 0x0002 |
| 77 | #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 |
| 78 | #define DISABLE_NEWLINE_AUTO_RETURN 0x0008 |
| 79 | #define ENABLE_LVB_GRID_WORLDWIDE 0x0010 |
| 80 | |
| 81 | WINBASEAPI WINBOOL WINAPI GetConsoleMode(HANDLE console_handle, LPDWORD mode); |
| 82 | WINBASEAPI WINBOOL WINAPI SetConsoleMode(HANDLE console_handle, DWORD mode); |
| 83 | WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE console_input, LPDWORD number_of_events); |
| 84 | |
| 85 | WINBASEAPI WINBOOL WINAPI ReadConsoleInputA(HANDLE console_input, PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read); |
| 86 | WINBASEAPI WINBOOL WINAPI ReadConsoleInputW(HANDLE console_input, PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read); |
| 87 | #define ReadConsoleInput __MINGW_NAME_AW(ReadConsoleInput) |
| 88 | |
| 89 | WINBASEAPI WINBOOL WINAPI PeekConsoleInputA(HANDLE console_input, PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read); |
| 90 | WINBASEAPI WINBOOL WINAPI PeekConsoleInputW(HANDLE console_input, PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read); |
| 91 | #define PeekConsoleInput __MINGW_NAME_AW(PeekConsoleInput) |
| 92 | |
| 93 | typedef struct _CONSOLE_READCONSOLE_CONTROL { |
| 94 | ULONG nLength; |
| 95 | ULONG nInitialChars; |
| 96 | ULONG dwCtrlWakeupMask; |
| 97 | ULONG dwControlKeyState; |
| 98 | } CONSOLE_READCONSOLE_CONTROL, *PCONSOLE_READCONSOLE_CONTROL; |
| 99 | |
| 100 | WINBASEAPI WINBOOL WINAPI ReadConsoleA(HANDLE console_input, LPVOID buffer, DWORD number_of_chars_to_read, LPDWORD number_of_chars_read, PCONSOLE_READCONSOLE_CONTROL input_control); |
| 101 | WINBASEAPI WINBOOL WINAPI ReadConsoleW(HANDLE console_input, LPVOID buffer, DWORD number_of_chars_to_read, LPDWORD number_of_chars_read, PCONSOLE_READCONSOLE_CONTROL input_control); |
| 102 | #define ReadConsole __MINGW_NAME_AW(ReadConsole) |
| 103 | |
| 104 | WINBASEAPI WINBOOL WINAPI WriteConsoleA(HANDLE console_output, const void *buffer, DWORD number_of_chars_to_write, LPDWORD number_of_chars_written, LPVOID reserved); |
| 105 | WINBASEAPI WINBOOL WINAPI WriteConsoleW(HANDLE console_output, const void *buffer, DWORD number_of_chars_to_write, LPDWORD number_of_chars_written, LPVOID reserved); |
| 106 | #define WriteConsole __MINGW_NAME_AW(WriteConsole) |
| 107 | |
| 108 | #define CTRL_C_EVENT 0 |
| 109 | #define CTRL_BREAK_EVENT 1 |
| 110 | #define CTRL_CLOSE_EVENT 2 |
| 111 | #define CTRL_LOGOFF_EVENT 5 |
| 112 | #define CTRL_SHUTDOWN_EVENT 6 |
| 113 | |
| 114 | typedef WINBOOL (WINAPI *PHANDLER_ROUTINE)(DWORD ctrl_type); |
| 115 | WINBASEAPI WINBOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE handler_routine, WINBOOL add); |
| 116 | |
| 117 | #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */ |
| 118 | |
| 119 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 120 | |
| 121 | #if (NTDDI_VERSION >= NTDDI_WIN10_RS5) |
| 122 | #define PSEUDOCONSOLE_INHERIT_CURSOR (0x1) |
| 123 | |
| 124 | WINBASEAPI HRESULT WINAPI CreatePseudoConsole(COORD size, HANDLE input, HANDLE output, DWORD flags, HPCON *pc); |
| 125 | WINBASEAPI HRESULT WINAPI ResizePseudoConsole(HPCON pc, COORD size); |
| 126 | WINBASEAPI void WINAPI ClosePseudoConsole(HPCON pc); |
| 127 | #endif |
| 128 | |
| 129 | #if (NTDDI_VERSION >= NTDDI_WIN11_GE) |
| 130 | WINBASEAPI HRESULT WINAPI ReleasePseudoConsole(HPCON pc); |
| 131 | #endif |
| 132 | |
| 133 | #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ |
| 134 | |
| 135 | #ifdef __cplusplus |
| 136 | } |
| 137 | #endif |
| 138 | |
| 139 | #endif /* _APISETCONSOLE_ */ |