mirror of
https://github.com/reactos/reactos.git
synced 2025-05-06 10:28:45 +00:00
[CONSRV] Deduplicate GetScreenBufferSizeUnits(), SmallRectToRect() and ConsoleInput. Rename ConsoleList and InsertConsole(). #179
This commit is contained in:
parent
9d91a2e8ce
commit
6429bfcd8f
7 changed files with 46 additions and 79 deletions
|
@ -14,15 +14,6 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
// ConDrvAddInputEvents
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
static ULONG CurrentConsoleID = 0;
|
||||
|
||||
/* Linked list of consoles */
|
||||
static LIST_ENTRY ConsoleList;
|
||||
static LIST_ENTRY ConDrvConsoleList;
|
||||
static RTL_RESOURCE ListLock;
|
||||
|
||||
#define ConDrvLockConsoleListExclusive() \
|
||||
|
@ -37,7 +37,7 @@ static RTL_RESOURCE ListLock;
|
|||
|
||||
|
||||
static NTSTATUS
|
||||
InsertConsole(IN PCONSOLE Console)
|
||||
ConDrvInsertConsole(IN PCONSOLE Console)
|
||||
{
|
||||
ASSERT(Console);
|
||||
|
||||
|
@ -45,7 +45,7 @@ InsertConsole(IN PCONSOLE Console)
|
|||
ConDrvLockConsoleListExclusive();
|
||||
|
||||
DPRINT("Insert in the list\n");
|
||||
InsertTailList(&ConsoleList, &Console->ListEntry);
|
||||
InsertTailList(&ConDrvConsoleList, &Console->ListEntry);
|
||||
|
||||
// FIXME: Move this code to the caller function!!
|
||||
/* Get a new console ID */
|
||||
|
@ -152,7 +152,7 @@ ConDrvInitConsoleSupport(VOID)
|
|||
DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
|
||||
|
||||
/* Initialize the console list and its lock */
|
||||
InitializeListHead(&ConsoleList);
|
||||
InitializeListHead(&ConDrvConsoleList);
|
||||
RtlInitializeResource(&ListLock);
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
|||
DPRINT("Console initialized\n");
|
||||
|
||||
/* All went right, so add the console to the list */
|
||||
Status = InsertConsole(Console);
|
||||
Status = ConDrvInsertConsole(Console);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Fail */
|
||||
|
|
|
@ -54,6 +54,11 @@ typedef struct _CONSOLE_PROCESS_DATA
|
|||
// LPTHREAD_START_ROUTINE ImeRoutine;
|
||||
} CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
// Helper for code refactoring
|
||||
// #define USE_NEW_CONSOLE_WAY
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "font.h"
|
||||
#include "guiterm.h"
|
||||
#include "conwnd.h"
|
||||
#include "resource.h"
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
@ -172,28 +171,6 @@ UnRegisterConWndClass(HINSTANCE hInstance)
|
|||
return !!UnregisterClassW(GUI_CONWND_CLASS, hInstance);
|
||||
}
|
||||
|
||||
|
||||
/* NOTE: Also used in guiterm.c */
|
||||
/* static */ VOID
|
||||
GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
|
||||
IN PGUI_CONSOLE_DATA GuiData,
|
||||
OUT PUINT WidthUnit,
|
||||
OUT PUINT HeightUnit)
|
||||
{
|
||||
ASSERT(Buffer && GuiData && WidthUnit && HeightUnit);
|
||||
|
||||
if (GetType(Buffer) == TEXTMODE_BUFFER)
|
||||
{
|
||||
*WidthUnit = GuiData->CharWidth ;
|
||||
*HeightUnit = GuiData->CharHeight;
|
||||
}
|
||||
else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
|
||||
{
|
||||
*WidthUnit = 1;
|
||||
*HeightUnit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
AppendMenuItems(HMENU hMenu,
|
||||
const GUICONSOLE_MENUITEM *Items)
|
||||
|
@ -742,20 +719,6 @@ OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
|
|||
DPRINT("TODO: Destroy console caret\n");
|
||||
}
|
||||
|
||||
static VOID
|
||||
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
|
||||
UINT WidthUnit, HeightUnit;
|
||||
|
||||
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
|
||||
|
||||
Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
Rect->right = (SmallRect->Right + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
}
|
||||
|
||||
VOID
|
||||
GetSelectionBeginEnd(PCOORD Begin, PCOORD End,
|
||||
PCOORD SelectionAnchor,
|
||||
|
|
|
@ -56,13 +56,6 @@ UnRegisterConWndClass(HINSTANCE hInstance);
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
/* NOTE: Defined in conwnd.c */
|
||||
VOID
|
||||
GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
|
||||
IN PGUI_CONSOLE_DATA GuiData,
|
||||
OUT PUINT WidthUnit,
|
||||
OUT PUINT HeightUnit);
|
||||
|
||||
VOID
|
||||
GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
|
||||
{
|
||||
|
@ -78,20 +71,6 @@ GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
|
|||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
|
||||
UINT WidthUnit, HeightUnit;
|
||||
|
||||
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
|
||||
|
||||
Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
Rect->right = (SmallRect->Right + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
}
|
||||
|
||||
static VOID
|
||||
DrawRegion(PGUI_CONSOLE_DATA GuiData,
|
||||
SMALL_RECT* Region)
|
||||
|
|
|
@ -14,6 +14,42 @@
|
|||
#include "guisettings.h"
|
||||
#include "conwnd.h"
|
||||
|
||||
extern inline
|
||||
VOID
|
||||
GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
|
||||
IN PGUI_CONSOLE_DATA GuiData,
|
||||
OUT PUINT WidthUnit,
|
||||
OUT PUINT HeightUnit)
|
||||
{
|
||||
ASSERT(Buffer && GuiData && WidthUnit && HeightUnit);
|
||||
|
||||
if (GetType(Buffer) == TEXTMODE_BUFFER)
|
||||
{
|
||||
*WidthUnit = GuiData->CharWidth ;
|
||||
*HeightUnit = GuiData->CharHeight;
|
||||
}
|
||||
else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
|
||||
{
|
||||
*WidthUnit = 1;
|
||||
*HeightUnit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
extern inline
|
||||
VOID
|
||||
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
|
||||
UINT WidthUnit, HeightUnit;
|
||||
|
||||
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
|
||||
|
||||
Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
Rect->right = (SmallRect->Right + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
|
||||
Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
|
||||
}
|
||||
|
||||
VOID
|
||||
GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
|
||||
|
||||
|
|
|
@ -40,13 +40,6 @@
|
|||
ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
|
||||
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
#if 0
|
||||
|
|
Loading…
Reference in a new issue