Author: jmorlan
Date: Sat Jun 5 02:45:08 2010
New Revision: 47580
URL:
http://svn.reactos.org/svn/reactos?rev=47580&view=rev
Log:
[KERNEL32], [WIN32CSR]
- Implement console history (note: not too useful yet without any way to recall it)
- Implement APIs GetConsoleCommandHistoryLength, GetConsoleCommandHistory,
ExpungeConsoleCommandHistory, SetConsoleNumberOfCommands, GetConsoleHistoryInfo,
SetConsoleHistoryInfo.
- Remove stub of obsolete function SetConsoleCommandHistoryMode, which no longer exists in
Windows.
Modified:
trunk/reactos/dll/win32/kernel32/kernel32.pspec
trunk/reactos/dll/win32/kernel32/misc/console.c
trunk/reactos/include/reactos/subsys/csrss/csrss.h
trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c
trunk/reactos/subsystems/win32/csrss/win32csr/conio.h
trunk/reactos/subsystems/win32/csrss/win32csr/console.c
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
Modified: trunk/reactos/dll/win32/kernel32/kernel32.pspec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] Sat Jun 5 02:45:08 2010
@@ -316,6 +316,7 @@
@ stdcall GetConsoleFontInfo(long long long ptr)
@ stdcall GetConsoleFontSize(long long)
@ stdcall GetConsoleHardwareState(long long ptr)
+@ stdcall GetConsoleHistoryInfo(ptr)
@ stdcall GetConsoleInputExeNameA(long ptr)
@ stdcall GetConsoleInputExeNameW(long ptr)
@ stdcall GetConsoleInputWaitHandle()
@@ -796,7 +797,6 @@
@ stdcall SetComputerNameW(wstr)
@ stdcall SetConsoleActiveScreenBuffer(long)
@ stdcall SetConsoleCP(long)
-@ stdcall SetConsoleCommandHistoryMode(long)
@ stdcall SetConsoleCtrlHandler(ptr long)
@ stdcall SetConsoleCursor(long long)
@ stdcall SetConsoleCursorInfo(long ptr)
@@ -805,6 +805,7 @@
@ stdcall SetConsoleDisplayMode(long long ptr)
@ stdcall SetConsoleFont(long long)
@ stdcall SetConsoleHardwareState(long long long)
+@ stdcall SetConsoleHistoryInfo(ptr)
@ stdcall SetConsoleIcon(ptr)
@ stdcall SetConsoleInputExeNameA(ptr)
@ stdcall SetConsoleInputExeNameW(ptr)
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sat Jun 5 02:45:08 2010
@@ -178,6 +178,37 @@
ExitThread(nExitCode);
}
+/* Get the size needed to copy a string to a capture buffer, including alignment */
+static ULONG
+IntStringSize(LPCVOID String,
+ BOOL Unicode)
+{
+ ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR);
+ return (Size + 3) & -4;
+}
+
+/* Copy a string to a capture buffer */
+static VOID
+IntCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer,
+ LPCVOID String,
+ BOOL Unicode,
+ PUNICODE_STRING RequestString)
+{
+ ULONG Size;
+ if (Unicode)
+ {
+ Size = wcslen(String) * sizeof(WCHAR);
+ CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)String, Size, (PVOID
*)&RequestString->Buffer);
+ }
+ else
+ {
+ Size = strlen(String);
+ CsrAllocateMessagePointer(CaptureBuffer, Size * sizeof(WCHAR), (PVOID
*)&RequestString->Buffer);
+ Size = MultiByteToWideChar(CP_ACP, 0, String, Size, RequestString->Buffer,
Size * sizeof(WCHAR))
+ * sizeof(WCHAR);
+ }
+ RequestString->Length = RequestString->MaximumLength = Size;
+}
/* FUNCTIONS *****************************************************************/
@@ -336,29 +367,56 @@
}
-/*
- * @unimplemented (Undocumented)
- */
-DWORD
-WINAPI
-ExpungeConsoleCommandHistoryW(DWORD Unknown0)
-{
- DPRINT1("ExpungeConsoleCommandHistoryW(0x%x) UNIMPLEMENTED!\n", Unknown0);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented (Undocumented)
- */
-DWORD
-WINAPI
-ExpungeConsoleCommandHistoryA (DWORD Unknown0)
-{
- DPRINT1("ExpungeConsoleCommandHistoryW(0x%x) UNIMPLEMENTED!\n", Unknown0);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
+static BOOL
+IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode)
+{
+ CSR_API_MESSAGE Request;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ ULONG CsrRequest = MAKE_CSR_API(EXPUNGE_COMMAND_HISTORY, CSR_CONSOLE);
+ NTSTATUS Status;
+
+ if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
+ if (!CaptureBuffer)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+ IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
+ &Request.Data.ExpungeCommandHistory.ExeName);
+ Status = CsrClientCallServer(&Request, CaptureBuffer, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * @implemented (Undocumented)
+ */
+BOOL
+WINAPI
+ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName)
+{
+ return IntExpungeConsoleCommandHistory(lpExeName, TRUE);
+}
+
+/*
+ * @implemented (Undocumented)
+ */
+BOOL
+WINAPI
+ExpungeConsoleCommandHistoryA(LPCSTR lpExeName)
+{
+ return IntExpungeConsoleCommandHistory(lpExeName, FALSE);
}
@@ -772,60 +830,138 @@
}
-/*
- * @unimplemented (Undocumented)
+static DWORD
+IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOL
bUnicode)
+{
+ CSR_API_MESSAGE Request;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ ULONG CsrRequest = MAKE_CSR_API(GET_COMMAND_HISTORY, CSR_CONSOLE);
+ NTSTATUS Status;
+ DWORD HistoryLength = cbHistory * (bUnicode ? 1 : sizeof(WCHAR));
+
+ if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) +
+ HistoryLength);
+ if (!CaptureBuffer)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+ IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
+ &Request.Data.GetCommandHistory.ExeName);
+ Request.Data.GetCommandHistory.Length = HistoryLength;
+ CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
+ (PVOID*)&Request.Data.GetCommandHistory.History);
+
+ Status = CsrClientCallServer(&Request, CaptureBuffer, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ SetLastErrorByStatus(Status);
+ return 0;
+ }
+
+ if (bUnicode)
+ {
+ memcpy(lpHistory,
+ Request.Data.GetCommandHistory.History,
+ Request.Data.GetCommandHistory.Length);
+ }
+ else
+ {
+ WideCharToMultiByte(CP_ACP, 0,
+ Request.Data.GetCommandHistory.History,
+ Request.Data.GetCommandHistory.Length / sizeof(WCHAR),
+ lpHistory,
+ cbHistory,
+ NULL, NULL);
+ }
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ return Request.Data.GetCommandHistory.Length;
+}
+
+/*
+ * @implemented (Undocumented)
*/
DWORD
WINAPI
-GetConsoleCommandHistoryW(DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2)
-{
- DPRINT1("GetConsoleCommandHistoryW(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n",
Unknown0, Unknown1, Unknown2);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented (Undocumented)
+GetConsoleCommandHistoryW(LPWSTR lpHistory,
+ DWORD cbHistory,
+ LPCWSTR lpExeName)
+{
+ return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE);
+}
+
+/*
+ * @implemented (Undocumented)
*/
DWORD
WINAPI
-GetConsoleCommandHistoryA(DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2)
-{
- DPRINT1("GetConsoleCommandHistoryA(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n",
Unknown0, Unknown1, Unknown2);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented (Undocumented)
+GetConsoleCommandHistoryA(LPSTR lpHistory,
+ DWORD cbHistory,
+ LPCSTR lpExeName)
+{
+ return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE);
+}
+
+
+static DWORD
+IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
+{
+ CSR_API_MESSAGE Request;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ ULONG CsrRequest = MAKE_CSR_API(GET_COMMAND_HISTORY_LENGTH, CSR_CONSOLE);
+ NTSTATUS Status;
+
+ if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
+ if (!CaptureBuffer)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+ IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
+ &Request.Data.GetCommandHistoryLength.ExeName);
+ Status = CsrClientCallServer(&Request, CaptureBuffer, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ SetLastErrorByStatus(Status);
+ return 0;
+ }
+ return Request.Data.GetCommandHistoryLength.Length;
+}
+
+/*
+ * @implemented (Undocumented)
*/
DWORD
WINAPI
-GetConsoleCommandHistoryLengthW(DWORD Unknown0)
-{
- DPRINT1("GetConsoleCommandHistoryLengthW(0x%x) UNIMPLEMENTED!\n",
Unknown0);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented (Undocumented)
+GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName)
+{
+ return IntGetConsoleCommandHistoryLength(lpExeName, TRUE);
+}
+
+/*
+ * @implemented (Undocumented)
*/
DWORD
WINAPI
-GetConsoleCommandHistoryLengthA(DWORD Unknown0)
-{
- DPRINT1("GetConsoleCommandHistoryLengthA(0x%x) UNIMPLEMENTED!\n",
Unknown0);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
+GetConsoleCommandHistoryLengthA(LPCSTR lpExeName)
+{
+ return IntGetConsoleCommandHistoryLength(lpExeName, FALSE) / sizeof(WCHAR);
+}
+
/*
* @unimplemented
@@ -1035,19 +1171,6 @@
}
return Request.Data.GetInputHandleRequest.Handle;
-}
-
-
-/*
- * @unimplemented (Undocumented)
- */
-BOOL
-WINAPI
-SetConsoleCommandHistoryMode(DWORD dwMode)
-{
- DPRINT1("SetConsoleCommandHistoryMode(0x%x) UNIMPLEMENTED!\n", dwMode);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
}
@@ -1176,31 +1299,61 @@
}
-/*
- * @unimplemented (Undocumented)
- */
-BOOL
-WINAPI
-SetConsoleNumberOfCommandsA(DWORD Unknown0,
- DWORD Unknown1)
-{
- DPRINT1("SetConsoleNumberOfCommandsA(0x%x, 0x%x) UNIMPLEMENTED!\n",
Unknown0, Unknown1);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
-
-
-/*
- * @unimplemented (Undocumented)
- */
-BOOL
-WINAPI
-SetConsoleNumberOfCommandsW(DWORD Unknown0,
- DWORD Unknown1)
-{
- DPRINT1("SetConsoleNumberOfCommandsW(0x%x, 0x%x) UNIMPLEMENTED!\n",
Unknown0, Unknown1);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+static BOOL
+IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
+ LPCVOID lpExeName,
+ BOOL bUnicode)
+{
+ CSR_API_MESSAGE Request;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ ULONG CsrRequest = MAKE_CSR_API(SET_HISTORY_NUMBER_COMMANDS, CSR_CONSOLE);
+ NTSTATUS Status;
+
+ if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
+ if (!CaptureBuffer)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+ IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
+ &Request.Data.SetHistoryNumberCommands.ExeName);
+ Request.Data.SetHistoryNumberCommands.NumCommands = dwNumCommands;
+ Status = CsrClientCallServer(&Request, CaptureBuffer, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * @implemented (Undocumented)
+ */
+BOOL
+WINAPI
+SetConsoleNumberOfCommandsA(DWORD dwNumCommands,
+ LPCWSTR lpExeName)
+{
+ return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE);
+}
+
+/*
+ * @implemented (Undocumented)
+ */
+BOOL
+WINAPI
+SetConsoleNumberOfCommandsW(DWORD dwNumCommands,
+ LPCSTR lpExeName)
+{
+ return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE);
}
@@ -4027,30 +4180,60 @@
/*--------------------------------------------------------------
* GetConsoleHistoryInfo
*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
GetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo)
{
- DPRINT1("GetConsoleHistoryInfo(0x%p) UNIMPLEMENTED!\n",
lpConsoleHistoryInfo);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ CSR_API_MESSAGE Request;
+ ULONG CsrRequest = MAKE_CSR_API(GET_HISTORY_INFO, CSR_CONSOLE);
+ NTSTATUS Status;
+ if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ Status = CsrClientCallServer(&Request, NULL, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ lpConsoleHistoryInfo->HistoryBufferSize =
Request.Data.GetHistoryInfo.HistoryBufferSize;
+ lpConsoleHistoryInfo->NumberOfHistoryBuffers =
Request.Data.GetHistoryInfo.NumberOfHistoryBuffers;
+ lpConsoleHistoryInfo->dwFlags =
Request.Data.GetHistoryInfo.dwFlags;
+ return TRUE;
}
/*--------------------------------------------------------------
* SetConsoleHistoryInfo
*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
SetConsoleHistoryInfo(IN PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo)
{
- DPRINT1("SetConsoleHistoryInfo(0x%p) UNIMPLEMENTED!\n",
lpConsoleHistoryInfo);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ CSR_API_MESSAGE Request;
+ ULONG CsrRequest = MAKE_CSR_API(GET_HISTORY_INFO, CSR_CONSOLE);
+ NTSTATUS Status;
+ if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ Request.Data.SetHistoryInfo.HistoryBufferSize =
lpConsoleHistoryInfo->HistoryBufferSize;
+ Request.Data.SetHistoryInfo.NumberOfHistoryBuffers =
lpConsoleHistoryInfo->NumberOfHistoryBuffers;
+ Request.Data.SetHistoryInfo.dwFlags =
lpConsoleHistoryInfo->dwFlags;
+ Status = CsrClientCallServer(&Request, NULL, CsrRequest,
sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ return TRUE;
}
Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
==============================================================================
--- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Sat Jun 5 02:45:08
2010
@@ -479,6 +479,37 @@
CONSOLE_SELECTION_INFO Info;
} CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO;
+typedef struct
+{
+ UNICODE_STRING ExeName;
+ DWORD Length;
+} CSRSS_GET_COMMAND_HISTORY_LENGTH, *PCSRSS_GET_COMMAND_HISTORY_LENGTH;
+
+typedef struct
+{
+ UNICODE_STRING ExeName;
+ PWCHAR History;
+ DWORD Length;
+} CSRSS_GET_COMMAND_HISTORY, *PCSRSS_GET_COMMAND_HISTORY;
+
+typedef struct
+{
+ UNICODE_STRING ExeName;
+} CSRSS_EXPUNGE_COMMAND_HISTORY, *PCSRSS_EXPUNGE_COMMAND_HISTORY;
+
+typedef struct
+{
+ UNICODE_STRING ExeName;
+ DWORD NumCommands;
+} CSRSS_SET_HISTORY_NUMBER_COMMANDS, *PCSRSS_SET_HISTORY_NUMBER_COMMANDS;
+
+typedef struct
+{
+ DWORD HistoryBufferSize;
+ DWORD NumberOfHistoryBuffers;
+ DWORD dwFlags;
+} CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO,
+ CSRSS_SET_HISTORY_INFO, *PCSRSS_SET_HISTORY_INFO;
#define CSR_API_MESSAGE_HEADER_SIZE(Type) (FIELD_OFFSET(CSR_API_MESSAGE, Data) +
sizeof(Type))
#define CSRSS_MAX_WRITE_CONSOLE (LPC_MAX_DATA_LENGTH -
CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE))
@@ -554,6 +585,12 @@
#define CREATE_THREAD (0x3F)
#define SET_SCREEN_BUFFER_SIZE (0x40)
#define GET_CONSOLE_SELECTION_INFO (0x41)
+#define GET_COMMAND_HISTORY_LENGTH (0x42)
+#define GET_COMMAND_HISTORY (0x43)
+#define EXPUNGE_COMMAND_HISTORY (0x44)
+#define SET_HISTORY_NUMBER_COMMANDS (0x45)
+#define GET_HISTORY_INFO (0x46)
+#define SET_HISTORY_INFO (0x47)
/* Keep in sync with definition below. */
#define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS))
@@ -629,6 +666,12 @@
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
+ CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
+ CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
+ CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
+ CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
+ CSRSS_GET_HISTORY_INFO GetHistoryInfo;
+ CSRSS_SET_HISTORY_INFO SetHistoryInfo;
} Data;
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] Sat Jun 5
02:45:08 2010
@@ -39,7 +39,7 @@
}
else if (KeyEvent->uChar.UnicodeChar == L'\r')
{
- /* TODO: add line to history */
+ HistoryAddEntry(Console);
Console->LineBuffer[Console->LineSize++] = L'\r';
if (Console->Mode & ENABLE_ECHO_INPUT)
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] Sat Jun 5 02:45:08
2010
@@ -80,6 +80,10 @@
WORD LineSize; /* current size of line */
WORD LinePos; /* current position within line */
BOOLEAN LineComplete; /* user pressed enter, ready to send back to
client */
+ LIST_ENTRY HistoryBuffers;
+ WORD HistoryBufferSize; /* size for newly created history buffers */
+ WORD NumberOfHistoryBuffers; /* maximum number of history buffers allowed */
+ BOOLEAN HistoryNoDup; /* remove old duplicate history entries */
LIST_ENTRY BufferList; /* List of all screen buffers for this console
*/
PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
WORD Mode; /* Console mode flags */
@@ -110,6 +114,8 @@
#define CONSOLE_SELECTION_NOT_EMPTY 0x2
#define CONSOLE_MOUSE_SELECTION 0x4
#define CONSOLE_MOUSE_DOWN 0x8
+/* HistoryFlags values */
+#define HISTORY_NO_DUP_FLAG 0x1
/* PauseFlags values (internal only) */
#define PAUSED_FROM_KEYBOARD 0x1
@@ -214,4 +220,15 @@
CSR_API(CsrGetConsoleAliasesExes);
CSR_API(CsrGetConsoleAliasesExesLength);
+/* history.c */
+struct tagHISTORY_BUFFER;
+VOID FASTCALL HistoryAddEntry(PCSRSS_CONSOLE Console);
+VOID FASTCALL HistoryDeleteBuffer(struct tagHISTORY_BUFFER *Hist);
+CSR_API(CsrGetCommandHistoryLength);
+CSR_API(CsrGetCommandHistory);
+CSR_API(CsrExpungeCommandHistory);
+CSR_API(CsrSetHistoryNumberCommands);
+CSR_API(CsrGetHistoryInfo);
+CSR_API(CsrSetHistoryInfo);
+
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] Sat Jun 5
02:45:08 2010
@@ -88,6 +88,7 @@
InitializeListHead(&Console->BufferList);
Console->ActiveBuffer = NULL;
InitializeListHead(&Console->InputEvents);
+ InitializeListHead(&Console->HistoryBuffers);
Console->CodePage = GetOEMCP();
Console->OutputCodePage = GetOEMCP();
@@ -332,6 +333,9 @@
ConioCleanupConsole(Console);
if (Console->LineBuffer)
RtlFreeHeap(Win32CsrApiHeap, 0, Console->LineBuffer);
+ while (!IsListEmpty(&Console->HistoryBuffers))
+ HistoryDeleteBuffer((struct tagHISTORY_BUFFER
*)Console->HistoryBuffers.Flink);
+
ConioDeleteScreenBuffer(Console->ActiveBuffer);
if (!IsListEmpty(&Console->BufferList))
{
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sat Jun 5
02:45:08 2010
@@ -81,6 +81,12 @@
CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent),
CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize),
CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo),
+ CSRSS_DEFINE_API(GET_COMMAND_HISTORY_LENGTH, CsrGetCommandHistoryLength),
+ CSRSS_DEFINE_API(GET_COMMAND_HISTORY, CsrGetCommandHistory),
+ CSRSS_DEFINE_API(EXPUNGE_COMMAND_HISTORY, CsrExpungeCommandHistory),
+ CSRSS_DEFINE_API(SET_HISTORY_NUMBER_COMMANDS, CsrSetHistoryNumberCommands),
+ CSRSS_DEFINE_API(GET_HISTORY_INFO, CsrGetHistoryInfo),
+ CSRSS_DEFINE_API(SET_HISTORY_INFO, CsrSetHistoryInfo),
{ 0, 0, NULL }
};
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] Sat Jun 5
02:45:08 2010
@@ -30,12 +30,9 @@
WCHAR FontName[LF_FACESIZE];
DWORD FontSize;
DWORD FontWeight;
- DWORD HistoryNoDup;
DWORD FullScreen;
DWORD QuickEdit;
DWORD InsertMode;
- DWORD NumberOfHistoryBuffers;
- DWORD HistoryBufferSize;
DWORD WindowPosition;
DWORD UseRasterFonts;
COLORREF ScreenText;
@@ -413,22 +410,24 @@
RegSetValueExW(hKey, L"CursorSize", 0, REG_DWORD, (const BYTE
*)&Console->ActiveBuffer->CursorInfo.dwSize, sizeof(DWORD));
}
- if (GuiData->NumberOfHistoryBuffers == 5)
+ if (Console->NumberOfHistoryBuffers == 5)
{
RegDeleteKeyW(hKey, L"NumberOfHistoryBuffers");
}
else
{
- RegSetValueExW(hKey, L"NumberOfHistoryBuffers", 0, REG_DWORD, (const
BYTE *)&GuiData->NumberOfHistoryBuffers, sizeof(DWORD));
- }
-
- if (GuiData->HistoryBufferSize == 50)
+ DWORD Temp = Console->NumberOfHistoryBuffers;
+ RegSetValueExW(hKey, L"NumberOfHistoryBuffers", 0, REG_DWORD, (const
BYTE *)&Temp, sizeof(DWORD));
+ }
+
+ if (Console->HistoryBufferSize == 50)
{
RegDeleteKeyW(hKey, L"HistoryBufferSize");
}
else
{
- RegSetValueExW(hKey, L"HistoryBufferSize", 0, REG_DWORD, (const BYTE
*)&GuiData->HistoryBufferSize, sizeof(DWORD));
+ DWORD Temp = Console->HistoryBufferSize;
+ RegSetValueExW(hKey, L"HistoryBufferSize", 0, REG_DWORD, (const BYTE
*)&Temp, sizeof(DWORD));
}
if (GuiData->FullScreen == FALSE)
@@ -458,13 +457,14 @@
RegSetValueExW(hKey, L"InsertMode", 0, REG_DWORD, (const BYTE
*)&GuiData->InsertMode, sizeof(DWORD));
}
- if (GuiData->HistoryNoDup == FALSE)
+ if (Console->HistoryNoDup == FALSE)
{
RegDeleteKeyW(hKey, L"HistoryNoDup");
}
else
{
- RegSetValueExW(hKey, L"HistoryNoDup", 0, REG_DWORD, (const BYTE
*)&GuiData->HistoryNoDup, sizeof(DWORD));
+ DWORD Temp = Console->HistoryNoDup;
+ RegSetValueExW(hKey, L"HistoryNoDup", 0, REG_DWORD, (const BYTE
*)&Temp, sizeof(DWORD));
}
if (GuiData->ScreenText == RGB(192, 192, 192))
@@ -564,7 +564,7 @@
}
else if (!wcscmp(szValueName, L"HistoryNoDup"))
{
- GuiData->HistoryNoDup = Value;
+ Console->HistoryNoDup = Value;
}
else if (!wcscmp(szValueName, L"WindowSize"))
{
@@ -603,12 +603,9 @@
wcscpy(GuiData->FontName, L"DejaVu Sans Mono");
GuiData->FontSize = 0x0008000C; // font is 8x12
GuiData->FontWeight = FW_NORMAL;
- GuiData->HistoryNoDup = FALSE;
GuiData->FullScreen = FALSE;
GuiData->QuickEdit = FALSE;
GuiData->InsertMode = TRUE;
- GuiData->HistoryBufferSize = 50;
- GuiData->NumberOfHistoryBuffers = 5;
GuiData->ScreenText = RGB(192, 192, 192);
GuiData->ScreenBackground = RGB(0, 0, 0);
GuiData->PopupText = RGB(128, 0, 128);
@@ -617,6 +614,9 @@
GuiData->UseRasterFonts = TRUE;
memcpy(GuiData->Colors, s_Colors, sizeof(s_Colors));
+ Console->HistoryBufferSize = 50;
+ Console->NumberOfHistoryBuffers = 5;
+ Console->HistoryNoDup = FALSE;
Console->Size.X = 80;
Console->Size.Y = 25;
@@ -1437,8 +1437,8 @@
/* setup struct */
SharedInfo.InsertMode = GuiData->InsertMode;
- SharedInfo.HistoryBufferSize = GuiData->HistoryBufferSize;
- SharedInfo.NumberOfHistoryBuffers = GuiData->NumberOfHistoryBuffers;
+ SharedInfo.HistoryBufferSize = Console->HistoryBufferSize;
+ SharedInfo.NumberOfHistoryBuffers = Console->NumberOfHistoryBuffers;
SharedInfo.ScreenText = GuiData->ScreenText;
SharedInfo.ScreenBackground = GuiData->ScreenBackground;
SharedInfo.PopupText = GuiData->PopupText;
@@ -1450,7 +1450,7 @@
SharedInfo.FontSize = (DWORD)GuiData->FontSize;
SharedInfo.FontWeight = GuiData->FontWeight;
SharedInfo.CursorSize = Console->ActiveBuffer->CursorInfo.dwSize;
- SharedInfo.HistoryNoDup = GuiData->HistoryNoDup;
+ SharedInfo.HistoryNoDup = Console->HistoryNoDup;
SharedInfo.FullScreen = GuiData->FullScreen;
SharedInfo.QuickEdit = GuiData->QuickEdit;
memcpy(&SharedInfo.Colors[0], GuiData->Colors, sizeof(s_Colors));
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] Sat Jun 5
02:45:08 2010
@@ -26,6 +26,7 @@
<file>guiconsole.c</file>
<file>handle.c</file>
<file>harderror.c</file>
+ <file>history.c</file>
<file>tuiconsole.c</file>
<file>appswitch.c</file>
<file>win32csr.rc</file>