can move cursor to beginning and end of prompt text
This commit is contained in:
parent
dcb0334724
commit
387186d280
|
@ -680,26 +680,11 @@ COORD CommandLine::_deletePromptBeforeCursor(CookedRead& cookedReadData) noexcep
|
|||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorToEndOfPrompt(CookedRead& cookedReadData) noexcept
|
||||
{
|
||||
/*
|
||||
cookedReadData.InsertionPoint() = cookedReadData.BytesRead() / sizeof(WCHAR);
|
||||
cookedReadData.SetBufferCurrentPtr(cookedReadData.BufferStartPtr() + cookedReadData.InsertionPoint());
|
||||
COORD cursorPosition{ 0, 0 };
|
||||
cursorPosition.X = (SHORT)(cookedReadData.OriginalCursorPosition().X + cookedReadData.VisibleCharCount());
|
||||
cursorPosition.Y = cookedReadData.OriginalCursorPosition().Y;
|
||||
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectProcessW(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint(),
|
||||
sScreenBufferSizeX - cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.OriginalCursorPosition().X,
|
||||
true))
|
||||
{
|
||||
cursorPosition.X++;
|
||||
}
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
const size_t cellsMoved = cookedReadData.MoveInsertionIndexToEnd();
|
||||
// the cursor is adjusted to be within the bounds of the screen later, don't need to worry about it here
|
||||
cursorPosition.X += gsl::narrow<short>(cellsMoved);
|
||||
return cursorPosition;
|
||||
*/
|
||||
return cookedReadData.PromptStartLocation();
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -710,11 +695,7 @@ COORD CommandLine::_moveCursorToEndOfPrompt(CookedRead& cookedReadData) noexcept
|
|||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorToStartOfPrompt(CookedRead& cookedReadData) noexcept
|
||||
{
|
||||
/*
|
||||
cookedReadData.InsertionPoint() = 0;
|
||||
cookedReadData.SetBufferCurrentPtr(cookedReadData.BufferStartPtr());
|
||||
return cookedReadData.OriginalCursorPosition();
|
||||
*/
|
||||
cookedReadData.MoveInsertionIndexToStart();
|
||||
return cookedReadData.PromptStartLocation();
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,25 @@ size_t CookedRead::MoveInsertionIndexRight()
|
|||
return cellsMoved;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - moves insertion index to the beginning of the prompt
|
||||
void CookedRead::MoveInsertionIndexToStart() noexcept
|
||||
{
|
||||
_insertionIndex = 0;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - moves insertion index to the end of the prompt
|
||||
// Return Value:
|
||||
// - the number of cells that the insertion point has moved by
|
||||
size_t CookedRead::MoveInsertionIndexToEnd()
|
||||
{
|
||||
const size_t leftCells = _calculatePromptCellLength(false);
|
||||
const size_t allCells = _calculatePromptCellLength(true);
|
||||
_insertionIndex = _prompt.size();
|
||||
return allCells - leftCells;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - checks if wch matches up with the control character masking for early data return
|
||||
// Arguments:
|
||||
|
@ -522,6 +541,7 @@ void CookedRead::_writeToScreen(const bool resetCursor)
|
|||
_status = WriteCharsLegacy(_screenInfo,
|
||||
_prompt.c_str(),
|
||||
_prompt.c_str(),
|
||||
|
||||
_prompt.c_str(),
|
||||
&bytesToWrite,
|
||||
nullptr,
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
size_t MoveInsertionIndexLeft();
|
||||
size_t MoveInsertionIndexRight();
|
||||
void MoveInsertionIndexToStart() noexcept;
|
||||
size_t MoveInsertionIndexToEnd();
|
||||
|
||||
SCREEN_INFORMATION& ScreenInfo();
|
||||
|
||||
|
|
Loading…
Reference in a new issue