wchar_t* Buffer, NumberOfCharsToWrite
| 995 | |
| 996 | // wchar_t* Buffer, NumberOfCharsToWrite |
| 997 | BOOL ExtWriteText(ExtWriteTextParm* Info) |
| 998 | { |
| 999 | if (!Info || (Info->StructSize < sizeof(*Info))) |
| 1000 | { |
| 1001 | _ASSERTE(Info!=NULL && (Info->StructSize >= sizeof(*Info))); |
| 1002 | SetLastError(E_INVALIDARG); |
| 1003 | return FALSE; |
| 1004 | } |
| 1005 | |
| 1006 | #ifdef _DEBUG |
| 1007 | // extern FARPROC CallWriteConsoleW; |
| 1008 | _ASSERTE((CallWriteConsoleW!=NULL) || !HooksWereSet); |
| 1009 | // ReSharper disable twice CppCStyleCast |
| 1010 | _ASSERTE((Info->Private == NULL) || (Info->Private == (void*)CallWriteConsoleW) || (!HooksWereSet && (Info->Private == (void*)WriteConsoleW))); |
| 1011 | #endif |
| 1012 | |
| 1013 | // Arguments validation |
| 1014 | if (!Info->ConsoleOutput || !Info->Buffer || !Info->NumberOfCharsToWrite) |
| 1015 | { |
| 1016 | _ASSERTE(Info->ConsoleOutput && Info->Buffer && Info->NumberOfCharsToWrite); |
| 1017 | SetLastError(E_INVALIDARG); |
| 1018 | return FALSE; |
| 1019 | } |
| 1020 | |
| 1021 | BOOL lbTrueColor = ExtCheckBuffers(Info->ConsoleOutput); |
| 1022 | UNREFERENCED_PARAMETER(lbTrueColor); |
| 1023 | |
| 1024 | HANDLE h = Info->ConsoleOutput; |
| 1025 | CONSOLE_SCREEN_BUFFER_INFO csbi = {}; |
| 1026 | SMALL_RECT srWork = {}; |
| 1027 | if (!ExtGetBufferInfo(h, csbi, srWork)) |
| 1028 | { |
| 1029 | return FALSE; |
| 1030 | } |
| 1031 | |
| 1032 | bool bWrap = true; |
| 1033 | bool bVirtualWrap = false; |
| 1034 | bool bRevertMode = false; |
| 1035 | SHORT WrapAtCol = csbi.dwSize.X; // 1-based |
| 1036 | DWORD Mode = 0; |
| 1037 | |
| 1038 | // "Working lines" may be defined (Vim and others) |
| 1039 | LONG scrollTop = 0, scrollBottom = 0; |
| 1040 | bool bScrollRegion = !!(Info->Flags & ewtf_Region); |
| 1041 | RECT rcScrollRegion = Info->Region; |
| 1042 | COORD crScrollCursor = {}; |
| 1043 | if (bScrollRegion) |
| 1044 | { |
| 1045 | _ASSERTEX(Info->Region.left==-1 && Info->Region.right==-1); // Not used yet |
| 1046 | rcScrollRegion.left = 0; rcScrollRegion.right = (csbi.dwSize.X - 1); |
| 1047 | _ASSERTEX(Info->Region.top>=0 && Info->Region.bottom>=Info->Region.top); |
| 1048 | scrollTop = Info->Region.top; |
| 1049 | scrollBottom = Info->Region.bottom+1; |
| 1050 | } |
| 1051 | else |
| 1052 | { |
| 1053 | scrollTop = 0; |
| 1054 | scrollBottom = csbi.dwSize.Y; |
no test coverage detected