mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[KERNEL32][CONSRV] Use more often the internal ConioRectHeight/Width() and ConioIsRectEmpty() macros.
This commit is contained in:
parent
05053b6f18
commit
570eba2a52
6 changed files with 22 additions and 26 deletions
|
@ -20,9 +20,9 @@
|
|||
|
||||
/* See consrv/include/rect.h */
|
||||
#define ConioRectHeight(Rect) \
|
||||
(((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
|
||||
(((Rect)->Top > (Rect)->Bottom) ? 0 : ((Rect)->Bottom - (Rect)->Top + 1))
|
||||
#define ConioRectWidth(Rect) \
|
||||
(((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
|
||||
(((Rect)->Left > (Rect)->Right) ? 0 : ((Rect)->Right - (Rect)->Left + 1))
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
@ -436,8 +436,7 @@ IntReadConsoleOutput(IN HANDLE hConsoleOutput,
|
|||
|
||||
/* Copy into the buffer */
|
||||
|
||||
SizeX = ReadOutputRequest->ReadRegion.Right -
|
||||
ReadOutputRequest->ReadRegion.Left + 1;
|
||||
SizeX = ConioRectWidth(&ReadOutputRequest->ReadRegion);
|
||||
|
||||
for (y = 0, Y = ReadOutputRequest->ReadRegion.Top; Y <= ReadOutputRequest->ReadRegion.Bottom; ++y, ++Y)
|
||||
{
|
||||
|
@ -913,8 +912,7 @@ IntWriteConsoleOutput(IN HANDLE hConsoleOutput,
|
|||
|
||||
/* Copy into the buffer */
|
||||
|
||||
SizeX = WriteOutputRequest->WriteRegion.Right -
|
||||
WriteOutputRequest->WriteRegion.Left + 1;
|
||||
SizeX = ConioRectWidth(&WriteOutputRequest->WriteRegion);
|
||||
|
||||
for (y = 0, Y = WriteOutputRequest->WriteRegion.Top; Y <= WriteOutputRequest->WriteRegion.Bottom; ++y, ++Y)
|
||||
{
|
||||
|
|
|
@ -1607,15 +1607,14 @@ ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
|
|||
}
|
||||
|
||||
/*
|
||||
* The MSDN documentation on SetConsoleWindowInfo is partially wrong about
|
||||
* The MSDN documentation on SetConsoleWindowInfo() is partially wrong about
|
||||
* the performed checks this API performs. While it is correct that the
|
||||
* 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
|
||||
* members, they can be equal.
|
||||
* members (the rectangle cannot be empty), they can be equal (describe one cell).
|
||||
* Also, if the 'Left' or 'Top' members are negative, this is automatically
|
||||
* corrected for, and the window rectangle coordinates are shifted accordingly.
|
||||
*/
|
||||
if ((CapturedWindowRect.Right < CapturedWindowRect.Left) ||
|
||||
(CapturedWindowRect.Bottom < CapturedWindowRect.Top))
|
||||
if (ConioIsRectEmpty(&CapturedWindowRect))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
@ -1627,8 +1626,8 @@ ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
|
|||
TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
|
||||
LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
|
||||
LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
|
||||
if ((CapturedWindowRect.Right - CapturedWindowRect.Left + 1 > LargestWindowSize.X) ||
|
||||
(CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1 > LargestWindowSize.Y))
|
||||
if ((ConioRectWidth(&CapturedWindowRect) > LargestWindowSize.X) ||
|
||||
(ConioRectHeight(&CapturedWindowRect) > LargestWindowSize.Y))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
@ -1652,8 +1651,8 @@ ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
|
|||
Buffer->ViewOrigin.X = CapturedWindowRect.Left;
|
||||
Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
|
||||
|
||||
Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
|
||||
Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
|
||||
Buffer->ViewSize.X = ConioRectWidth(&CapturedWindowRect);
|
||||
Buffer->ViewSize.Y = ConioRectHeight(&CapturedWindowRect);
|
||||
|
||||
TermResizeTerminal(Console);
|
||||
|
||||
|
|
|
@ -497,8 +497,8 @@ CSR_API(SrvReadConsoleOutput)
|
|||
|
||||
DPRINT("SrvReadConsoleOutput\n");
|
||||
|
||||
NumCells = (ReadOutputRequest->ReadRegion.Right - ReadOutputRequest->ReadRegion.Left + 1) *
|
||||
(ReadOutputRequest->ReadRegion.Bottom - ReadOutputRequest->ReadRegion.Top + 1);
|
||||
NumCells = ConioRectWidth(&ReadOutputRequest->ReadRegion) *
|
||||
ConioRectHeight(&ReadOutputRequest->ReadRegion);
|
||||
|
||||
/*
|
||||
* For optimization purposes, Windows (and hence ReactOS, too, for
|
||||
|
@ -562,8 +562,8 @@ CSR_API(SrvWriteConsoleOutput)
|
|||
|
||||
DPRINT("SrvWriteConsoleOutput\n");
|
||||
|
||||
NumCells = (WriteOutputRequest->WriteRegion.Right - WriteOutputRequest->WriteRegion.Left + 1) *
|
||||
(WriteOutputRequest->WriteRegion.Bottom - WriteOutputRequest->WriteRegion.Top + 1);
|
||||
NumCells = ConioRectWidth(&WriteOutputRequest->WriteRegion) *
|
||||
ConioRectHeight(&WriteOutputRequest->WriteRegion);
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(Process),
|
||||
WriteOutputRequest->OutputHandle,
|
||||
|
|
|
@ -32,8 +32,8 @@ GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
|
|||
|
||||
if (Buffer->BitMap == NULL) return;
|
||||
|
||||
selWidth = GuiData->Selection.srSelection.Right - GuiData->Selection.srSelection.Left + 1;
|
||||
selHeight = GuiData->Selection.srSelection.Bottom - GuiData->Selection.srSelection.Top + 1;
|
||||
selWidth = ConioRectWidth(&GuiData->Selection.srSelection);
|
||||
selHeight = ConioRectHeight(&GuiData->Selection.srSelection);
|
||||
DPRINT("Selection is (%d|%d) to (%d|%d)\n",
|
||||
GuiData->Selection.srSelection.Left,
|
||||
GuiData->Selection.srSelection.Top,
|
||||
|
|
|
@ -57,12 +57,11 @@ CopyBlock(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
Selection->Left, Selection->Top, Selection->Right, Selection->Bottom);
|
||||
|
||||
/* Prevent against empty blocks */
|
||||
if (Selection == NULL) return;
|
||||
if (Selection->Left > Selection->Right || Selection->Top > Selection->Bottom)
|
||||
if ((Selection == NULL) || ConioIsRectEmpty(Selection))
|
||||
return;
|
||||
|
||||
selWidth = Selection->Right - Selection->Left + 1;
|
||||
selHeight = Selection->Bottom - Selection->Top + 1;
|
||||
selWidth = ConioRectWidth(Selection);
|
||||
selHeight = ConioRectHeight(Selection);
|
||||
|
||||
/* Basic size for one line... */
|
||||
size = selWidth;
|
||||
|
|
|
@ -29,9 +29,9 @@ do { \
|
|||
(((Rect)->Left > (Rect)->Right) || ((Rect)->Top > (Rect)->Bottom))
|
||||
|
||||
#define ConioRectHeight(Rect) \
|
||||
(((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
|
||||
(((Rect)->Top > (Rect)->Bottom) ? 0 : ((Rect)->Bottom - (Rect)->Top + 1))
|
||||
#define ConioRectWidth(Rect) \
|
||||
(((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
|
||||
(((Rect)->Left > (Rect)->Right) ? 0 : ((Rect)->Right - (Rect)->Left + 1))
|
||||
|
||||
|
||||
static __inline BOOLEAN
|
||||
|
|
Loading…
Reference in a new issue