30#define MORE_STRING _T("-- Press space to view more. Press q or Ctrl+break to cancel.--")
31#define MORE_EMPTY_STRING _T(" ")
102 DWORD dwCharsWrittenAdd = 0;
106 switch(
p[dwCharsWrittenAdd])
176 DWORD dwRecordsReaded;
179 ASSERT(dwRecordsReaded == 1);
180 if (dwRecordsReaded != 1)
271#define X_CURSOR_POSITION_FROM_OFFSET(ofs) USHORT(((FristCharCursorPosition.X + ofs)%m_BufferSize.X))
272#define Y_CURSOR_POSITION_FROM_OFFSET(ofs) USHORT((FristCharCursorPosition.Y + (FristCharCursorPosition.X + ofs)/m_BufferSize.X))
275 DWORD dwRecordsReaded;
276 DWORD dwCurrentCharOffset = 0;
277 DWORD dwLastCharOffset = 0;
282 unsigned long long nCompletionIndex = 0;
283 DWORD dwCompletionOffset = 0;
284 DWORD dwCompletionStringSize = 0;
285 COORD CompletionPosition = FristCharCursorPosition;
291 DWORD dwHistoryIndex = 0;
296 ASSERT(dwRecordsReaded == 1);
297 if (dwRecordsReaded != 1)
return FALSE;
336 if (blnCompletionMode) blnCompletionMode =
FALSE;
388 if ((
m_blnInsetMode)||(dwCurrentCharOffset == dwLastCharOffset)) dwLastCharOffset++;
389 dwCurrentCharOffset++;
394 DWORD ofs = dwCurrentCharOffset;
396 while(ofs <= dwLastCharOffset)
404 if (dwCurrentCharOffset < dwLastCharOffset)
427 if (blnCompletionMode) blnCompletionMode =
FALSE;
428 if (dwCurrentCharOffset)
449 ASSERT(dwCurrentCharOffset < dwLastCharOffset);
457 dwCurrentCharOffset--;
474 if (blnCompletionMode) blnCompletionMode =
FALSE;
475 if (dwCurrentCharOffset < dwLastCharOffset)
494 ASSERT(dwCurrentCharOffset <= dwLastCharOffset);
501 dwCurrentCharOffset++;
514 if (blnCompletionMode) blnCompletionMode =
FALSE;
515 dwCurrentCharOffset = 0;
521 if (blnCompletionMode) blnCompletionMode =
FALSE;
522 dwCurrentCharOffset = dwLastCharOffset;
529 if (blnCompletionMode) blnCompletionMode =
FALSE;
534 if (dwLastCharOffset)
540 dwCurrentCharOffset = dwLastCharOffset = 0;
544 dwCurrentCharOffset = dwLastCharOffset =
_tcslen(pchHistoryLine);
560 if (blnCompletionMode) blnCompletionMode =
FALSE;
565 if (dwLastCharOffset)
571 dwCurrentCharOffset = dwLastCharOffset = 0;
577 dwCurrentCharOffset = dwLastCharOffset =
_tcslen(pchHistoryLine);
593 DWORD dwCharOffset = dwCurrentCharOffset;
594 if (dwCharOffset < dwLastCharOffset)
596 while(dwCharOffset < dwLastCharOffset)
623 else if ((ch == 27) && dwLastCharOffset &&
626 if (blnCompletionMode) blnCompletionMode =
FALSE;
631 dwCurrentCharOffset = dwLastCharOffset = 0;
635 else if (ch ==
_T(
'\r'))
642 static TCHAR strLF[] =
_T(
"\n");
646 else if (ch ==
_T(
'\b'))
648 if (blnCompletionMode) blnCompletionMode =
FALSE;
652 COORD NewCursorPosition;
668 DWORD dwCharOffset = dwCurrentCharOffset-1;
669 while(dwCharOffset < dwLastCharOffset-1)
677 dwCurrentCharOffset--;
688 else if (ch ==
_T(
'\t'))
691 if (!blnCompletionMode)
695 nCompletionIndex = (
unsigned long long) -1;
697 nCompletionIndex = 0;
700 dwCompletionOffset = dwCurrentCharOffset;
702 while(dwCompletionOffset)
704 dwCompletionOffset--;
707 blnQuotedParameter = !blnQuotedParameter;
711 dwCompletionOffset++;
716 ASSERT(dwCompletionOffset <= dwCurrentCharOffset);
725 dwCompletionStringSize = dwCurrentCharOffset-dwCompletionOffset;
728 if (dwCompletionStringSize)
744 blnCompletionMode?&blnForward:
NULL,
759 DWORD dwOldCompletionStringSize = dwCompletionStringSize;
762 dwCompletionStringSize =
_tcslen(pchCompletion);
765 if (dwCompletionStringSize > dwFree)
766 dwCompletionStringSize = dwFree;
768 if (dwCompletionStringSize)
778 dwCurrentCharOffset = dwLastCharOffset = dwCompletionOffset + dwCompletionStringSize;
784 if (dwOldCompletionStringSize > dwCompletionStringSize)
787 dwOldCompletionStringSize - dwCompletionStringSize);
793 dwOldCompletionStringSize - dwCompletionStringSize))
804 blnCompletionMode =
TRUE;
808 if (blnCompletionMode) blnCompletionMode =
FALSE;
819 if ((
m_blnInsetMode)||(dwCurrentCharOffset == dwLastCharOffset)) dwLastCharOffset++;
820 dwCurrentCharOffset++;
825 DWORD ofs = dwCurrentCharOffset;
827 while(ofs <= dwLastCharOffset)
835 if (dwCurrentCharOffset < dwLastCharOffset)
962 if (dwMaxHistoryLines)
964 if (!
m_History.
Init(dwBufferSize,dwMaxHistoryLines))
goto Abort;
1000 static COORD BufferCoord = {0,0};
1025 static COORD BufferCoord = {0,0};
1068 DWORD dwRecordsWriten;
const TCHAR *(* ReplaceCompletionCallback)(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pchContext, const TCHAR *pchBegin)
#define Y_CURSOR_POSITION_FROM_OFFSET(ofs)
#define X_CURSOR_POSITION_FROM_OFFSET(ofs)
#define MORE_EMPTY_STRING
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
BOOL WINAPI SetConsoleCursorInfo(IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
ReplaceCompletionCallback m_pfReplaceCompletionCallback
BOOL m_blnOldInputModeSaved
BOOL SetInsertMode(BOOL blnInsetMode)
BOOL SetTitle(const TCHAR *p)
unsigned int GetTabWidth()
BOOL WriteString(const TCHAR *pchString, COORD Position)
void BeginScrollingOperation()
BOOL SetTextAttribute(WORD wAttributes)
TCHAR * Init(DWORD dwBufferSize, DWORD dwMaxHistoryLines=0)
BOOL m_blnOldOutputModeSaved
BOOL GetTextAttribute(WORD &rwAttributes)
DWORD m_dwOverwriteModeCursorHeight
BOOL Write(const TCHAR *p, DWORD dwChars=0)
DWORD m_dwInsertModeCursorHeight
void SetReplaceCompletionCallback(ReplaceCompletionCallback pfCallback)
void AddHistoryLine(const TCHAR *pchLine)
BOOL Init(DWORD dwMaxHistoryLineSize, DWORD dwMaxHistoryLines)
const TCHAR * GetHistoryLine(DWORD dwIndex)
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
#define INVALID_HANDLE_VALUE
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent(DWORD dwCtrlEvent, DWORD dwProcessGroupId)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
union _CHAR_INFO::@3284 Char
union _KEY_EVENT_RECORD::@3285 uChar
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
#define STD_OUTPUT_HANDLE
DWORD WINAPI GetLastError(void)
*nSize LPSTR _Inout_ LPDWORD nSize
#define LEFT_CTRL_PRESSED
#define RIGHT_CTRL_PRESSED
#define WriteConsoleInput
#define ScrollConsoleScreenBuffer
#define WriteConsoleOutput
BOOL WINAPI CloseClipboard(void)
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
HANDLE WINAPI GetClipboardData(_In_ UINT)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)