[CONSRV]: Use an optional parameter for passing things to the "line discipline" funct...
[reactos.git] / win32ss / user / winsrv / consrv / include / conio.h
index f4985e8..271a130 100644 (file)
 
 #pragma once
 
-#define CSR_DEFAULT_CURSOR_SIZE 25
+#include "rect.h"
+
+// This is ALMOST a HACK!!!!!!!
+// Helpers for code refactoring
+#ifdef USE_NEW_CONSOLE_WAY
+
+#define _CONSRV_CONSOLE  _WINSRV_CONSOLE
+#define  CONSRV_CONSOLE   WINSRV_CONSOLE
+#define PCONSRV_CONSOLE  PWINSRV_CONSOLE
+
+#else
+
+#define _CONSRV_CONSOLE  _CONSOLE
+#define  CONSRV_CONSOLE   CONSOLE
+#define PCONSRV_CONSOLE  PCONSOLE
+
+#endif
 
 /* Default attributes */
 #define DEFAULT_SCREEN_ATTRIB   (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
 #define DEFAULT_POPUP_ATTRIB    (FOREGROUND_BLUE | FOREGROUND_RED   | \
                                  BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
 
+
 /* Object type magic numbers */
 typedef enum _CONSOLE_IO_OBJECT_TYPE
 {
-//  ANY_TYPE_BUFFER = 0x00, // --> Match any types of IO handles
-    TEXTMODE_BUFFER = 0x01, // --> Output-type handles for text SBs
-    GRAPHICS_BUFFER = 0x02, // --> Output-type handles for graphics SBs
+    UNKNOWN         = 0x00, // --> Unknown object
+    TEXTMODE_BUFFER = 0x01, // --> Output-type object for text SBs
+    GRAPHICS_BUFFER = 0x02, // --> Output-type object for graphics SBs
     SCREEN_BUFFER   = 0x03, // --> Any SB type
-    INPUT_BUFFER    = 0x04  // --> Input-type handles
+    INPUT_BUFFER    = 0x04, // --> Input-type object
+    ANY_TYPE_BUFFER = 0x07, // --> Any IO object
 } CONSOLE_IO_OBJECT_TYPE;
 
 typedef struct _CONSOLE_IO_OBJECT
 {
     CONSOLE_IO_OBJECT_TYPE Type;
+
     struct _CONSOLE* /* PCONSOLE */ Console;
+    LONG ReferenceCount;    /* Is incremented each time a console object gets referenced */
+
     LONG AccessRead, AccessWrite;
     LONG ExclusiveRead, ExclusiveWrite;
-    LONG HandleCount;
 } CONSOLE_IO_OBJECT, *PCONSOLE_IO_OBJECT;
 
 
@@ -171,7 +191,7 @@ typedef struct _CONSOLE_INPUT_BUFFER
 {
     CONSOLE_IO_OBJECT Header;       /* Object header - MUST BE IN FIRST PLACE */
 
-    ULONG       InputBufferSize;    /* Size of this input buffer */
+    ULONG       InputBufferSize;    /* Size of this input buffer -- UNUSED!! */
     LIST_ENTRY  InputEvents;        /* List head for input event queue */
     HANDLE      ActiveEvent;        /* Event set when an input event is added in its queue */
 
@@ -190,17 +210,33 @@ typedef struct _TERMINAL_VTBL
                                    IN struct _CONSOLE* Console);
     VOID (NTAPI *DeinitTerminal)(IN OUT PTERMINAL This);
 
+
+
+/************ Line discipline ***************/
+
+    /* Interface used only for text-mode screen buffers */
+
+    NTSTATUS (NTAPI *ReadStream)(IN OUT PTERMINAL This,
+                                 IN BOOLEAN Unicode,
+                                 /**PWCHAR Buffer,**/
+                                 OUT PVOID Buffer,
+                                 IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
+                                 IN PVOID Parameter OPTIONAL,
+                                 IN ULONG NumCharsToRead,
+                                 OUT PULONG NumCharsRead OPTIONAL);
+    NTSTATUS (NTAPI *WriteStream)(IN OUT PTERMINAL This,
+                                  PTEXTMODE_SCREEN_BUFFER Buff,
+                                  PWCHAR Buffer,
+                                  DWORD Length,
+                                  BOOL Attrib);
+
+/************ Line discipline ***************/
+
+
+
     /* Interface used for both text-mode and graphics screen buffers */
     VOID (NTAPI *DrawRegion)(IN OUT PTERMINAL This,
                              SMALL_RECT* Region);
-    /* Interface used only for text-mode screen buffers */
-    VOID (NTAPI *WriteStream)(IN OUT PTERMINAL This,
-                              SMALL_RECT* Region,
-                              SHORT CursorStartX,
-                              SHORT CursorStartY,
-                              UINT ScrolledLines,
-                              PWCHAR Buffer,
-                              UINT Length);
     BOOL (NTAPI *SetCursorInfo)(IN OUT PTERMINAL This,
                                 PCONSOLE_SCREEN_BUFFER ScreenBuffer);
     BOOL (NTAPI *SetScreenInfo)(IN OUT PTERMINAL This,
@@ -215,11 +251,8 @@ typedef struct _TERMINAL_VTBL
     /*
      * External interface (functions corresponding to the Console API)
      */
-    VOID (NTAPI *ChangeTitle)(IN OUT PTERMINAL This);
     VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PTERMINAL This,
                                               PCOORD pSize);
-    // BOOL (NTAPI *GetSelectionInfo)(IN OUT PTERMINAL This,
-                                   // PCONSOLE_SELECTION_INFO pSelectionInfo);
     BOOL (NTAPI *SetPalette)(IN OUT PTERMINAL This,
                              HPALETTE PaletteHandle,
                              UINT PaletteUsage);
@@ -258,117 +291,65 @@ typedef enum _CONSOLE_STATE
 
 // HACK!!
 struct _CONSOLE;
-struct _WINSRV_CONSOLE;
 /* HACK: */ typedef struct _CONSOLE *PCONSOLE;
+#ifndef USE_NEW_CONSOLE_WAY
 #include "conio_winsrv.h"
+#endif
 
 typedef struct _CONSOLE
 {
 /******************************* Console Set-up *******************************/
+
+#ifndef USE_NEW_CONSOLE_WAY
+    WINSRV_CONSOLE; // HACK HACK!!
+#endif
+
     LONG ReferenceCount;                    /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
     CRITICAL_SECTION Lock;
 
-    /**/WINSRV_CONSOLE;/**/ // HACK HACK!!
-
     CONSOLE_STATE State;                    /* State of the console */
     TERMINAL TermIFace;                     /* Frontend-specific interface */
 
     ULONG ConsoleID;                        /* The ID of the console */
     LIST_ENTRY ListEntry;                   /* Entry in the list of consoles */
 
-/**************************** Input buffer and data ***************************/
+    HANDLE UnpauseEvent;                    /* When != NULL, event for pausing the console */
+
+/******************************** Input buffer ********************************/
     CONSOLE_INPUT_BUFFER InputBuffer;       /* Input buffer of the console */
     UINT InputCodePage;
 
-    /** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/
-    PWCHAR LineBuffer;                      /* Current line being input, in line buffered mode */
-    WORD LineMaxSize;                       /* Maximum size of line in characters (including CR+LF) */
-    WORD LineSize;                          /* Current size of line */
-    WORD LinePos;                           /* Current position within line */
-    BOOLEAN LineComplete;                   /* User pressed enter, ready to send back to client */
-    BOOLEAN LineUpPressed;
-    BOOLEAN LineInsertToggle;               /* Replace character over cursor instead of inserting */
-    ULONG LineWakeupMask;                   /* Bitmap of which control characters will end line input */
-    /***************************************************/
-
-    BOOLEAN InsertMode;
-
 /******************************* Screen buffers *******************************/
     LIST_ENTRY BufferList;                  /* List of all screen buffers for this console */
     PCONSOLE_SCREEN_BUFFER ActiveBuffer;    /* Pointer to currently active screen buffer */
     UINT OutputCodePage;
 
 /****************************** Other properties ******************************/
-    UNICODE_STRING OriginalTitle;           /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */
-    UNICODE_STRING Title;                   /* Title of console. Always NULL-terminated */
-
-    HANDLE UnpauseEvent;                    /* When != NULL, event for pausing the console */
-
     COORD   ConsoleSize;                    /* The current size of the console, for text-mode only */
     BOOLEAN FixedSize;                      /* TRUE if the console is of fixed size */
 
-    COLORREF Colors[16];                    /* Colour palette */
-
 } CONSOLE; // , *PCONSOLE;
 
-// #include "conio_winsrv.h"
-
 /* console.c */
 VOID NTAPI
 ConDrvPause(PCONSOLE Console);
 VOID NTAPI
 ConDrvUnpause(PCONSOLE Console);
 
-PCONSOLE_PROCESS_DATA NTAPI
-ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
 NTSTATUS
 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
                        IN PCONSOLE_PROCESS_DATA ProcessData);
-NTSTATUS NTAPI
-ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
-                              IN ULONG ProcessGroupId,
-                              IN ULONG CtrlEvent);
-
-/* coninput.c */
-VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
-NTSTATUS ConioAddInputEvent(PCONSOLE Console,
-                                     PINPUT_RECORD InputEvent,
-                                     BOOLEAN AppendToEnd);
-NTSTATUS ConioProcessInputEvent(PCONSOLE Console,
-                                         PINPUT_RECORD InputEvent);
 
-/* conoutput.c */
-#define ConioInitRect(Rect, top, left, bottom, right) \
-do {    \
-    ((Rect)->Top) = top;    \
-    ((Rect)->Left) = left;  \
-    ((Rect)->Bottom) = bottom;  \
-    ((Rect)->Right) = right;    \
-} while (0)
-#define ConioIsRectEmpty(Rect) \
-    (((Rect)->Left > (Rect)->Right) || ((Rect)->Top > (Rect)->Bottom))
-#define ConioRectHeight(Rect) \
-    (((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
-#define ConioRectWidth(Rect) \
-    (((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
-
-#define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
-    WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
-
-#define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
-    MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
 
+#define GetConsoleInputBufferMode(Console)  \
+    (Console)->InputBuffer.Mode
+
+
+/* conoutput.c */
 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-VOID ConioDrawConsole(PCONSOLE Console);
-NTSTATUS ConioResizeBuffer(PCONSOLE Console,
+VOID ConioDrawConsole(PCONSOLE /*PCONSRV_CONSOLE*/ Console);
+NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
                            PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
                            COORD Size);
-NTSTATUS ConioWriteConsole(PCONSOLE Console,
-                           PTEXTMODE_SCREEN_BUFFER Buff,
-                           PWCHAR Buffer,
-                           DWORD Length,
-                           BOOL Attrib);
-DWORD ConioEffectiveCursorSize(PCONSOLE Console,
-                                        DWORD Scale);
 
 /* EOF */