本文整理汇总了C++中Viewport::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::Left方法的具体用法?C++ Viewport::Left怎么用?C++ Viewport::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::Left方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteConvRegionToScreen
void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo,
const Viewport& convRegion)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
if (!ScreenInfo.IsActiveScreenBuffer())
{
return;
}
ConsoleImeInfo* const pIme = &gci.ConsoleIme;
for (unsigned int i = 0; i < pIme->ConvAreaCompStr.size(); ++i)
{
const auto& ConvAreaInfo = pIme->ConvAreaCompStr[i];
if (!ConvAreaInfo.IsHidden())
{
const auto currentViewport = ScreenInfo.GetViewport().ToInclusive();
const auto areaInfo = ConvAreaInfo.GetAreaBufferInfo();
// Do clipping region
SMALL_RECT Region;
Region.Left = currentViewport.Left + areaInfo.rcViewCaWindow.Left + areaInfo.coordConView.X;
Region.Right = Region.Left + (areaInfo.rcViewCaWindow.Right - areaInfo.rcViewCaWindow.Left);
Region.Top = currentViewport.Top + areaInfo.rcViewCaWindow.Top + areaInfo.coordConView.Y;
Region.Bottom = Region.Top + (areaInfo.rcViewCaWindow.Bottom - areaInfo.rcViewCaWindow.Top);
SMALL_RECT ClippedRegion;
ClippedRegion.Left = std::max(Region.Left, currentViewport.Left);
ClippedRegion.Top = std::max(Region.Top, currentViewport.Top);
ClippedRegion.Right = std::min(Region.Right, currentViewport.Right);
ClippedRegion.Bottom = std::min(Region.Bottom, currentViewport.Bottom);
if (IsValidSmallRect(&ClippedRegion))
{
Region = ClippedRegion;
ClippedRegion.Left = std::max(Region.Left, convRegion.Left());
ClippedRegion.Top = std::max(Region.Top, convRegion.Top());
ClippedRegion.Right = std::min(Region.Right, convRegion.RightInclusive());
ClippedRegion.Bottom = std::min(Region.Bottom, convRegion.BottomInclusive());
if (IsValidSmallRect(&ClippedRegion))
{
// if we have a renderer, we need to update.
// we've already confirmed (above with an early return) that we're on conversion areas that are a part of the active (visible/rendered) screen
// so send invalidates to those regions such that we're queried for data on the next frame and repainted.
if (ServiceLocator::LocateGlobals().pRender != nullptr)
{
// convert inclusive rectangle to exclusive rectangle
SMALL_RECT srExclusive = ClippedRegion;
srExclusive.Right++;
srExclusive.Bottom++;
ServiceLocator::LocateGlobals().pRender->TriggerRedraw(Viewport::FromExclusive(srExclusive));
}
}
}
}
}
}
示例2: WordByWordSelection
// Routine Description:
// - Modifies the given selection point to the edge of the next (or previous) word.
// - By default operates in a left-to-right fashion.
// Arguments:
// - fReverse: Specifies that this function should operate in reverse. E.g. Right-to-left.
// - bufferSize: The dimensions of the screen buffer.
// - coordAnchor: The point within the buffer (inside the edges) where this selection started.
// - coordSelPoint: Defines selection region from coordAnchor to this point. Modified to define the new selection region.
// Return Value:
// - <none>
COORD Selection::WordByWordSelection(const bool fReverse,
const Viewport& bufferSize,
const COORD coordAnchor,
const COORD coordSelPoint) const
{
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
const SCREEN_INFORMATION& screenInfo = gci.GetActiveOutputBuffer();
COORD outCoord = coordSelPoint;
// first move one character in the requested direction
if (!fReverse)
{
bufferSize.IncrementInBounds(outCoord);
}
else
{
bufferSize.DecrementInBounds(outCoord);
}
// get the character at the new position
auto charData = *screenInfo.GetTextDataAt(outCoord);
// we want to go until the state change from delim to non-delim
bool fCurrIsDelim = IsWordDelim(charData);
bool fPrevIsDelim;
// find the edit-line boundaries that we can highlight
COORD coordMaxLeft;
COORD coordMaxRight;
const bool fSuccess = s_GetInputLineBoundaries(&coordMaxLeft, &coordMaxRight);
// if line boundaries fail, then set them to the buffer corners so they don't restrict anything.
if (!fSuccess)
{
coordMaxLeft.X = bufferSize.Left();
coordMaxLeft.Y = bufferSize.Top();
coordMaxRight.X = bufferSize.RightInclusive();
coordMaxRight.Y = bufferSize.BottomInclusive();
}
// track whether we failed to move during an operation
// if we failed to move, we hit the end of the buffer and should just highlight to there and be done.
bool fMoveSucceeded = false;
// determine if we're highlighting more text or unhighlighting already selected text.
bool fUnhighlighting;
if (!fReverse)
{
// if the selection point is left of the anchor, then we're unhighlighting when moving right
fUnhighlighting = Utils::s_CompareCoords(outCoord, coordAnchor) < 0;
}
else
{
// if the selection point is right of the anchor, then we're unhighlighting when moving left
fUnhighlighting = Utils::s_CompareCoords(outCoord, coordAnchor) > 0;
}
do
{
// store previous state
fPrevIsDelim = fCurrIsDelim;
// to make us "sticky" within the edit line, stop moving once we've reached a given max position left/right
// users can repeat the command to move past the line and continue word selecting
// if we're at the max position left, stop moving
if (Utils::s_CompareCoords(outCoord, coordMaxLeft) == 0)
{
// set move succeeded to false as we can't move any further
fMoveSucceeded = false;
break;
}
// if we're at the max position right, stop moving.
// we don't want them to "word select" past the end of the edit line as there's likely nothing there.
// (thus >= and not == like left)
if (Utils::s_CompareCoords(outCoord, coordMaxRight) >= 0)
{
// set move succeeded to false as we can't move any further.
fMoveSucceeded = false;
break;
}
if (!fReverse)
{
fMoveSucceeded = bufferSize.IncrementInBounds(outCoord);
}
else
{
fMoveSucceeded = bufferSize.DecrementInBounds(outCoord);
//.........这里部分代码省略.........