Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmdline.h File Reference

Go to the source code of this file.

Classes

struct  _COMMAND
struct  _CLE_POPUP
struct  _COMMAND_HISTORY
struct  _COOKED_READ_DATA
struct  _ALIAS
struct  _EXE_ALIAS_LIST

Defines

#define CLEPF_FALSE_UNICODE   0x0001
#define POPUP_SIZE_X(POPUP)   (SHORT)(((POPUP)->Region.Right - (POPUP)->Region.Left - 1))
#define POPUP_SIZE_Y(POPUP)   (SHORT)(((POPUP)->Region.Bottom - (POPUP)->Region.Top - 1))
#define COMMAND_NUMBER_SIZE   8
#define CLE_ALLOCATED   0x00000001
#define CLE_RESET   0x00000002
#define DEFAULT_NUMBER_OF_COMMANDS   25
#define DEFAULT_NUMBER_OF_BUFFERS   4
#define COMMAND_NUM_TO_INDEX(NUM, CMDHIST)   (SHORT)(((NUM+(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
#define COMMAND_INDEX_TO_NUM(INDEX, CMDHIST)   (SHORT)(((INDEX+((CMDHIST)->MaximumNumberOfCommands)-(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
#define COMMAND_IND_PREV(IND, CMDHIST)
#define COMMAND_IND_NEXT(IND, CMDHIST)
#define COMMAND_IND_DEC(IND, CMDHIST)
#define COMMAND_IND_INC(IND, CMDHIST)
#define CLE_NO_POPUPS(COMMAND_HISTORY)   (&(COMMAND_HISTORY)->PopupList == (COMMAND_HISTORY)->PopupList.Blink)
#define FMCFL_EXACT_MATCH   1
#define FMCFL_JUST_LOOKING   2
#define WC_DESTRUCTIVE_BACKSPACE   0x01
#define WC_KEEP_CURSOR_VISIBLE   0x02
#define WC_ECHO   0x04
#define WC_FALSIFY_UNICODE   0x08
#define WC_LIMIT_BACKSPACE   0x10
#define UCLP_WRAP   1
#define IS_WORD_DELIM(wch)   ((wch) == L' ' || (gaWordDelimChars[0] && IsWordDelim(wch)))
#define WORD_DELIM_MAX   32

Typedefs

typedef _COMMAND COMMAND
typedef _COMMANDPCOMMAND
typedef ULONG(* PCLE_POPUP_INPUT_ROUTINE )(IN PVOID CookedReadData, IN PCSR_API_MSG WaitReplyMessage, IN PCSR_THREAD WaitingThread, IN BOOLEAN WaitRoutine)
typedef _CLE_POPUP CLE_POPUP
typedef _CLE_POPUPPCLE_POPUP
typedef _COMMAND_HISTORY COMMAND_HISTORY
typedef _COMMAND_HISTORYPCOMMAND_HISTORY
typedef _COOKED_READ_DATA COOKED_READ_DATA
typedef _COOKED_READ_DATAPCOOKED_READ_DATA
typedef _ALIAS ALIAS
typedef _ALIASPALIAS
typedef _EXE_ALIAS_LIST EXE_ALIAS_LIST
typedef _EXE_ALIAS_LISTPEXE_ALIAS_LIST

Functions

NTSTATUS ProcessCommandLine (IN PCOOKED_READ_DATA CookedReadData, IN WCHAR Char, IN DWORD KeyState, IN PCSR_API_MSG WaitReplyMessage, IN PCSR_THREAD WaitingThread, IN BOOLEAN WaitRoutine)
VOID DeleteCommandLine (IN OUT PCOOKED_READ_DATA CookedReadData, IN BOOL UpdateFields)
VOID RedrawCommandLine (IN PCOOKED_READ_DATA CookedReadData)
VOID EmptyCommandHistory (IN PCOMMAND_HISTORY CommandHistory)
PCOMMAND_HISTORY ReallocCommandHistory (IN PCONSOLE_INFORMATION Console, IN PCOMMAND_HISTORY CurrentCommandHistory, IN DWORD NumCommands)
PCOMMAND_HISTORY FindExeCommandHistory (IN PCONSOLE_INFORMATION Console, IN PVOID AppName, IN DWORD AppNameLength, IN BOOLEAN UnicodeExe)
PCOMMAND_HISTORY FindCommandHistory (IN PCONSOLE_INFORMATION Console, IN HANDLE ProcessHandle)
ULONG RetrieveNumberOfSpaces (IN SHORT OriginalCursorPositionX, IN PWCHAR Buffer, IN ULONG CurrentPosition)
ULONG RetrieveTotalNumberOfSpaces (IN SHORT OriginalCursorPositionX, IN PWCHAR Buffer, IN ULONG CurrentPosition)
NTSTATUS GetChar (IN PINPUT_INFORMATION InputInfo, OUT PWCHAR Char, IN BOOLEAN Wait, IN PCONSOLE_INFORMATION Console, IN PHANDLE_DATA HandleData, IN PCSR_API_MSG Message OPTIONAL, IN CSR_WAIT_ROUTINE WaitRoutine OPTIONAL, IN PVOID WaitParameter OPTIONAL, IN ULONG WaitParameterLength OPTIONAL, IN BOOLEAN WaitBlockExists OPTIONAL, OUT PBOOLEAN CommandLineEditingKeys OPTIONAL, OUT PBOOLEAN CommandLinePopupKeys OPTIONAL, OUT PBOOLEAN EnableScrollMode OPTIONAL, OUT PDWORD KeyState OPTIONAL)
BOOL IsCommandLinePopupKey (IN OUT PKEY_EVENT_RECORD KeyEvent)
BOOL IsCommandLineEditingKey (IN OUT PKEY_EVENT_RECORD KeyEvent)
VOID CleanUpPopups (IN PCOOKED_READ_DATA CookedReadData)
BOOL ProcessCookedReadInput (IN PCOOKED_READ_DATA CookedReadData, IN WCHAR Char, IN DWORD KeyState, OUT PNTSTATUS Status)
VOID DrawCommandListBorder (IN PCLE_POPUP Popup, IN PSCREEN_INFORMATION ScreenInfo)
PCOMMAND GetLastCommand (IN PCOMMAND_HISTORY CommandHistory)
SHORT FindMatchingCommand (IN PCOMMAND_HISTORY CommandHistory, IN PWCHAR CurrentCommand, IN ULONG CurrentCommandLength, IN SHORT CurrentIndex, IN DWORD Flags)
NTSTATUS CommandNumberPopup (IN PCOOKED_READ_DATA CookedReadData, IN PCSR_API_MSG WaitReplyMessage, IN PCSR_THREAD WaitingThread, IN BOOLEAN WaitRoutine)
BOOLEAN CookedReadWaitRoutine (IN PLIST_ENTRY WaitQueue, IN PCSR_THREAD WaitingThread, IN PCSR_API_MSG WaitReplyMessage, IN PVOID WaitParameter, IN PVOID SatisfyParameter1, IN PVOID SatisfyParameter2, IN ULONG WaitFlags)
VOID ReadRectFromScreenBuffer (IN PSCREEN_INFORMATION ScreenInfo, IN COORD SourcePoint, IN PCHAR_INFO Target, IN COORD TargetSize, IN PSMALL_RECT TargetRect)
NTSTATUS WriteCharsFromInput (IN PSCREEN_INFORMATION ScreenInfo, IN PWCHAR lpBufferBackupLimit, IN PWCHAR lpBuffer, IN PWCHAR lpString, IN OUT PDWORD NumBytes, OUT PLONG NumSpaces OPTIONAL, IN SHORT OriginalXPosition, IN DWORD dwFlags, OUT PSHORT ScrollY OPTIONAL)
VOID DrawCommandListPopup (IN PCLE_POPUP Popup, IN SHORT CurrentCommand, IN PCOMMAND_HISTORY CommandHistory, IN PSCREEN_INFORMATION ScreenInfo)
VOID UpdateCommandListPopup (IN SHORT Delta, IN OUT PSHORT CurrentCommand, IN PCOMMAND_HISTORY CommandHistory, IN PCLE_POPUP Popup, IN PSCREEN_INFORMATION ScreenInfo, IN DWORD Flags)
VOID InitExtendedEditKeys (CONST ExtKeyDefBuf *lpbuf)
BOOL IsPauseKey (IN PKEY_EVENT_RECORD pKeyEvent)
BOOL IsWordDelim (WCHAR)

Variables

WCHAR gaWordDelimChars []
CONST WCHAR gaWordDelimCharsDefault []


Define Documentation

#define CLE_ALLOCATED   0x00000001
 

Definition at line 65 of file cmdline.h.

Referenced by AddCommand(), AllocateCommandHistory(), FindCommandHistory(), FindExeCommandHistory(), FreeCommandHistory(), ProcessCommandLine(), ResizeCommandHistoryBuffers(), RetrieveCommand(), and UpdatePopups().

#define CLE_NO_POPUPS COMMAND_HISTORY   )     (&(COMMAND_HISTORY)->PopupList == (COMMAND_HISTORY)->PopupList.Blink)
 

Definition at line 154 of file cmdline.h.

Referenced by AllocateCommandHistory(), CleanUpPopups(), CookedReadWaitRoutine(), EndPopup(), ProcessCommandNumberInput(), and UpdatePopups().

#define CLE_RESET   0x00000002
 

Definition at line 66 of file cmdline.h.

Referenced by AddCommand(), AtFirstCommand(), EmptyCommandHistory(), FindMatchingCommand(), ReallocCommandHistory(), ResetCommandHistory(), and RetrieveCommand().

#define CLEPF_FALSE_UNICODE   0x0001
 

Definition at line 39 of file cmdline.h.

Referenced by BeginPopup(), and EndPopup().

#define COMMAND_IND_DEC IND,
CMDHIST   ) 
 

Value:

{ \ if (IND <= 0) { \ IND = (CMDHIST)->MaximumNumberOfCommands; \ } \ IND--; \ }

Definition at line 138 of file cmdline.h.

Referenced by RemoveCommand().

#define COMMAND_IND_INC IND,
CMDHIST   ) 
 

Value:

{ \ ++IND; \ if (IND >= (CMDHIST)->MaximumNumberOfCommands){ \ IND = 0; \ } \ }

Definition at line 146 of file cmdline.h.

Referenced by AddCommand(), and RemoveCommand().

#define COMMAND_IND_NEXT IND,
CMDHIST   ) 
 

Value:

{ \ ++IND; \ if (IND >= (CMDHIST)->NumberOfCommands){ \ IND = 0; \ } \ }

Definition at line 130 of file cmdline.h.

Referenced by RetrieveCommand().

#define COMMAND_IND_PREV IND,
CMDHIST   ) 
 

Value:

{ \ if (IND <= 0) { \ IND = (CMDHIST)->NumberOfCommands; \ } \ IND--; \ }

Definition at line 122 of file cmdline.h.

Referenced by AddCommand(), FindMatchingCommand(), and RetrieveCommand().

#define COMMAND_INDEX_TO_NUM INDEX,
CMDHIST   )     (SHORT)(((INDEX+((CMDHIST)->MaximumNumberOfCommands)-(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
 

Definition at line 113 of file cmdline.h.

Referenced by BeginPopup(), CommandListPopup(), RemoveCommand(), and UpdateCommandListPopup().

#define COMMAND_NUM_TO_INDEX NUM,
CMDHIST   )     (SHORT)(((NUM+(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
 

Definition at line 112 of file cmdline.h.

Referenced by DrawCommandListPopup(), ProcessCommandLine(), ProcessCommandNumberInput(), ReallocCommandHistory(), and UpdateCommandListPopup().

#define COMMAND_NUMBER_SIZE   8
 

Definition at line 59 of file cmdline.h.

Referenced by DrawCommandListPopup().

#define DEFAULT_NUMBER_OF_BUFFERS   4
 

Definition at line 83 of file cmdline.h.

Referenced by InitializeConsoleAttributes().

#define DEFAULT_NUMBER_OF_COMMANDS   25
 

Definition at line 82 of file cmdline.h.

Referenced by InitializeConsoleAttributes().

#define FMCFL_EXACT_MATCH   1
 

Definition at line 306 of file cmdline.h.

Referenced by AddCommand(), and FindMatchingCommand().

#define FMCFL_JUST_LOOKING   2
 

Definition at line 307 of file cmdline.h.

Referenced by FindMatchingCommand(), and ProcessCommandListInput().

#define IS_WORD_DELIM wch   )     ((wch) == L' ' || (gaWordDelimChars[0] && IsWordDelim(wch)))
 

Definition at line 399 of file cmdline.h.

Referenced by HandleMouseEvent(), ProcessCommandLine(), and ProcessCookedReadInput().

#define POPUP_SIZE_X POPUP   )     (SHORT)(((POPUP)->Region.Right - (POPUP)->Region.Left - 1))
 

Definition at line 57 of file cmdline.h.

Referenced by CommandNumberPopup(), DrawCommandListBorder(), DrawCommandListPopup(), DrawPromptPopup(), and UpdateHighlight().

#define POPUP_SIZE_Y POPUP   )     (SHORT)(((POPUP)->Region.Bottom - (POPUP)->Region.Top - 1))
 

Definition at line 58 of file cmdline.h.

Referenced by CommandListPopup(), DrawCommandListBorder(), DrawCommandListPopup(), DrawPromptPopup(), ProcessCommandListInput(), UpdateCommandListPopup(), and UpdateHighlight().

#define UCLP_WRAP   1
 

Definition at line 378 of file cmdline.h.

Referenced by ProcessCommandListInput(), and UpdateCommandListPopup().

#define WC_DESTRUCTIVE_BACKSPACE   0x01
 

Definition at line 353 of file cmdline.h.

Referenced by ProcessCommandLine(), ProcessCommandNumberInput(), ProcessCookedReadInput(), ProcessCopyFromCharInput(), ProcessCopyToCharInput(), RedrawCommandLine(), SetCurrentCommandLine(), and WWSB_WriteChars().

#define WC_ECHO   0x04
 

Definition at line 355 of file cmdline.h.

Referenced by ProcessCommandLine(), ProcessCommandNumberInput(), ProcessCookedReadInput(), ProcessCopyFromCharInput(), ProcessCopyToCharInput(), RedrawCommandLine(), SetCurrentCommandLine(), and WWSB_WriteChars().

#define WC_FALSIFY_UNICODE   0x08
 

Definition at line 356 of file cmdline.h.

Referenced by WriteCharsFromInput(), and WWSB_WriteChars().

#define WC_KEEP_CURSOR_VISIBLE   0x02
 

Definition at line 354 of file cmdline.h.

Referenced by ProcessCommandLine(), ProcessCommandNumberInput(), ProcessCookedReadInput(), ProcessCopyFromCharInput(), ProcessCopyToCharInput(), RedrawCommandLine(), SetCurrentCommandLine(), and WWSB_WriteChars().

#define WC_LIMIT_BACKSPACE   0x10
 

Definition at line 357 of file cmdline.h.

Referenced by WWSB_DoWriteConsole(), and WWSB_WriteChars().

#define WORD_DELIM_MAX   32
 

Definition at line 405 of file cmdline.h.

Referenced by GetRegistryValues(), and IsWordDelim().


Typedef Documentation

typedef struct _ALIAS ALIAS
 

Referenced by FindAlias().

typedef struct _CLE_POPUP CLE_POPUP
 

Referenced by BeginPopup(), and CookedReadWaitRoutine().

typedef struct _COMMAND COMMAND
 

Referenced by AddCommand().

typedef struct _COMMAND_HISTORY COMMAND_HISTORY
 

Referenced by ReallocCommandHistory().

typedef struct _COOKED_READ_DATA COOKED_READ_DATA
 

Referenced by ReadChars().

typedef struct _EXE_ALIAS_LIST EXE_ALIAS_LIST
 

Referenced by AddExeAliasList().

typedef struct _ALIAS * PALIAS
 

typedef struct _CLE_POPUP * PCLE_POPUP
 

Referenced by BeginPopup(), and CookedReadWaitRoutine().

typedef ULONG(* PCLE_POPUP_INPUT_ROUTINE)(IN PVOID CookedReadData, IN PCSR_API_MSG WaitReplyMessage, IN PCSR_THREAD WaitingThread, IN BOOLEAN WaitRoutine)
 

Definition at line 29 of file cmdline.h.

Referenced by CommandListPopup(), CommandNumberPopup(), CopyFromCharPopup(), and CopyToCharPopup().

typedef struct _COMMAND * PCOMMAND
 

typedef struct _COMMAND_HISTORY * PCOMMAND_HISTORY
 

typedef struct _COOKED_READ_DATA * PCOOKED_READ_DATA
 

Referenced by WWSB_AdjustCursorPosition().

typedef struct _EXE_ALIAS_LIST * PEXE_ALIAS_LIST
 


Function Documentation

VOID CleanUpPopups IN PCOOKED_READ_DATA  CookedReadData  ) 
 

Definition at line 1993 of file server/cmdline.c.

References CLE_NO_POPUPS, and EndPopup().

Referenced by CookedReadWaitRoutine().

01996 { 01997 PCOMMAND_HISTORY CommandHistory; 01998 01999 CommandHistory = CookedReadData->CommandHistory; 02000 if (!CommandHistory) 02001 return; 02002 while (!CLE_NO_POPUPS(CommandHistory)) { 02003 EndPopup(CookedReadData->ScreenInfo,CommandHistory); 02004 } 02005 }

NTSTATUS CommandNumberPopup IN PCOOKED_READ_DATA  CookedReadData,
IN PCSR_API_MSG  WaitReplyMessage,
IN PCSR_THREAD  WaitingThread,
IN BOOLEAN  WaitRoutine
 

Definition at line 3150 of file server/cmdline.c.

References COMMAND_NUMBER_LENGTH, DrawPromptPopup(), GetConsoleLangId(), ghInstance, LoadStringEx, MINIMUM_COMMAND_PROMPT_SIZE, msgCmdLineF9, NT_SUCCESS, NTSTATUS(), _CLE_POPUP::NumberRead, PCLE_POPUP_INPUT_ROUTINE, POPUP_SIZE_X, _CLE_POPUP::PopupInputRoutine, _COMMAND_HISTORY::PopupList, ProcessCommandNumberInput(), _CLE_POPUP::Region, SetCursorPosition(), SHORT, Status, and TRUE.

Referenced by ProcessCommandLine(), and ProcessCommandListInput().

03163 : 03164 03165 CONSOLE_STATUS_WAIT - we ran out of input, so 03166 a wait block was created 03167 03168 STATUS_SUCCESS - read was fully completed (user hit return) 03169 03170 --*/ 03171 03172 { 03173 PCLE_POPUP Popup; 03174 PCOMMAND_HISTORY CommandHistory; 03175 COORD CursorPosition; 03176 WCHAR ItemString[70]; 03177 int ItemLength; 03178 NTSTATUS Status; 03179 LANGID LangId; 03180 03181 CommandHistory = CookedReadData->CommandHistory; 03182 Popup = CONTAINING_RECORD( CommandHistory->PopupList.Flink, CLE_POPUP, ListLink ); 03183 03184 Status = GetConsoleLangId(CookedReadData->ScreenInfo->Console->OutputCP, &LangId); 03185 if (NT_SUCCESS(Status)) { 03186 ItemLength = LoadStringEx(ghInstance,msgCmdLineF9,ItemString,70,LangId); 03187 } 03188 if (!NT_SUCCESS(Status) || ItemLength == 0) { 03189 ItemLength = LoadString(ghInstance,msgCmdLineF9,ItemString,70); 03190 } 03191 03192 if (ItemLength > POPUP_SIZE_X(Popup) - COMMAND_NUMBER_LENGTH) { 03193 ItemLength = POPUP_SIZE_X(Popup) - COMMAND_NUMBER_LENGTH; 03194 } 03195 DrawPromptPopup(Popup, 03196 CookedReadData->ScreenInfo, 03197 ItemString, 03198 ItemLength 03199 ); 03200 CursorPosition.X = (SHORT)(Popup->Region.Right - MINIMUM_COMMAND_PROMPT_SIZE); 03201 CursorPosition.Y = (SHORT)(Popup->Region.Top+1); 03202 SetCursorPosition(CookedReadData->ScreenInfo, 03203 CursorPosition, 03204 TRUE 03205 ); 03206 Popup->NumberRead=0; 03207 Popup->PopupInputRoutine = (PCLE_POPUP_INPUT_ROUTINE) ProcessCommandNumberInput; 03208 return ProcessCommandNumberInput(CookedReadData, 03209 WaitReplyMessage, 03210 WaitingThread, 03211 WaitRoutine 03212 ); 03213 }

BOOLEAN CookedReadWaitRoutine IN PLIST_ENTRY  WaitQueue,
IN PCSR_THREAD  WaitingThread,
IN PCSR_API_MSG  WaitReplyMessage,
IN PVOID  WaitParameter,
IN PVOID  SatisfyParameter1,
IN PVOID  SatisfyParameter2,
IN ULONG  WaitFlags
 

Definition at line 1541 of file server/stream.c.

References ASSERT, _COOKED_READ_DATA::BackupLimit, _CONSOLE_READCONSOLE_MSG::Buffer, BUFFER_SIZE, _COOKED_READ_DATA::BytesRead, _CONSOLE_READCONSOLE_MSG::CaptureBufferSize, CLE_NO_POPUPS, CLE_POPUP, CleanUpPopups(), CloseOutputHandle(), _COOKED_READ_DATA::CommandHistory, _COOKED_READ_DATA::Console, CONSOLE_CTRL_BREAK_SEEN, CONSOLE_CTRL_C_SEEN, CONSOLE_FROMTHREADPERPROCESSDATA, CONSOLE_STATUS_READ_COMPLETE, CONSOLE_STATUS_WAIT, CONSOLE_STATUS_WAIT_NO_BLOCK, ConsoleHeapFree, ConsoleLocked, CookedRead(), DereferenceIoHandleNoCheck(), _COOKED_READ_DATA::Echo, _COOKED_READ_DATA::ExeName, FALSE, HANDLE_CLOSING, HANDLE_INPUT_PENDING, _COOKED_READ_DATA::HandleIndex, _INPUT_READ_HANDLE_DATA::InputHandleFlags, _HANDLE_DATA::InputReadData, LockReadCount, NT_SUCCESS, NTSTATUS(), NULL, PCLE_POPUP, _CLE_POPUP::PopupInputRoutine, _COMMAND_HISTORY::PopupList, _COOKED_READ_DATA::ProcessData, _INPUT_READ_HANDLE_DATA::ReadCount, Status, _COOKED_READ_DATA::TempHandle, TRUE, UnlockReadCount, and _COOKED_READ_DATA::UserBuffer.

Referenced by CookedRead(), ProcessCommandListInput(), ProcessCommandNumberInput(), ProcessCopyFromCharInput(), and ProcessCopyToCharInput().

01553 : 01554 01555 This routine is called to complete a cooked read that blocked in 01556 ReadInputBuffer. The context of the read was saved in the CookedReadData 01557 structure. This routine is called when events have been written to 01558 the input buffer. It is called in the context of the writing thread. 01559 It may be called more than once. 01560 01561 Arguments: 01562 01563 WaitQueue - pointer to queue containing wait block 01564 01565 WaitingThread - pointer to waiting thread 01566 01567 WaitReplyMessage - pointer to reply message 01568 01569 CookedReadData - pointer to data saved in ReadChars 01570 01571 SatisfyParameter1 - if this routine was called (indirectly) by 01572 CloseInputHandle, this argument contains a HandleData pointer of 01573 the dying handle. otherwise, it contains NULL. 01574 01575 SatisfyParameter2 - if this routine is called because a ctrl-c or 01576 ctrl-break was seen, this argument contains CONSOLE_CTRL_SEEN. 01577 otherwise it contains NULL. 01578 01579 WaitFlags - Flags indicating status of wait. 01580 01581 Return Value: 01582 01583 --*/ 01584 01585 01586 { 01587 NTSTATUS Status; 01588 PCONSOLE_INFORMATION Console; 01589 PCOOKED_READ_DATA CookedReadData; 01590 PCONSOLE_READCONSOLE_MSG a; 01591 PHANDLE_DATA HandleData; 01592 01593 a = (PCONSOLE_READCONSOLE_MSG)&WaitReplyMessage->u.ApiMessageData; 01594 CookedReadData = (PCOOKED_READ_DATA)WaitParameter; 01595 01596 Status = DereferenceIoHandleNoCheck(CookedReadData->ProcessData, 01597 CookedReadData->HandleIndex, 01598 &HandleData 01599 ); 01600 ASSERT (NT_SUCCESS(Status)); 01601 ASSERT(!(HandleData->InputReadData->InputHandleFlags & HANDLE_INPUT_PENDING)); 01602 01603 // 01604 // see if this routine was called by CloseInputHandle. if it 01605 // was, see if this wait block corresponds to the dying handle. 01606 // if it doesn't, just return. 01607 // 01608 01609 if (SatisfyParameter1 != NULL && 01610 SatisfyParameter1 != HandleData) { 01611 //DbgPrint("CookedReadWaitRoutine exit 1\n"); 01612 return FALSE; 01613 } 01614 01615 Console = CookedReadData->Console; 01616 01617 // 01618 // this routine should be called by a thread owning the same 01619 // lock on the same console as we're reading from. 01620 // 01621 01622 LockReadCount(HandleData); 01623 ASSERT(HandleData->InputReadData->ReadCount); 01624 HandleData->InputReadData->ReadCount -= 1; 01625 UnlockReadCount(HandleData); 01626 01627 // 01628 // if ctrl-c or ctrl-break was seen, terminate read. 01629 // 01630 01631 if ((ULONG_PTR)SatisfyParameter2 & (CONSOLE_CTRL_C_SEEN | CONSOLE_CTRL_BREAK_SEEN)) { 01632 if (CookedReadData->Echo) { 01633 CloseOutputHandle(CONSOLE_FROMTHREADPERPROCESSDATA(WaitingThread), 01634 CookedReadData->Console, 01635 &CookedReadData->TempHandle, 01636 NULL, 01637 FALSE 01638 ); 01639 } 01640 //DbgPrint("CookedReadWaitRoutine exit 2\n"); 01641 WaitReplyMessage->ReturnValue = STATUS_ALERTED; 01642 ConsoleHeapFree(CookedReadData->BackupLimit); 01643 ConsoleHeapFree(CookedReadData->ExeName); 01644 #if defined(FE_SB) 01645 CookedReadData->Console->lpCookedReadData = NULL; 01646 #endif 01647 ConsoleHeapFree(CookedReadData); 01648 return TRUE; 01649 } 01650 01651 // 01652 // see if called by CsrDestroyProcess or CsrDestroyThread 01653 // via CsrNotifyWaitBlock. if so, just decrement the ReadCount 01654 // and return. 01655 // 01656 01657 if (WaitFlags & CSR_PROCESS_TERMINATING) { 01658 if (CookedReadData->Echo) { 01659 CloseOutputHandle(CONSOLE_FROMTHREADPERPROCESSDATA(WaitingThread), 01660 CookedReadData->Console, 01661 &CookedReadData->TempHandle, 01662 NULL, 01663 FALSE 01664 ); 01665 } 01666 //DbgPrint("CookedReadWaitRoutine exit 3\n"); 01667 WaitReplyMessage->ReturnValue = (ULONG)STATUS_THREAD_IS_TERMINATING; 01668 01669 // 01670 // clean up popup data structures 01671 // 01672 01673 CleanUpPopups(CookedReadData); 01674 ConsoleHeapFree(CookedReadData->BackupLimit); 01675 ConsoleHeapFree(CookedReadData->ExeName); 01676 #if defined(FE_SB) 01677 CookedReadData->Console->lpCookedReadData = NULL; 01678 #endif 01679 ConsoleHeapFree(CookedReadData); 01680 return TRUE; 01681 } 01682 01683 // 01684 // We must see if we were woken up because the handle is being 01685 // closed. if so, we decrement the read count. if it goes to 01686 // zero, we wake up the close thread. otherwise, we wake up any 01687 // other thread waiting for data. 01688 // 01689 01690 if (HandleData->InputReadData->InputHandleFlags & HANDLE_CLOSING) { 01691 ASSERT (SatisfyParameter1 == HandleData); 01692 if (CookedReadData->Echo) { 01693 CloseOutputHandle(CONSOLE_FROMTHREADPERPROCESSDATA(WaitingThread), 01694 CookedReadData->Console, 01695 &CookedReadData->TempHandle, 01696 NULL, 01697 FALSE 01698 ); 01699 } 01700 //DbgPrint("CookedReadWaitRoutine exit 4\n"); 01701 WaitReplyMessage->ReturnValue = STATUS_ALERTED; 01702 01703 // 01704 // clean up popup data structures 01705 // 01706 01707 CleanUpPopups(CookedReadData); 01708 ConsoleHeapFree(CookedReadData->BackupLimit); 01709 ConsoleHeapFree(CookedReadData->ExeName); 01710 #if defined(FE_SB) 01711 CookedReadData->Console->lpCookedReadData = NULL; 01712 #endif 01713 ConsoleHeapFree(CookedReadData); 01714 return TRUE; 01715 } 01716 01717 // 01718 // if we get to here, this routine was called either by the input 01719 // thread or a write routine. both of these callers grab the 01720 // current console lock. 01721 // 01722 01723 // 01724 // this routine should be called by a thread owning the same 01725 // lock on the same console as we're reading from. 01726 // 01727 01728 ASSERT (ConsoleLocked(Console)); 01729 01730 if (CookedReadData->CommandHistory) { 01731 PCLE_POPUP Popup; 01732 if (!CLE_NO_POPUPS(CookedReadData->CommandHistory)) { 01733 Popup = CONTAINING_RECORD( CookedReadData->CommandHistory->PopupList.Flink, CLE_POPUP, ListLink ); 01734 Status = (Popup->PopupInputRoutine)(CookedReadData, 01735 WaitReplyMessage, 01736 WaitingThread, 01737 TRUE); 01738 if (Status == CONSOLE_STATUS_READ_COMPLETE || 01739 (Status != CONSOLE_STATUS_WAIT && 01740 Status != CONSOLE_STATUS_WAIT_NO_BLOCK) ) { 01741 ConsoleHeapFree(CookedReadData->BackupLimit); 01742 ConsoleHeapFree(CookedReadData->ExeName); 01743 #if defined(FE_SB) 01744 CookedReadData->Console->lpCookedReadData = NULL; 01745 #endif 01746 ConsoleHeapFree(CookedReadData); 01747 return TRUE; 01748 } 01749 return FALSE; 01750 } 01751 } 01752 if (a->CaptureBufferSize <= BUFFER_SIZE && 01753 CookedReadData->BytesRead == 0) { 01754 CookedReadData->UserBuffer = a->Buffer; 01755 } 01756 Status = CookedRead(CookedReadData, 01757 WaitReplyMessage, 01758 WaitingThread, 01759 TRUE 01760 ); 01761 01762 if (Status != CONSOLE_STATUS_WAIT) { 01763 return TRUE; 01764 } else { 01765 return FALSE; 01766 } 01767 01768 // 01769 // satisfy the unreferenced parameter warnings. 01770 // 01771 01772 UNREFERENCED_PARAMETER(WaitQueue); 01773 UNREFERENCED_PARAMETER(SatisfyParameter2); 01774 }

VOID DeleteCommandLine IN OUT PCOOKED_READ_DATA  CookedReadData,
IN BOOL  UpdateFields
 

Definition at line 2009 of file server/cmdline.c.

References CONSOLE_FALSE_UNICODE, DWORD, FillOutput, SetCursorPosition(), and TRUE.

Referenced by ProcessCommandLine(), ProcessCommandNumberInput(), ProcessCookedReadInput(), ProcessCopyFromCharInput(), PropertiesUpdate(), and SetCurrentCommandLine().

02013 { 02014 DWORD CharsToWrite = CookedReadData->NumberOfVisibleChars; 02015 COORD Coord = CookedReadData->OriginalCursorPosition; 02016 02017 // 02018 // catch the case where the current command has scrolled off the 02019 // top of the screen. 02020 // 02021 02022 if (Coord.Y < 0) { 02023 CharsToWrite += CookedReadData->ScreenInfo->ScreenBufferSize.X * Coord.Y; 02024 CharsToWrite += CookedReadData->OriginalCursorPosition.X; // account for prompt 02025 CookedReadData->OriginalCursorPosition.X = 0; 02026 CookedReadData->OriginalCursorPosition.Y = 0; 02027 Coord.X = 0; 02028 Coord.Y = 0; 02029 } 02030 #if defined(FE_SB) 02031 if (CONSOLE_IS_DBCS_OUTPUTCP(CookedReadData->ScreenInfo->Console) && 02032 !CheckBisectStringW(CookedReadData->ScreenInfo, 02033 CookedReadData->ScreenInfo->Console->CP, 02034 CookedReadData->BackupLimit, 02035 CharsToWrite, 02036 CookedReadData->ScreenInfo->ScreenBufferSize.X 02037 -CookedReadData->OriginalCursorPosition.X 02038 )) { 02039 CharsToWrite++; 02040 } 02041 #endif 02042 FillOutput(CookedReadData->ScreenInfo, 02043 (WCHAR)' ', 02044 Coord, 02045 CONSOLE_FALSE_UNICODE, // faster than real unicode 02046 &CharsToWrite 02047 ); 02048 if (UpdateFields) { 02049 CookedReadData->BufPtr=CookedReadData->BackupLimit; 02050 CookedReadData->BytesRead=0; 02051 CookedReadData->CurrentPosition=0; 02052 CookedReadData->NumberOfVisibleChars = 0; 02053 } 02054 SetCursorPosition(CookedReadData->ScreenInfo, 02055 CookedReadData->OriginalCursorPosition, 02056 TRUE 02057 ); 02058 }

VOID DrawCommandListBorder IN PCLE_POPUP  Popup,
IN PSCREEN_INFORMATION  ScreenInfo
 

Definition at line 4123 of file server/cmdline.c.

References CONSOLE_ATTRIBUTE, CONSOLE_REAL_UNICODE, else, FillOutput, POPUP_SIZE_X, POPUP_SIZE_Y, and SHORT.

Referenced by BeginPopup().

04127 { 04128 COORD WriteCoord; 04129 ULONG Length; 04130 SHORT i; 04131 04132 // 04133 // fill attributes of top line 04134 // 04135 WriteCoord.X = Popup->Region.Left; 04136 WriteCoord.Y = Popup->Region.Top; 04137 Length = POPUP_SIZE_X(Popup) + 2; 04138 FillOutput(ScreenInfo, 04139 Popup->Attributes, 04140 WriteCoord, 04141 CONSOLE_ATTRIBUTE, 04142 &Length 04143 ); 04144 // 04145 // draw upper left corner 04146 // 04147 Length = 1; 04148 FillOutput(ScreenInfo, 04149 #if defined(FE_SB) 04150 ScreenInfo->LineChar[UPPER_LEFT_CORNER], 04151 #else 04152 (WCHAR)0x250c, 04153 #endif 04154 WriteCoord, 04155 CONSOLE_REAL_UNICODE, 04156 &Length 04157 ); 04158 04159 // 04160 // draw upper bar 04161 // 04162 04163 WriteCoord.X += 1; 04164 Length = POPUP_SIZE_X(Popup); 04165 FillOutput(ScreenInfo, 04166 #if defined(FE_SB) 04167 ScreenInfo->LineChar[HORIZONTAL_LINE], 04168 #else 04169 (WCHAR)0x2500, 04170 #endif 04171 WriteCoord, 04172 CONSOLE_REAL_UNICODE, 04173 &Length 04174 ); 04175 04176 // 04177 // draw upper right corner 04178 // 04179 04180 WriteCoord.X = Popup->Region.Right; 04181 Length = 1; 04182 FillOutput(ScreenInfo, 04183 #if defined(FE_SB) 04184 ScreenInfo->LineChar[UPPER_RIGHT_CORNER], 04185 #else 04186 (WCHAR)0x2510, 04187 #endif 04188 WriteCoord, 04189 CONSOLE_REAL_UNICODE, 04190 &Length 04191 ); 04192 04193 for (i=0;i<POPUP_SIZE_Y(Popup);i++) { 04194 WriteCoord.Y += 1; 04195 WriteCoord.X = Popup->Region.Left; 04196 04197 // 04198 // fill attributes 04199 // 04200 04201 Length = POPUP_SIZE_X(Popup) + 2; 04202 FillOutput(ScreenInfo, 04203 Popup->Attributes, 04204 WriteCoord, 04205 CONSOLE_ATTRIBUTE, 04206 &Length 04207 ); 04208 Length = 1; 04209 FillOutput(ScreenInfo, 04210 #if defined(FE_SB) 04211 ScreenInfo->LineChar[VERTICAL_LINE], 04212 #else 04213 (WCHAR)0x2502, 04214 #endif 04215 WriteCoord, 04216 CONSOLE_REAL_UNICODE, 04217 &Length 04218 ); 04219 WriteCoord.X = Popup->Region.Right; 04220 Length = 1; 04221 FillOutput(ScreenInfo, 04222 #if defined(FE_SB) 04223 ScreenInfo->LineChar[VERTICAL_LINE], 04224 #else 04225 (WCHAR)0x2502, 04226 #endif 04227 WriteCoord, 04228 CONSOLE_REAL_UNICODE, 04229 &Length 04230 ); 04231 } 04232 04233 // 04234 // draw bottom line 04235 // 04236 // fill attributes of top line 04237 // 04238 04239 WriteCoord.X = Popup->Region.Left; 04240 WriteCoord.Y = Popup->Region.Bottom; 04241 Length = POPUP_SIZE_X(Popup) + 2; 04242 FillOutput(ScreenInfo, 04243 Popup->Attributes, 04244 WriteCoord, 04245 CONSOLE_ATTRIBUTE, 04246 &Length 04247 ); 04248 // 04249 // draw bottom left corner 04250 // 04251 04252 Length = 1; 04253 WriteCoord.X = Popup->Region.Left; 04254 FillOutput(ScreenInfo, 04255 #if defined(FE_SB) 04256 ScreenInfo->LineChar[BOTTOM_LEFT_CORNER], 04257 #else 04258 (WCHAR)0x2514, 04259 #endif 04260 WriteCoord, 04261 CONSOLE_REAL_UNICODE, 04262 &Length 04263 ); 04264 04265 // 04266 // draw lower bar 04267 // 04268 04269 WriteCoord.X += 1; 04270 Length = POPUP_SIZE_X(Popup); 04271 FillOutput(ScreenInfo, 04272 #if defined(FE_SB) 04273 ScreenInfo->LineChar[HORIZONTAL_LINE], 04274 #else 04275 (WCHAR)0x2500, 04276 #endif 04277 WriteCoord, 04278 CONSOLE_REAL_UNICODE, 04279 &Length 04280 ); 04281 04282 // 04283 // draw lower right corner 04284 // 04285 04286 WriteCoord.X = Popup->Region.Right; 04287 Length = 1; 04288 FillOutput(ScreenInfo, 04289 #if defined(FE_SB) 04290 ScreenInfo->LineChar[BOTTOM_RIGHT_CORNER], 04291 #else 04292 (WCHAR)0x2518, 04293 #endif 04294 WriteCoord, 04295 CONSOLE_REAL_UNICODE, 04296 &Length 04297 ); 04298 }

VOID DrawCommandListPopup IN PCLE_POPUP  Popup,
IN SHORT  CurrentCommand,
IN PCOMMAND_HISTORY  CommandHistory,
IN PSCREEN_INFORMATION  ScreenInfo
 

Definition at line 4346 of file server/cmdline.c.

References CHAR, COMMAND_NUM_TO_INDEX, COMMAND_NUMBER_SIZE, CONSOLE_ASCII, CONSOLE_ATTRIBUTE, CONSOLE_FALSE_UNICODE, CONSOLE_OEMFONT_DISPLAY, CONSOLE_REAL_UNICODE, ConsoleHeapAlloc, ConsoleHeapFree, DWORD, FalseUnicodeToRealUnicode(), FillOutput, MAKE_TAG, max, NULL, POPUP_SIZE_X, POPUP_SIZE_Y, SHORT, and WriteOutputString.

Referenced by CommandListPopup(), and UpdateCommandListPopup().

04352 { 04353 WORD Attributes; 04354 ULONG lStringLength,CommandNumberLength; 04355 CHAR CommandNumber[COMMAND_NUMBER_SIZE]; 04356 PCHAR CommandNumberPtr; 04357 COORD WriteCoord; 04358 SHORT i; 04359 04360 // 04361 // draw empty popup 04362 // 04363 04364 WriteCoord.X = (SHORT)(Popup->Region.Left+1); 04365 WriteCoord.Y = (SHORT)(Popup->Region.Top+1); 04366 lStringLength = POPUP_SIZE_X(Popup); 04367 for (i=0;i<POPUP_SIZE_Y(Popup);i++) { 04368 FillOutput(ScreenInfo, 04369 Popup->Attributes, 04370 WriteCoord, 04371 CONSOLE_ATTRIBUTE, 04372 &lStringLength 04373 ); 04374 FillOutput(ScreenInfo, 04375 (WCHAR)' ', 04376 WriteCoord, 04377 CONSOLE_FALSE_UNICODE, // faster than real unicode 04378 &lStringLength 04379 ); 04380 WriteCoord.Y += 1; 04381 } 04382 04383 WriteCoord.Y = (SHORT)(Popup->Region.Top+1); 04384 for (i=max((SHORT)(Popup->BottomIndex-POPUP_SIZE_Y(Popup)+1),0);i<=Popup->BottomIndex;i++) { 04385 04386 // 04387 // write command number to screen 04388 // 04389 04390 CommandNumberPtr = _itoa(i,CommandNumber,10); 04391 CommandNumberLength = (SHORT)lstrlenA(CommandNumberPtr); 04392 CommandNumber[CommandNumberLength] = ':'; 04393 CommandNumber[CommandNumberLength+1] = ' '; 04394 CommandNumberLength+=2; 04395 if (CommandNumberLength > (ULONG)POPUP_SIZE_X(Popup)) 04396 CommandNumberLength = (ULONG)POPUP_SIZE_X(Popup); 04397 WriteCoord.X = (SHORT)(Popup->Region.Left+1); 04398 WriteOutputString(ScreenInfo, 04399 CommandNumberPtr, 04400 WriteCoord, 04401 CONSOLE_ASCII, 04402 &CommandNumberLength, 04403 NULL 04404 ); 04405 04406 // 04407 // write command to screen 04408 // 04409 04410 lStringLength = CommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CommandHistory)]->CommandLength/sizeof(WCHAR); 04411 #if defined(FE_SB) 04412 { 04413 DWORD lTmpStringLength; 04414 LONG lPopupLength; 04415 LPWSTR lpStr; 04416 04417 lTmpStringLength = lStringLength; 04418 lPopupLength = POPUP_SIZE_X(Popup) - CommandNumberLength; 04419 lpStr = CommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CommandHistory)]->Command; 04420 while (lTmpStringLength--) { 04421 if (IsConsoleFullWidth(ScreenInfo->Console->hDC, 04422 ScreenInfo->Console->OutputCP,*lpStr++)) { 04423 lPopupLength -= 2; 04424 } 04425 else { 04426 lPopupLength--; 04427 } 04428 if (lPopupLength <= 0) { 04429 lStringLength -= lTmpStringLength; 04430 if (lPopupLength < 0) 04431 lStringLength--; 04432 break; 04433 } 04434 } 04435 } 04436 #else 04437 if ((lStringLength+CommandNumberLength) > (ULONG)POPUP_SIZE_X(Popup)) 04438 lStringLength = (ULONG)(POPUP_SIZE_X(Popup)-CommandNumberLength); 04439 #endif 04440 WriteCoord.X = (SHORT)(WriteCoord.X + CommandNumberLength); 04441 #if defined(FE_SB) 04442 { 04443 PWCHAR TransBuffer; 04444 04445 TransBuffer = ConsoleHeapAlloc(MAKE_TAG( TMP_DBCS_TAG ),lStringLength * sizeof(WCHAR)); 04446 if (TransBuffer == NULL) { 04447 return; 04448 } 04449 04450 RtlCopyMemory(TransBuffer,CommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CommandHistory)]->Command,lStringLength * sizeof(WCHAR)); 04451 WriteOutputString(ScreenInfo, 04452 TransBuffer, 04453 WriteCoord, 04454 CONSOLE_REAL_UNICODE, 04455 &lStringLength, 04456 NULL 04457 ); 04458 ConsoleHeapFree(TransBuffer); 04459 } 04460 #else 04461 WriteOutputString(ScreenInfo, 04462 CommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CommandHistory)]->Command, 04463 WriteCoord, 04464 CONSOLE_REAL_UNICODE, 04465 &lStringLength, 04466 NULL 04467 ); 04468 // convert back to true unicode (got converted by WriteOutputString) 04469 if ((ScreenInfo->Flags & CONSOLE_OEMFONT_DISPLAY) && 04470 !(ScreenInfo->Console->FullScreenFlags & CONSOLE_FULLSCREEN)) { 04471 FalseUnicodeToRealUnicode(CommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CommandHistory)]->Command, 04472 lStringLength, 04473 ScreenInfo->Console->OutputCP); 04474 } 04475 #endif 04476 04477 // 04478 // write attributes to screen 04479 // 04480 04481 if (COMMAND_NUM_TO_INDEX(i,CommandHistory) == CurrentCommand) { 04482 WriteCoord.X = (SHORT)(Popup->Region.Left+1); 04483 // inverted attributes 04484 Attributes = (WORD)(((Popup->Attributes << 4) & 0xf0) | 04485 ((Popup->Attributes >> 4) & 0x0f)); 04486 lStringLength = POPUP_SIZE_X(Popup); 04487 FillOutput(ScreenInfo, 04488 Attributes, 04489 WriteCoord, 04490 CONSOLE_ATTRIBUTE, 04491 &lStringLength 04492 ); 04493 } 04494 04495 WriteCoord.Y += 1; 04496 } 04497 }

VOID EmptyCommandHistory IN PCOMMAND_HISTORY  CommandHistory  ) 
 

Definition at line 3227 of file server/cmdline.c.

References CLE_RESET, ConsoleHeapFree, NULL, and SHORT.

Referenced by ProcessCommandLine(), and SrvExpungeConsoleCommandHistory().

03230 { 03231 SHORT i; 03232 if (CommandHistory==NULL) 03233 return; 03234 for (i=0;i<CommandHistory->NumberOfCommands;i++) { 03235 ConsoleHeapFree(CommandHistory->Commands[i]); 03236 } 03237 CommandHistory->NumberOfCommands = 0; 03238 CommandHistory->LastAdded = -1; 03239 CommandHistory->LastDisplayed = -1; 03240 CommandHistory->FirstCommand = 0; 03241 CommandHistory->Flags = CLE_RESET; 03242 }

PCOMMAND_HISTORY FindCommandHistory IN PCONSOLE_INFORMATION  Console,
IN HANDLE  ProcessHandle
 

Definition at line 4564 of file server/cmdline.c.

References ASSERT, CLE_ALLOCATED, History, and NULL.

Referenced by FreeCommandHistory(), and SrvReadConsole().

04571 : 04572 04573 This routine marks the command history buffer freed. 04574 04575 Arguments: 04576 04577 Console - pointer to console. 04578 04579 ProcessHandle - handle to client process. 04580 04581 Return Value: 04582 04583 none. 04584 04585 --*/ 04586 04587 { 04588 PCOMMAND_HISTORY History; 04589 PLIST_ENTRY ListHead, ListNext; 04590 04591 ListHead = &Console->CommandHistoryList; 04592 ListNext = ListHead->Flink; 04593 while (ListNext != ListHead) { 04594 History = CONTAINING_RECORD( ListNext, COMMAND_HISTORY, ListLink ); 04595 ListNext = ListNext->Flink; 04596 if (History->ProcessHandle == ProcessHandle) { 04597 ASSERT(History->Flags & CLE_ALLOCATED); 04598 return History; 04599 } 04600 } 04601 return NULL; 04602 }

PCOMMAND_HISTORY FindExeCommandHistory IN PCONSOLE_INFORMATION  Console,
IN PVOID  AppName,
IN DWORD  AppNameLength,
IN BOOLEAN  UnicodeExe
 

Definition at line 1637 of file server/cmdline.c.

References CLE_ALLOCATED, ConsoleHeapAlloc, ConsoleHeapFree, ConvertInputToUnicode(), History, MAKE_TAG, my_wcsncmpi, NULL, TMP_TAG, Unicode, and USHORT.

Referenced by SrvExpungeConsoleCommandHistory(), SrvGetConsoleCommandHistory(), SrvGetConsoleCommandHistoryLength(), and SrvSetConsoleNumberOfCommands().

01643 { 01644 PCOMMAND_HISTORY History; 01645 PLIST_ENTRY ListHead, ListNext; 01646 PWCHAR AppNamePtr; 01647 01648 if (!Unicode) { 01649 AppNamePtr = (PWCHAR)ConsoleHeapAlloc(MAKE_TAG( TMP_TAG ),AppNameLength * sizeof(WCHAR)); 01650 if (AppNamePtr == NULL) { 01651 return NULL; 01652 } 01653 AppNameLength = ConvertInputToUnicode(Console->CP, 01654 AppName, 01655 AppNameLength, 01656 AppNamePtr, 01657 AppNameLength); 01658 AppNameLength *= 2; 01659 } else { 01660 AppNamePtr = AppName; 01661 } 01662 ListHead = &Console->CommandHistoryList; 01663 ListNext = ListHead->Flink; 01664 while (ListNext != ListHead) { 01665 History = CONTAINING_RECORD( ListNext, COMMAND_HISTORY, ListLink ); 01666 ListNext = ListNext->Flink; 01667 01668 if (History->Flags & CLE_ALLOCATED && 01669 !my_wcsncmpi(History->AppName,AppNamePtr,(USHORT)AppNameLength)) { 01670 if (!Unicode) { 01671 ConsoleHeapFree(AppNamePtr); 01672 } 01673 return History; 01674 } 01675 } 01676 if (!Unicode) { 01677 ConsoleHeapFree(AppNamePtr); 01678 } 01679 return NULL; 01680 }

SHORT FindMatchingCommand IN PCOMMAND_HISTORY  CommandHistory,
IN PWCHAR  CurrentCommand,
IN ULONG  CurrentCommandLength,
IN SHORT  CurrentIndex,
IN DWORD  Flags
 

Definition at line 4078 of file server/cmdline.c.

References CLE_RESET, _COMMAND::Command, COMMAND_IND_PREV, _COMMAND::CommandLength, FMCFL_EXACT_MATCH, FMCFL_JUST_LOOKING, my_wcsncmp, SHORT, and USHORT.

Referenced by AddCommand(), ProcessCommandLine(), and ProcessCommandListInput().

04094 { 04095 SHORT i; 04096 04097 if (CommandHistory->NumberOfCommands == 0) { 04098 return -1; 04099 } 04100 if (!(Flags & FMCFL_JUST_LOOKING) && (CommandHistory->Flags & CLE_RESET)) { 04101 CommandHistory->Flags &= ~CLE_RESET; 04102 } else { 04103 COMMAND_IND_PREV(CommandIndex, CommandHistory); 04104 } 04105 if (cbIn == 0) { 04106 return CommandIndex; 04107 } 04108 for (i=0;i<CommandHistory->NumberOfCommands;i++) { 04109 PCOMMAND pcmdT = CommandHistory->Commands[CommandIndex]; 04110 04111 if ((!(Flags & FMCFL_EXACT_MATCH) && (cbIn <= pcmdT->CommandLength)) || 04112 ((USHORT)cbIn == pcmdT->CommandLength)) { 04113 if (!my_wcsncmp(pcmdT->Command, pwszIn, (USHORT)cbIn)) { 04114 return CommandIndex; 04115 } 04116 } 04117 COMMAND_IND_PREV(CommandIndex, CommandHistory); 04118 } 04119 return -1; 04120 }

NTSTATUS GetChar IN PINPUT_INFORMATION  InputInfo,
OUT PWCHAR  Char,
IN BOOLEAN  Wait,
IN PCONSOLE_INFORMATION  Console,
IN PHANDLE_DATA  HandleData,
IN PCSR_API_MSG Message  OPTIONAL,
IN CSR_WAIT_ROUTINE WaitRoutine  OPTIONAL,
IN PVOID WaitParameter  OPTIONAL,
IN ULONG WaitParameterLength  OPTIONAL,
IN BOOLEAN WaitBlockExists  OPTIONAL,
OUT PBOOLEAN CommandLineEditingKeys  OPTIONAL,
OUT PBOOLEAN CommandLinePopupKeys  OPTIONAL,
OUT PBOOLEAN EnableScrollMode  OPTIONAL,
OUT PDWORD KeyState  OPTIONAL
 

Definition at line 263 of file server/stream.c.

References ASSERT, BOOL, CHAR, CharToWchar(), Event(), FALSE, HIBYTE, IsCommandLineEditingKey(), IsCommandLinePopupKey(), IsDbcsExemptionForHighAnsi(), KEYEVENTSTATE_EQUAL_WINMODS, LOBYTE, NT_SUCCESS, NTSTATUS(), ReadInputBuffer(), SHORT, Status, TRUE, UINT, and VkKeyScan().

Referenced by CommonMenuDisplay(), CookedRead(), ProcessCommandListInput(), ProcessCommandNumberInput(), ProcessCopyFromCharInput(), ProcessCopyToCharInput(), RawReadWaitRoutine(), and ReadChars().

00282 : 00283 00284 This routine is used in stream input. It gets input and filters it 00285 for unicode characters. 00286 00287 Arguments: 00288 00289 InputInfo - Pointer to input buffer information. 00290 00291 Char - Unicode char input. 00292 00293 Wait - TRUE if the routine shouldn't wait for input. 00294 00295 Console - Pointer to console buffer information. 00296 00297 HandleData - Pointer to handle data structure. 00298 00299 Message - csr api message. 00300 00301 WaitRoutine - Routine to call when wait is woken up. 00302 00303 WaitParameter - Parameter to pass to wait routine. 00304 00305 WaitParameterLength - Length of wait parameter. 00306 00307 WaitBlockExists - TRUE if wait block has already been created. 00308 00309 CommandLineEditingKeys - if present, arrow keys will be returned. on 00310 output, if TRUE, Char contains virtual key code for arrow key. 00311 00312 CommandLinePopupKeys - if present, arrow keys will be returned. on 00313 output, if TRUE, Char contains virtual key code for arrow key. 00314 00315 Return Value: 00316 00317 --*/ 00318 00319 { 00320 ULONG NumRead; 00321 INPUT_RECORD Event; 00322 NTSTATUS Status; 00323 00324 if (ARGUMENT_PRESENT(CommandLineEditingKeys)) { 00325 *CommandLineEditingKeys = FALSE; 00326 } 00327 if (ARGUMENT_PRESENT(CommandLinePopupKeys)) { 00328 *CommandLinePopupKeys = FALSE; 00329 } 00330 if (ARGUMENT_PRESENT(EnableScrollMode)) { 00331 *EnableScrollMode = FALSE; 00332 } 00333 if (ARGUMENT_PRESENT(KeyState)) { 00334 *KeyState = 0; 00335 } 00336 00337 NumRead = 1; 00338 while (TRUE) { 00339 Status =ReadInputBuffer(InputInfo, 00340 &Event, 00341 &NumRead, 00342 FALSE, 00343 Wait, 00344 TRUE, 00345 Console, 00346 HandleData, 00347 Message, 00348 WaitRoutine, 00349 WaitParameter, 00350 WaitParameterLength, 00351 WaitBlockExists 00352 #if defined(FE_SB) 00353 , 00354 TRUE 00355 #endif 00356 ); 00357 if (!NT_SUCCESS(Status)) { 00358 return Status; 00359 } 00360 if (NumRead == 0) { 00361 if (Wait) { 00362 ASSERT (FALSE); 00363 } 00364 else { 00365 return STATUS_UNSUCCESSFUL; 00366 } 00367 } 00368 if (Event.EventType == KEY_EVENT) { 00369 BOOL fCommandLineEditKey; 00370 00371 if (ARGUMENT_PRESENT(CommandLineEditingKeys)) { 00372 fCommandLineEditKey = IsCommandLineEditingKey(&Event.Event.KeyEvent); 00373 } else if (ARGUMENT_PRESENT(CommandLinePopupKeys)) { 00374 fCommandLineEditKey = IsCommandLinePopupKey(&Event.Event.KeyEvent); 00375 } else { 00376 fCommandLineEditKey = FALSE; 00377 } 00378 00379 // 00380 // Always return keystate if caller asked for it. 00381 // 00382 if (ARGUMENT_PRESENT(KeyState)) { 00383 *KeyState = Event.Event.KeyEvent.dwControlKeyState; 00384 } 00385 00386 if (Event.Event.KeyEvent.uChar.UnicodeChar != 0 && 00387 !fCommandLineEditKey) { 00388 00389 // 00390 // chars that are generated using alt+numpad 00391 // 00392 if (!Event.Event.KeyEvent.bKeyDown && 00393 Event.Event.KeyEvent.wVirtualKeyCode == VK_MENU) { 00394 if (Event.Event.KeyEvent.dwControlKeyState & ALTNUMPAD_BIT) 00395 { 00396 if (CONSOLE_IS_DBCS_CP(Console) && HIBYTE(Event.Event.KeyEvent.uChar.UnicodeChar)) { 00397 char chT[2] = { 00398 HIBYTE(Event.Event.KeyEvent.uChar.UnicodeChar), 00399 LOBYTE(Event.Event.KeyEvent.uChar.UnicodeChar), 00400 }; 00401 *Char = CharToWchar(Console, Console->CP, chT); 00402 } else { 00403 // Because USER doesn't know our codepage, it gives us the 00404 // raw OEM char and we convert it to a Unicode character. 00405 char chT = LOBYTE(Event.Event.KeyEvent.uChar.UnicodeChar); 00406 UINT uCodePage = Console->CP; 00407 00408 // 00409 // FarEast hack for High ANSI OEM characters. 00410 // 00411 if (CONSOLE_IS_DBCS_CP(Console)) { 00412 if (IsDbcsExemptionForHighAnsi(uCodePage, chT)) { 00413 /* 00414 * FarEast hack: 00415 * treat characters in High ANSI area as if they are 00416 * the ones of Codepage 1252. 00417 */ 00418 uCodePage = 1252; 00419 } 00420 } 00421 *Char = CharToWchar(Console, uCodePage, &chT); 00422 } 00423 } else { 00424 *Char = Event.Event.KeyEvent.uChar.UnicodeChar; 00425 } 00426 return STATUS_SUCCESS; 00427 } 00428 // 00429 // Ignore Escape and Newline chars 00430 // 00431 else if (Event.Event.KeyEvent.bKeyDown && 00432 Event.Event.KeyEvent.wVirtualKeyCode != VK_ESCAPE && 00433 Event.Event.KeyEvent.uChar.UnicodeChar != 0x0a) { 00434 00435 *Char = Event.Event.KeyEvent.uChar.UnicodeChar; 00436 return STATUS_SUCCESS; 00437 } 00438 } 00439 00440 if (Event.Event.KeyEvent.bKeyDown) { 00441 SHORT sTmp; 00442 if (ARGUMENT_PRESENT(CommandLineEditingKeys) && 00443 fCommandLineEditKey) { 00444 *CommandLineEditingKeys = TRUE; 00445 *Char = (WCHAR) Event.Event.KeyEvent.wVirtualKeyCode; 00446 return STATUS_SUCCESS; 00447 } 00448 else if (ARGUMENT_PRESENT(CommandLinePopupKeys) && 00449 fCommandLineEditKey) { 00450 *CommandLinePopupKeys = TRUE; 00451 *Char = (CHAR) Event.Event.KeyEvent.wVirtualKeyCode; 00452 return STATUS_SUCCESS; 00453 } 00454 00455 sTmp = VkKeyScan(0); 00456 00457 if ((LOBYTE(sTmp) == Event.Event.KeyEvent.wVirtualKeyCode) && 00458 KEYEVENTSTATE_EQUAL_WINMODS(Event, HIBYTE(sTmp))) { 00459 /* 00460 * This really is the character 0x0000 00461 */ 00462 *Char = Event.Event.KeyEvent.uChar.UnicodeChar; 00463 return STATUS_SUCCESS; 00464 } 00465 } 00466 } 00467 } 00468 }

PCOMMAND GetLastCommand IN PCOMMAND_HISTORY  CommandHistory  ) 
 

Definition at line 3217 of file server/cmdline.c.

References NULL.

Referenced by ProcessCommandLine(), and ProcessCopyToCharInput().

03220 { 03221 if (CommandHistory->NumberOfCommands == 0) 03222 return NULL; 03223 return CommandHistory->Commands[CommandHistory->LastDisplayed]; 03224 }

VOID InitExtendedEditKeys CONST ExtKeyDefBuf *  lpbuf  ) 
 

Definition at line 186 of file server/cmdline.c.

References BYTE, DbgPrint, DWORD, gaDefaultKeyDef, gaKeyDef, NULL, and VOID().

Referenced by GetRegistryValues().

00187 { 00188 CONST BYTE* lpbyte; 00189 int i; 00190 DWORD dwCheckSum; 00191 00192 // 00193 // Sanity check 00194 // If pKeyDefBuf is NULL, give it the default value. 00195 // If the version is not supported, just use the default and bail. 00196 // 00197 if (pKeyDefBuf == NULL || pKeyDefBuf->dwVersion != 0) { 00198 #if DBG 00199 if (pKeyDefBuf != NULL) { 00200 DbgPrint("InitExtendedEditKeys: Unsupported version number(%d)\n", pKeyDefBuf->dwVersion); 00201 } 00202 #endif 00203 retry_clean: 00204 memcpy(gaKeyDef, gaDefaultKeyDef, sizeof gaKeyDef); 00205 return; 00206 } 00207 00208 // 00209 // Calculate check sum 00210 // 00211 dwCheckSum = 0; 00212 for (lpbyte = (CONST BYTE*)pKeyDefBuf, i = FIELD_OFFSET(ExtKeyDefBuf, table); i < sizeof *pKeyDefBuf; ++i) { 00213 dwCheckSum += lpbyte[i]; 00214 } 00215 if (dwCheckSum != pKeyDefBuf->dwCheckSum) { 00216 #if DBG 00217 DbgPrint("InitExtendedEditKeys: Checksum(%d) does not match.\n", pKeyDefBuf->dwCheckSum); 00218 #endif 00219 goto retry_clean; 00220 } 00221 00222 // 00223 // Copy the entity 00224 // 00225 00226 memcpy(gaKeyDef, pKeyDefBuf->table, sizeof gaKeyDef); 00227 }

BOOL IsCommandLineEditingKey IN OUT PKEY_EVENT_RECORD  KeyEvent  ) 
 

Referenced by GetChar().

BOOL IsCommandLinePopupKey IN OUT PKEY_EVENT_RECORD  KeyEvent  ) 
 

Definition at line 2179 of file server/cmdline.c.

References FALSE, gExtendedEditKey, ParseEditKeyInfo(), and TRUE.

Referenced by GetChar().

02182 { 02183 if (!(KeyEvent->dwControlKeyState & 02184 (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED | 02185 RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))) { 02186 switch (KeyEvent->wVirtualKeyCode) { 02187 case VK_ESCAPE: 02188 case VK_PRIOR: 02189 case VK_NEXT: 02190 case VK_END: 02191 case VK_HOME: 02192 case VK_LEFT: 02193 case VK_UP: 02194 case VK_RIGHT: 02195 case VK_DOWN: 02196 case VK_F9: 02197 return TRUE; 02198 default: 02199 break; 02200 } 02201 } 02202 02203 // 02204 // Extended key handling 02205 // 02206 if (gExtendedEditKey && ParseEditKeyInfo(KeyEvent)) { 02207 return KeyEvent->uChar.UnicodeChar == 0; 02208 } 02209 02210 return FALSE; 02211 }

BOOL IsPauseKey IN PKEY_EVENT_RECORD  pKeyEvent  ) 
 

Definition at line 289 of file server/cmdline.c.

References BOOL, CTRL_BUT_NOT_ALT, gExtendedEditKey, L, NULL, and ParseEditKeyInfo().

Referenced by PreprocessInput().

00290 { 00291 if (gExtendedEditKey) { 00292 KEY_EVENT_RECORD KeyEvent = *pKeyEvent; 00293 CONST ExtKeySubst* pKeySubst = ParseEditKeyInfo(&KeyEvent); 00294 00295 return pKeySubst != NULL && pKeySubst->wVirKey == VK_PAUSE; 00296 } 00297 00298 return pKeyEvent->wVirtualKeyCode == L'S' && CTRL_BUT_NOT_ALT(pKeyEvent->dwControlKeyState); 00299 }

BOOL IsWordDelim WCHAR   ) 
 

Definition at line 309 of file server/cmdline.c.

References ASSERT, BOOL, FALSE, gaWordDelimChars, L, TRUE, and WORD_DELIM_MAX.

00310 { 00311 int i; 00312 00313 // 00314 // Before it reaches here, L' ' case should have beeen already detected, 00315 // and gaWordDelimChars is specified. 00316 // 00317 ASSERT(wch != L' ' && gaWordDelimChars[0]); 00318 00319 for (i = 0; gaWordDelimChars[i] && i < WORD_DELIM_MAX; ++i) { 00320 if (wch == gaWordDelimChars[i]) { 00321 return TRUE; 00322 } 00323 } 00324 00325 return FALSE; 00326 }

NTSTATUS ProcessCommandLine IN PCOOKED_READ_DATA  CookedReadData,
IN WCHAR  Char,
IN DWORD  KeyState,
IN PCSR_API_MSG  WaitReplyMessage,
IN PCSR_THREAD  WaitingThread,
IN BOOLEAN  WaitRoutine
 

Definition at line 3272 of file server/cmdline.c.

References AdjustCursorPosition, ASSERT, AT_EOL, AtFirstCommand(), AtLastCommand(), BeginPopup(), BOOL, CLE_ALLOCATED, ClearAliases(), _COMMAND::Command, COMMAND_NUM_TO_INDEX, COMMAND_NUMBER_LENGTH, COMMAND_NUMBER_PROMPT_LENGTH, _COMMAND::CommandLength, CommandListPopup(), CommandNumberPopup(), CONSOLE_IS_DBCS_ENABLED, COPY_FROM_CHAR_PROMPT_LENGTH, COPY_TO_CHAR_PROMPT_LENGTH, CopyFromCharPopup(), CopyToCharPopup(), CTRL_PRESSED, DBGPRINT, DeleteCommandLine(), DWORD, EmptyCommandHistory(), FALSE, FindMatchingCommand(), GetLastCommand(), IS_WORD_DELIM, MINIMUM_COMMAND_PROMPT_SIZE, NT_SUCCESS, NTSTATUS(), NULL, PBYTE, RetrieveCommand(), RetrieveNthCommand(), RetrieveNumberOfSpaces(), RetrieveTotalNumberOfSpaces(), SetCursorMode(), SetCursorPosition(), SHORT, Status, TRUE, USHORT, WC_DESTRUCTIVE_BACKSPACE, WC_ECHO, WC_KEEP_CURSOR_VISIBLE, and WriteCharsFromInput().

Referenced by CookedRead(), and ProcessCookedReadInput().

03286 : 03287 03288 CONSOLE_STATUS_WAIT - CommandListPopup ran out of input 03289 CONSOLE_STATUS_READ_COMPLETE - user hit <enter> in CommandListPopup 03290 STATUS_SUCCESS - everything's cool 03291 03292 --*/ 03293 03294 { 03295 COORD CurrentPosition; 03296 DWORD CharsToWrite; 03297 NTSTATUS Status; 03298 BOOL UpdateCursorPosition; 03299 SHORT ScrollY=0; 03300 BOOL fStartFromDelim; 03301 03302 UpdateCursorPosition = FALSE; 03303 if (Char == VK_F7 && 03304 !(KeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED | RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))) { 03305 COORD PopupSize; 03306 03307 if (CookedReadData->CommandHistory && 03308 CookedReadData->CommandHistory->NumberOfCommands) { 03309 PopupSize.X = 40; 03310 PopupSize.Y = 10; 03311 Status = BeginPopup(CookedReadData->ScreenInfo, 03312 CookedReadData->CommandHistory, 03313 PopupSize 03314 ); 03315 if (NT_SUCCESS(Status)) { 03316 // CommandListPopup does EndPopup call 03317 return CommandListPopup(CookedReadData, 03318 WaitReplyMessage, 03319 WaitingThread, 03320 WaitRoutine 03321 ); 03322 } 03323 } 03324 } else { 03325 switch (Char) { 03326 case VK_ESCAPE: 03327 DeleteCommandLine(CookedReadData, 03328 TRUE); 03329 break; 03330 case VK_UP: 03331 case VK_DOWN: 03332 case VK_F5: 03333 if (Char == VK_F5) 03334 Char = VK_UP; 03335 // for doskey compatibility, buffer isn't circular 03336 if (Char==VK_UP && !AtFirstCommand(CookedReadData->CommandHistory) || 03337 Char==VK_DOWN && !AtLastCommand(CookedReadData->CommandHistory)) { 03338 DeleteCommandLine(CookedReadData, 03339 TRUE); 03340 Status = RetrieveCommand(CookedReadData->CommandHistory, 03341 Char, 03342 CookedReadData->BackupLimit, 03343 CookedReadData->BufferSize, 03344 &CookedReadData->BytesRead); 03345 ASSERT(CookedReadData->BackupLimit == CookedReadData->BufPtr); 03346 if (CookedReadData->Echo) { 03347 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03348 CookedReadData->BackupLimit, 03349 CookedReadData->BufPtr, 03350 CookedReadData->BufPtr, 03351 &CookedReadData->BytesRead, 03352 (PLONG)&CookedReadData->NumberOfVisibleChars, 03353 CookedReadData->OriginalCursorPosition.X, 03354 WC_DESTRUCTIVE_BACKSPACE | 03355 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03356 &ScrollY ); 03357 ASSERT(NT_SUCCESS(Status)); 03358 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03359 } 03360 CharsToWrite = CookedReadData->BytesRead/sizeof(WCHAR); 03361 CookedReadData->CurrentPosition = CharsToWrite; 03362 CookedReadData->BufPtr = CookedReadData->BackupLimit + CharsToWrite; 03363 } 03364 break; 03365 case VK_PRIOR: 03366 case VK_NEXT: 03367 if (CookedReadData->CommandHistory && 03368 CookedReadData->CommandHistory->NumberOfCommands) { 03369 03370 // 03371 // display oldest or newest command 03372 // 03373 03374 SHORT CommandNumber; 03375 if (Char == VK_PRIOR) { 03376 CommandNumber = 0; 03377 } else { 03378 CommandNumber = (SHORT)(CookedReadData->CommandHistory->NumberOfCommands-1); 03379 } 03380 DeleteCommandLine(CookedReadData, 03381 TRUE); 03382 Status = RetrieveNthCommand(CookedReadData->CommandHistory, 03383 COMMAND_NUM_TO_INDEX(CommandNumber,CookedReadData->CommandHistory), 03384 CookedReadData->BackupLimit, 03385 CookedReadData->BufferSize, 03386 &CookedReadData->BytesRead); 03387 ASSERT(CookedReadData->BackupLimit == CookedReadData->BufPtr); 03388 if (CookedReadData->Echo) { 03389 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03390 CookedReadData->BackupLimit, 03391 CookedReadData->BufPtr, 03392 CookedReadData->BufPtr, 03393 &CookedReadData->BytesRead, 03394 (PLONG)&CookedReadData->NumberOfVisibleChars, 03395 CookedReadData->OriginalCursorPosition.X, 03396 WC_DESTRUCTIVE_BACKSPACE | 03397 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03398 &ScrollY 03399 ); 03400 ASSERT(NT_SUCCESS(Status)); 03401 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03402 } 03403 CharsToWrite = CookedReadData->BytesRead/sizeof(WCHAR); 03404 CookedReadData->CurrentPosition = CharsToWrite; 03405 CookedReadData->BufPtr = CookedReadData->BackupLimit + CharsToWrite; 03406 } 03407 break; 03408 case VK_END: 03409 if (KeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) { 03410 DeleteCommandLine(CookedReadData, 03411 FALSE); 03412 CookedReadData->BytesRead = CookedReadData->CurrentPosition*sizeof(WCHAR); 03413 if (CookedReadData->Echo) { 03414 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03415 CookedReadData->BackupLimit, 03416 CookedReadData->BackupLimit, 03417 CookedReadData->BackupLimit, 03418 &CookedReadData->BytesRead, 03419 (PLONG)&CookedReadData->NumberOfVisibleChars, 03420 CookedReadData->OriginalCursorPosition.X, 03421 WC_DESTRUCTIVE_BACKSPACE | 03422 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03423 NULL 03424 ); 03425 ASSERT(NT_SUCCESS(Status)); 03426 } 03427 } else { 03428 CookedReadData->CurrentPosition = CookedReadData->BytesRead/sizeof(WCHAR); 03429 CookedReadData->BufPtr = CookedReadData->BackupLimit + CookedReadData->CurrentPosition; 03430 CurrentPosition.X = (SHORT)(CookedReadData->OriginalCursorPosition.X + CookedReadData->NumberOfVisibleChars); 03431 CurrentPosition.Y = CookedReadData->OriginalCursorPosition.Y; 03432 #if defined(FE_SB) 03433 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 03434 CookedReadData->ScreenInfo->Console->CP, 03435 CookedReadData->BackupLimit, 03436 CookedReadData->CurrentPosition, 03437 CookedReadData->ScreenInfo->ScreenBufferSize.X-CookedReadData->OriginalCursorPosition.X, 03438 CookedReadData->OriginalCursorPosition.X, 03439 TRUE)) { 03440 CurrentPosition.X++; 03441 } 03442 #endif 03443 UpdateCursorPosition = TRUE; 03444 } 03445 break; 03446 case VK_HOME: 03447 if (KeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) { 03448 DeleteCommandLine(CookedReadData, 03449 FALSE); 03450 CookedReadData->BytesRead -= CookedReadData->CurrentPosition*sizeof(WCHAR); 03451 CookedReadData->CurrentPosition = 0; 03452 RtlCopyMemory(CookedReadData->BackupLimit, 03453 CookedReadData->BufPtr, 03454 CookedReadData->BytesRead 03455 ); 03456 CookedReadData->BufPtr = CookedReadData->BackupLimit; 03457 if (CookedReadData->Echo) { 03458 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03459 CookedReadData->BackupLimit, 03460 CookedReadData->BackupLimit, 03461 CookedReadData->BackupLimit, 03462 &CookedReadData->BytesRead, 03463 (PLONG)&CookedReadData->NumberOfVisibleChars, 03464 CookedReadData->OriginalCursorPosition.X, 03465 WC_DESTRUCTIVE_BACKSPACE | 03466 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03467 NULL 03468 ); 03469 ASSERT(NT_SUCCESS(Status)); 03470 } 03471 CurrentPosition = CookedReadData->OriginalCursorPosition; 03472 UpdateCursorPosition = TRUE; 03473 } else { 03474 CookedReadData->CurrentPosition = 0; 03475 CookedReadData->BufPtr = CookedReadData->BackupLimit; 03476 CurrentPosition = CookedReadData->OriginalCursorPosition; 03477 UpdateCursorPosition = TRUE; 03478 } 03479 break; 03480 case VK_LEFT: 03481 if (KeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) { 03482 PWCHAR LastWord; 03483 BOOL NonSpaceCharSeen=FALSE; 03484 if (CookedReadData->BufPtr != CookedReadData->BackupLimit) { 03485 LastWord = CookedReadData->BufPtr-1; 03486 while (LastWord != CookedReadData->BackupLimit) { 03487 if (!IS_WORD_DELIM(*LastWord)) 03488 NonSpaceCharSeen=TRUE; 03489 else 03490 if (NonSpaceCharSeen) 03491 break; 03492 LastWord--; 03493 } 03494 if (LastWord != CookedReadData->BackupLimit) { 03495 CookedReadData->BufPtr = LastWord+1; 03496 } else { 03497 CookedReadData->BufPtr = LastWord; 03498 } 03499 CookedReadData->CurrentPosition=(ULONG)(CookedReadData->BufPtr-CookedReadData->BackupLimit); 03500 CurrentPosition = CookedReadData->OriginalCursorPosition; 03501 #if defined(FE_SB) 03502 CurrentPosition.X = (SHORT)(CurrentPosition.X + 03503 RetrieveTotalNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03504 CookedReadData->BackupLimit, 03505 CookedReadData->CurrentPosition, 03506 CookedReadData->ScreenInfo->Console)); 03507 if (CheckBisectStringW(CookedReadData->ScreenInfo, 03508 CookedReadData->ScreenInfo->Console->CP, 03509 CookedReadData->BackupLimit, 03510 CookedReadData->CurrentPosition+1, 03511 CookedReadData->ScreenInfo->ScreenBufferSize.X 03512 -CookedReadData->OriginalCursorPosition.X 03513 )) { 03514 CurrentPosition.X++; 03515 } 03516 #else 03517 CurrentPosition.X = (SHORT)(CurrentPosition.X + RetrieveTotalNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03518 CookedReadData->BackupLimit, 03519 CookedReadData->CurrentPosition)); 03520 #endif 03521 UpdateCursorPosition = TRUE; 03522 } 03523 } else { 03524 if (CookedReadData->BufPtr != CookedReadData->BackupLimit) { 03525 CookedReadData->BufPtr--; 03526 CookedReadData->CurrentPosition--; 03527 CurrentPosition.X = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition.X; 03528 CurrentPosition.Y = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition.Y; 03529 #if defined(FE_SB) 03530 CurrentPosition.X = (SHORT)(CurrentPosition.X - 03531 RetrieveNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03532 CookedReadData->BackupLimit, 03533 CookedReadData->CurrentPosition, 03534 CookedReadData->ScreenInfo->Console, 03535 CookedReadData->ScreenInfo->Console->CP)); 03536 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 03537 CookedReadData->ScreenInfo->Console->CP, 03538 CookedReadData->BackupLimit, 03539 CookedReadData->CurrentPosition+2, 03540 CookedReadData->ScreenInfo->ScreenBufferSize.X 03541 -CookedReadData->OriginalCursorPosition.X, 03542 CookedReadData->OriginalCursorPosition.X, 03543 TRUE)) { 03544 if ((CurrentPosition.X == -2) || 03545 (CurrentPosition.X == -1)) { 03546 CurrentPosition.X--; 03547 } 03548 } 03549 #else 03550 CurrentPosition.X = (SHORT)(CurrentPosition.X - RetrieveNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03551 CookedReadData->BackupLimit, 03552 CookedReadData->CurrentPosition)); 03553 #endif 03554 UpdateCursorPosition = TRUE; 03555 } 03556 } 03557 break; 03558 case VK_RIGHT: 03559 case VK_F1: 03560 03561 // 03562 // we don't need to check for end of buffer here because we've 03563 // already done it. 03564 // 03565 03566 if (KeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) { 03567 if (Char != VK_F1) { 03568 PWCHAR NextWord; 03569 SHORT i; 03570 if (CookedReadData->CurrentPosition < (CookedReadData->BytesRead/sizeof(WCHAR))) { 03571 NextWord = CookedReadData->BufPtr; 03572 for (i=(SHORT)(CookedReadData->CurrentPosition); 03573 i<(SHORT)((CookedReadData->BytesRead-1)/sizeof(WCHAR)); 03574 i++) { 03575 if (IS_WORD_DELIM(*NextWord)) { 03576 i++; 03577 NextWord++; 03578 while ((i<(SHORT)((CookedReadData->BytesRead-1)/sizeof(WCHAR))) && 03579 IS_WORD_DELIM(*NextWord)) { 03580 i++; 03581 NextWord++; 03582 } 03583 break; 03584 } 03585 NextWord++; 03586 } 03587 CookedReadData->BufPtr = NextWord; 03588 CookedReadData->CurrentPosition=(ULONG)(CookedReadData->BufPtr-CookedReadData->BackupLimit); 03589 #if defined(FE_SB) 03590 CurrentPosition = CookedReadData->OriginalCursorPosition; 03591 CurrentPosition.X = (SHORT)(CurrentPosition.X + 03592 RetrieveTotalNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03593 CookedReadData->BackupLimit, 03594 CookedReadData->CurrentPosition, 03595 CookedReadData->ScreenInfo->Console)); 03596 if (CheckBisectStringW(CookedReadData->ScreenInfo, 03597 CookedReadData->ScreenInfo->Console->CP, 03598 CookedReadData->BackupLimit, 03599 CookedReadData->CurrentPosition+1, 03600 CookedReadData->ScreenInfo->ScreenBufferSize.X 03601 -CookedReadData->OriginalCursorPosition.X 03602 )) { 03603 CurrentPosition.X++; 03604 } 03605 #else 03606 CurrentPosition = CookedReadData->OriginalCursorPosition; 03607 CurrentPosition.X = (SHORT)(CurrentPosition.X + RetrieveTotalNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03608 CookedReadData->BackupLimit, 03609 CookedReadData->CurrentPosition)); 03610 #endif 03611 UpdateCursorPosition = TRUE; 03612 } 03613 } 03614 } else { 03615 03616 // 03617 // if not at the end of the line, move cursor position right 03618 // 03619 03620 if (CookedReadData->CurrentPosition < (CookedReadData->BytesRead/sizeof(WCHAR))) { 03621 CurrentPosition = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition; 03622 #if defined(FE_SB) 03623 CurrentPosition.X = (SHORT)(CurrentPosition.X + 03624 RetrieveNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03625 CookedReadData->BackupLimit, 03626 CookedReadData->CurrentPosition, 03627 CookedReadData->ScreenInfo->Console, 03628 CookedReadData->ScreenInfo->Console->CP)); 03629 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 03630 CookedReadData->ScreenInfo->Console->CP, 03631 CookedReadData->BackupLimit, 03632 CookedReadData->CurrentPosition+2, 03633 CookedReadData->ScreenInfo->ScreenBufferSize.X 03634 -CookedReadData->OriginalCursorPosition.X, 03635 CookedReadData->OriginalCursorPosition.X, 03636 TRUE)) { 03637 if (CurrentPosition.X == (CookedReadData->ScreenInfo->ScreenBufferSize.X-1)) 03638 CurrentPosition.X++; 03639 } 03640 #else 03641 CurrentPosition.X = (SHORT)(CurrentPosition.X + RetrieveNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 03642 CookedReadData->BackupLimit, 03643 CookedReadData->CurrentPosition)); 03644 #endif 03645 CookedReadData->BufPtr++; 03646 CookedReadData->CurrentPosition++; 03647 UpdateCursorPosition = TRUE; 03648 03649 // 03650 // if at the end of the line, copy a character from the 03651 // same position in the last command 03652 // 03653 03654 } else if (CookedReadData->CommandHistory) { 03655 PCOMMAND LastCommand; 03656 DWORD NumSpaces; 03657 LastCommand = GetLastCommand(CookedReadData->CommandHistory); 03658 if (LastCommand && (USHORT)(LastCommand->CommandLength/sizeof(WCHAR)) > (USHORT)CookedReadData->CurrentPosition) { 03659 *CookedReadData->BufPtr = LastCommand->Command[CookedReadData->CurrentPosition]; 03660 CookedReadData->BytesRead += sizeof(WCHAR); 03661 CookedReadData->CurrentPosition++; 03662 if (CookedReadData->Echo) { 03663 CharsToWrite = sizeof(WCHAR); 03664 Status = WriteCharsFromInput( 03665 CookedReadData->ScreenInfo, 03666 CookedReadData->BackupLimit, 03667 CookedReadData->BufPtr, 03668 CookedReadData->BufPtr, 03669 &CharsToWrite, 03670 (PLONG)&NumSpaces, 03671 CookedReadData->OriginalCursorPosition.X, 03672 WC_DESTRUCTIVE_BACKSPACE | 03673 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03674 &ScrollY); 03675 ASSERT(NT_SUCCESS(Status)); 03676 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03677 CookedReadData->NumberOfVisibleChars += NumSpaces; 03678 } 03679 CookedReadData->BufPtr+=1; 03680 } 03681 } 03682 } 03683 break; 03684 case VK_F2: 03685 03686 // 03687 // copy the previous command to the current command, up to but 03688 // not including the character specified by the user. the user 03689 // is prompted via popup to enter a character. 03690 // 03691 03692 if (CookedReadData->CommandHistory) { 03693 COORD PopupSize; 03694 03695 PopupSize.X = COPY_TO_CHAR_PROMPT_LENGTH+2; 03696 PopupSize.Y = 1; 03697 Status = BeginPopup(CookedReadData->ScreenInfo, 03698 CookedReadData->CommandHistory, 03699 PopupSize 03700 ); 03701 if (NT_SUCCESS(Status)) { 03702 // CopyToCharPopup does EndPopup call 03703 return CopyToCharPopup(CookedReadData, 03704 WaitReplyMessage, 03705 WaitingThread, 03706 WaitRoutine 03707 ); 03708 } 03709 } 03710 break; 03711 case VK_F3: 03712 03713 // 03714 // copy the remainder of the previous command to the current command. 03715 // 03716 03717 if (CookedReadData->CommandHistory) { 03718 PCOMMAND LastCommand; 03719 DWORD NumSpaces; 03720 int j; // chars, not bytes 03721 LastCommand = GetLastCommand(CookedReadData->CommandHistory); 03722 if (LastCommand && (USHORT)(LastCommand->CommandLength/sizeof(WCHAR)) > (USHORT)CookedReadData->CurrentPosition) { 03723 j = (LastCommand->CommandLength/sizeof(WCHAR)) - CookedReadData->CurrentPosition; 03724 RtlCopyMemory(CookedReadData->BufPtr, 03725 &LastCommand->Command[CookedReadData->CurrentPosition], 03726 j*sizeof(WCHAR) 03727 ); 03728 CookedReadData->CurrentPosition += j; 03729 j *= sizeof(WCHAR); 03730 CookedReadData->BytesRead += j; 03731 if (CookedReadData->Echo) { 03732 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03733 CookedReadData->BackupLimit, 03734 CookedReadData->BufPtr, 03735 CookedReadData->BufPtr, 03736 (PDWORD) &j, 03737 (PLONG)&NumSpaces, 03738 CookedReadData->OriginalCursorPosition.X, 03739 WC_DESTRUCTIVE_BACKSPACE | 03740 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03741 &ScrollY); 03742 ASSERT(NT_SUCCESS(Status)); 03743 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03744 CookedReadData->NumberOfVisibleChars += NumSpaces; 03745 } 03746 CookedReadData->BufPtr+=j/sizeof(WCHAR); 03747 } 03748 } 03749 break; 03750 case VK_F4: 03751 03752 // 03753 // copy the previous command to the current command, from 03754 // the letter specified by the user. the user 03755 // is prompted via popup to enter a character. 03756 // 03757 03758 if (CookedReadData->CommandHistory) { 03759 COORD PopupSize; 03760 03761 PopupSize.X = COPY_FROM_CHAR_PROMPT_LENGTH+2; 03762 PopupSize.Y = 1; 03763 Status = BeginPopup(CookedReadData->ScreenInfo, 03764 CookedReadData->CommandHistory, 03765 PopupSize 03766 ); 03767 if (NT_SUCCESS(Status)) { 03768 // CopyFromCharPopup does EndPopup call 03769 return CopyFromCharPopup(CookedReadData, 03770 WaitReplyMessage, 03771 WaitingThread, 03772 WaitRoutine 03773 ); 03774 } 03775 } 03776 break; 03777 case VK_F6: 03778 03779 // 03780 // place a ctrl-z in the current command line 03781 // 03782 03783 { 03784 DWORD NumSpaces; 03785 *CookedReadData->BufPtr = (WCHAR)0x1a; // ctrl-z 03786 CookedReadData->BytesRead += sizeof(WCHAR); 03787 CookedReadData->CurrentPosition++; 03788 if (CookedReadData->Echo) { 03789 CharsToWrite = sizeof(WCHAR); 03790 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03791 CookedReadData->BackupLimit, 03792 CookedReadData->BufPtr, 03793 CookedReadData->BufPtr, 03794 &CharsToWrite, 03795 (PLONG)&NumSpaces, 03796 CookedReadData->OriginalCursorPosition.X, 03797 WC_DESTRUCTIVE_BACKSPACE | 03798 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03799 &ScrollY 03800 ); 03801 ASSERT(NT_SUCCESS(Status)); 03802 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03803 CookedReadData->NumberOfVisibleChars += NumSpaces; 03804 } 03805 CookedReadData->BufPtr+=1; 03806 } 03807 break; 03808 case VK_F7: 03809 if (KeyState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) { 03810 EmptyCommandHistory(CookedReadData->CommandHistory); 03811 CookedReadData->CommandHistory->Flags |= CLE_ALLOCATED; 03812 } 03813 break; 03814 case VK_F8: 03815 if (CookedReadData->CommandHistory) { 03816 SHORT i; 03817 03818 // 03819 // cycles through the stored commands that start with 03820 // the characters in the current command 03821 // 03822 03823 i = FindMatchingCommand(CookedReadData->CommandHistory, 03824 CookedReadData->BackupLimit, 03825 CookedReadData->CurrentPosition*sizeof(WCHAR), 03826 CookedReadData->CommandHistory->LastDisplayed, 0); 03827 if (i!=-1) { 03828 SHORT CurrentPosition; 03829 COORD CursorPosition; 03830 03831 // 03832 // save cursor position 03833 // 03834 03835 CurrentPosition = (SHORT)CookedReadData->CurrentPosition; 03836 CursorPosition = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition; 03837 03838 DeleteCommandLine(CookedReadData, 03839 TRUE); 03840 Status = RetrieveNthCommand(CookedReadData->CommandHistory, 03841 i, 03842 CookedReadData->BackupLimit, 03843 CookedReadData->BufferSize, 03844 &CookedReadData->BytesRead); 03845 ASSERT(CookedReadData->BackupLimit == CookedReadData->BufPtr); 03846 if (CookedReadData->Echo) { 03847 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03848 CookedReadData->BackupLimit, 03849 CookedReadData->BufPtr, 03850 CookedReadData->BufPtr, 03851 &CookedReadData->BytesRead, 03852 (PLONG)&CookedReadData->NumberOfVisibleChars, 03853 CookedReadData->OriginalCursorPosition.X, 03854 WC_DESTRUCTIVE_BACKSPACE | 03855 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03856 &ScrollY); 03857 ASSERT(NT_SUCCESS(Status)); 03858 CookedReadData->OriginalCursorPosition.Y += ScrollY; 03859 } 03860 CursorPosition.Y += ScrollY; 03861 03862 // 03863 // restore cursor position 03864 // 03865 03866 CookedReadData->BufPtr = CookedReadData->BackupLimit + CurrentPosition; 03867 CookedReadData->CurrentPosition = CurrentPosition; 03868 Status = SetCursorPosition(CookedReadData->ScreenInfo, 03869 CursorPosition, 03870 TRUE 03871 ); 03872 ASSERT(NT_SUCCESS(Status)); 03873 } 03874 } 03875 break; 03876 case VK_F9: 03877 03878 // 03879 // prompt the user to enter the desired command number. 03880 // copy that command to the command line. 03881 // 03882 03883 { 03884 COORD PopupSize; 03885 03886 if (CookedReadData->CommandHistory && 03887 CookedReadData->CommandHistory->NumberOfCommands && 03888 CookedReadData->ScreenInfo->ScreenBufferSize.X >= MINIMUM_COMMAND_PROMPT_SIZE+2) { // 2 is for border 03889 PopupSize.X = COMMAND_NUMBER_PROMPT_LENGTH+COMMAND_NUMBER_LENGTH; 03890 PopupSize.Y = 1; 03891 Status = BeginPopup(CookedReadData->ScreenInfo, 03892 CookedReadData->CommandHistory, 03893 PopupSize 03894 ); 03895 if (NT_SUCCESS(Status)) { 03896 // CommandNumberPopup does EndPopup call 03897 return CommandNumberPopup(CookedReadData, 03898 WaitReplyMessage, 03899 WaitingThread, 03900 WaitRoutine 03901 ); 03902 } 03903 } 03904 } 03905 break; 03906 case VK_F10: 03907 if (KeyState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) { 03908 ClearAliases(CookedReadData->Console); 03909 } 03910 break; 03911 case VK_INSERT: 03912 CookedReadData->InsertMode = !CookedReadData->InsertMode; 03913 SetCursorMode(CookedReadData->ScreenInfo, 03914 (BOOLEAN)(CookedReadData->InsertMode != CookedReadData->Console->InsertMode)); 03915 break; 03916 case VK_DELETE: 03917 if (!AT_EOL(CookedReadData)) { 03918 COORD CursorPosition; 03919 03920 fStartFromDelim = IS_WORD_DELIM(*CookedReadData->BufPtr); 03921 03922 del_repeat: 03923 // 03924 // save cursor position 03925 // 03926 03927 CursorPosition = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition; 03928 03929 // 03930 // deletecommandline 03931 // 03932 03933 DeleteCommandLine(CookedReadData, 03934 FALSE); 03935 // 03936 // delete char 03937 // 03938 03939 CookedReadData->BytesRead -= sizeof(WCHAR); 03940 RtlCopyMemory(CookedReadData->BufPtr, 03941 CookedReadData->BufPtr+1, 03942 CookedReadData->BytesRead - (CookedReadData->CurrentPosition*sizeof(WCHAR)) 03943 ); 03944 03945 #if defined(FE_SB) 03946 { 03947 PWCHAR buf = (PWCHAR)((PBYTE)CookedReadData->BackupLimit + 03948 CookedReadData->BytesRead ); 03949 *buf = (WCHAR)' '; 03950 } 03951 #endif 03952 // 03953 // write commandline 03954 // 03955 03956 if (CookedReadData->Echo) { 03957 Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 03958 CookedReadData->BackupLimit, 03959 CookedReadData->BackupLimit, 03960 CookedReadData->BackupLimit, 03961 &CookedReadData->BytesRead, 03962 (PLONG)&CookedReadData->NumberOfVisibleChars, 03963 CookedReadData->OriginalCursorPosition.X, 03964 WC_DESTRUCTIVE_BACKSPACE | 03965 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 03966 NULL); 03967 ASSERT(NT_SUCCESS(Status)); 03968 } 03969 03970 // 03971 // restore cursor position 03972 // 03973 03974 if (CONSOLE_IS_DBCS_ENABLED() && CONSOLE_IS_DBCS_CP(CookedReadData->Console)) { 03975 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 03976 CookedReadData->ScreenInfo->Console->CP, 03977 CookedReadData->BackupLimit, 03978 CookedReadData->CurrentPosition+1, 03979 CookedReadData->ScreenInfo->ScreenBufferSize.X 03980 -CookedReadData->OriginalCursorPosition.X, 03981 CookedReadData->OriginalCursorPosition.X, 03982 TRUE)) { 03983 CursorPosition.X++; 03984 } 03985 CurrentPosition = CursorPosition; 03986 if (CookedReadData->Echo) { 03987 Status = AdjustCursorPosition(CookedReadData->ScreenInfo, 03988 CurrentPosition, 03989 TRUE, 03990 NULL); 03991 ASSERT(NT_SUCCESS(Status)); 03992 } 03993 } 03994 else { 03995 Status = SetCursorPosition(CookedReadData->ScreenInfo, 03996 CursorPosition, 03997 TRUE 03998 ); 03999 ASSERT(NT_SUCCESS(Status)); 04000 } 04001 04002 // If Ctrl key is pressed, delete a word. 04003 // If the start point was word delimiter, just remove delimiters portion only. 04004 if ((KeyState & CTRL_PRESSED) && !AT_EOL(CookedReadData) && 04005 fStartFromDelim ^ !IS_WORD_DELIM(*CookedReadData->BufPtr)) { 04006 DBGPRINT(("Repeating it(%x).\n", *CookedReadData->BufPtr)); 04007 goto del_repeat; 04008 } 04009 } 04010 break; 04011 default: 04012 ASSERT(FALSE); 04013 break; 04014 } 04015 } 04016 if (UpdateCursorPosition && CookedReadData->Echo) { 04017 Status = AdjustCursorPosition(CookedReadData->ScreenInfo, 04018 CurrentPosition, 04019 TRUE, 04020 NULL); 04021 ASSERT(NT_SUCCESS(Status)); 04022 } 04023 return STATUS_SUCCESS; 04024 }

BOOL ProcessCookedReadInput IN PCOOKED_READ_DATA  CookedReadData,
IN WCHAR  Char,
IN DWORD  KeyState,
OUT PNTSTATUS  Status
 

Definition at line 876 of file server/stream.c.

References AdjustCursorPosition, ASSERT, AT_EOL, BOOL, DeleteCommandLine(), DWORD, FALSE, gExtendedEditKey, INSERT_MODE, IS_WORD_DELIM, L, NT_SUCCESS, NULL, PBYTE, ProcessCommandLine(), RetrieveNumberOfSpaces(), SHORT, Status, TRUE, UNICODE_BACKSPACE, UNICODE_BACKSPACE2, UNICODE_CARRIAGERETURN, UNICODE_LINEFEED, WC_DESTRUCTIVE_BACKSPACE, WC_ECHO, WC_KEEP_CURSOR_VISIBLE, and WriteCharsFromInput().

Referenced by CookedRead(), and ProcessCommandListInput().

00885 : 00886 00887 TRUE if read is completed 00888 --*/ 00889 00890 { 00891 DWORD NumSpaces; 00892 SHORT ScrollY=0; 00893 ULONG NumToWrite; 00894 WCHAR wchOrig = Char; 00895 BOOL fStartFromDelim; 00896 00897 *Status = STATUS_SUCCESS; 00898 if (CookedReadData->BytesRead >= (CookedReadData->BufferSize-(2*sizeof(WCHAR))) && 00899 Char != UNICODE_CARRIAGERETURN && 00900 Char != UNICODE_BACKSPACE) { 00901 return FALSE; 00902 } 00903 00904 if (CookedReadData->CtrlWakeupMask != 0 && 00905 Char < L' ' && (CookedReadData->CtrlWakeupMask & (1 << Char))) { 00906 *CookedReadData->BufPtr = Char; 00907 CookedReadData->BytesRead += sizeof(WCHAR); 00908 CookedReadData->BufPtr+=1; 00909 CookedReadData->CurrentPosition+=1; 00910 CookedReadData->ControlKeyState = KeyState; 00911 return TRUE; 00912 } 00913 00914 00915 if (Char == EXTKEY_ERASE_PREV_WORD) { 00916 Char = UNICODE_BACKSPACE; 00917 00918 } 00919 if (AT_EOL(CookedReadData)) { 00920 00921 // 00922 // if at end of line, processing is relatively simple. just store the 00923 // character and write it to the screen. 00924 // 00925 00926 00927 if (Char == UNICODE_BACKSPACE2) { 00928 Char = UNICODE_BACKSPACE; 00929 } 00930 if (Char != UNICODE_BACKSPACE || 00931 CookedReadData->BufPtr != CookedReadData->BackupLimit) { 00932 00933 fStartFromDelim = gExtendedEditKey && IS_WORD_DELIM(CookedReadData->BufPtr[-1]); 00934 00935 eol_repeat: 00936 if (CookedReadData->Echo) { 00937 NumToWrite=sizeof(WCHAR); 00938 *Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 00939 CookedReadData->BackupLimit, 00940 CookedReadData->BufPtr, 00941 &Char, 00942 &NumToWrite, 00943 (PLONG)&NumSpaces, 00944 CookedReadData->OriginalCursorPosition.X, 00945 WC_DESTRUCTIVE_BACKSPACE | 00946 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 00947 &ScrollY 00948 ); 00949 if (NT_SUCCESS(*Status)) { 00950 CookedReadData->OriginalCursorPosition.Y += ScrollY; 00951 } else { 00952 RIPMSG1(RIP_WARNING, "WriteCharsFromInput failed %x", *Status); 00953 } 00954 } 00955 CookedReadData->NumberOfVisibleChars += NumSpaces; 00956 if (Char == UNICODE_BACKSPACE && CookedReadData->Processed) { 00957 CookedReadData->BytesRead -= sizeof(WCHAR); 00958 *CookedReadData->BufPtr=(WCHAR)' '; 00959 CookedReadData->BufPtr-=1; 00960 CookedReadData->CurrentPosition-=1; 00961 00962 // Repeat until it hits the word boundary 00963 if (gExtendedEditKey && 00964 wchOrig == EXTKEY_ERASE_PREV_WORD && 00965 CookedReadData->BufPtr != CookedReadData->BackupLimit && 00966 fStartFromDelim ^ !IS_WORD_DELIM(CookedReadData->BufPtr[-1])) { 00967 goto eol_repeat; 00968 } 00969 } 00970 else { 00971 *CookedReadData->BufPtr = Char; 00972 CookedReadData->BytesRead += sizeof(WCHAR); 00973 CookedReadData->BufPtr+=1; 00974 CookedReadData->CurrentPosition+=1; 00975 } 00976 } 00977 } else { 00978 BOOL CallWrite=TRUE; 00979 00980 // 00981 // processing in the middle of the line is more complex: 00982 // 00983 // 00984 // calculate new cursor position 00985 // store new char 00986 // clear the current command line from the screen 00987 // write the new command line to the screen 00988 // update the cursor position 00989 // 00990 00991 if (Char == UNICODE_BACKSPACE && CookedReadData->Processed) { 00992 00993 // 00994 // for backspace, use writechars to calculate the new cursor position. 00995 // this call also sets the cursor to the right position for the 00996 // second call to writechars. 00997 // 00998 if (CookedReadData->BufPtr != CookedReadData->BackupLimit) { 00999 01000 fStartFromDelim = gExtendedEditKey && IS_WORD_DELIM(CookedReadData->BufPtr[-1]); 01001 01002 bs_repeat: 01003 01004 // 01005 // we call writechar here so that cursor position gets updated 01006 // correctly. we also call it later if we're not at eol so 01007 // that the remainder of the string can be updated correctly. 01008 // 01009 01010 if (CookedReadData->Echo) { 01011 NumToWrite=sizeof(WCHAR); 01012 *Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 01013 CookedReadData->BackupLimit, 01014 CookedReadData->BufPtr, 01015 &Char, 01016 &NumToWrite, 01017 NULL, 01018 CookedReadData->OriginalCursorPosition.X, 01019 WC_DESTRUCTIVE_BACKSPACE | 01020 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 01021 NULL); 01022 01023 if (!NT_SUCCESS(*Status)) { 01024 RIPMSG1(RIP_WARNING, "WriteCharsFromInput failed %x", *Status); 01025 } 01026 } 01027 CookedReadData->BytesRead -= sizeof(WCHAR); 01028 CookedReadData->BufPtr-=1; 01029 CookedReadData->CurrentPosition-=1; 01030 RtlCopyMemory(CookedReadData->BufPtr, 01031 CookedReadData->BufPtr+1, 01032 CookedReadData->BytesRead - (CookedReadData->CurrentPosition * sizeof(WCHAR)) 01033 ); 01034 #if defined(FE_SB) 01035 { 01036 PWCHAR buf = (PWCHAR)((PBYTE)CookedReadData->BackupLimit + 01037 CookedReadData->BytesRead ); 01038 *buf = (WCHAR)' '; 01039 } 01040 #endif 01041 NumSpaces = 0; 01042 01043 // Repeat until it hits the word boundary 01044 if (gExtendedEditKey && 01045 wchOrig == EXTKEY_ERASE_PREV_WORD && 01046 CookedReadData->BufPtr != CookedReadData->BackupLimit && 01047 fStartFromDelim ^ !IS_WORD_DELIM(CookedReadData->BufPtr[-1])) { 01048 goto bs_repeat; 01049 } 01050 } else { 01051 CallWrite = FALSE; 01052 } 01053 } else { 01054 01055 // 01056 // store the char 01057 // 01058 01059 if (Char == UNICODE_CARRIAGERETURN) { 01060 CookedReadData->BufPtr = (PWCHAR)((PBYTE)CookedReadData->BackupLimit + CookedReadData->BytesRead); 01061 *CookedReadData->BufPtr = Char; 01062 CookedReadData->BufPtr+=1; 01063 CookedReadData->BytesRead += sizeof(WCHAR); 01064 CookedReadData->CurrentPosition += 1; 01065 } else { 01066 #if defined(FE_SB) 01067 BOOL fBisect = FALSE; 01068 if (CookedReadData->Echo) { 01069 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 01070 CookedReadData->ScreenInfo->Console->CP, 01071 CookedReadData->BackupLimit, 01072 CookedReadData->CurrentPosition+1, 01073 CookedReadData->ScreenInfo->ScreenBufferSize.X 01074 -CookedReadData->OriginalCursorPosition.X, 01075 CookedReadData->OriginalCursorPosition.X, 01076 TRUE)) { 01077 fBisect = TRUE; 01078 } 01079 } 01080 #endif 01081 if (INSERT_MODE(CookedReadData)) { 01082 memmove(CookedReadData->BufPtr+1, 01083 CookedReadData->BufPtr, 01084 CookedReadData->BytesRead - (CookedReadData->CurrentPosition * sizeof(WCHAR)) 01085 ); 01086 CookedReadData->BytesRead += sizeof(WCHAR); 01087 } 01088 *CookedReadData->BufPtr = Char; 01089 CookedReadData->BufPtr+=1; 01090 CookedReadData->CurrentPosition += 1; 01091 01092 // 01093 // calculate new cursor position 01094 // 01095 01096 if (CookedReadData->Echo) { 01097 NumSpaces = RetrieveNumberOfSpaces(CookedReadData->OriginalCursorPosition.X, 01098 CookedReadData->BackupLimit, 01099 CookedReadData->CurrentPosition-1 01100 #if defined(FE_SB) 01101 , 01102 CookedReadData->ScreenInfo->Console, 01103 CookedReadData->ScreenInfo->Console->CP 01104 #endif 01105 ); 01106 #if defined(FE_SB) 01107 if (NumSpaces > 0 && fBisect) 01108 NumSpaces--; 01109 #endif 01110 } 01111 } 01112 } 01113 01114 if (CookedReadData->Echo && CallWrite) { 01115 01116 COORD CursorPosition; 01117 01118 // 01119 // save cursor position 01120 // 01121 01122 CursorPosition = CookedReadData->ScreenInfo->BufferInfo.TextInfo.CursorPosition; 01123 CursorPosition.X = (SHORT)(CursorPosition.X+NumSpaces); 01124 01125 // 01126 // clear the current command line from the screen 01127 // 01128 01129 DeleteCommandLine(CookedReadData, 01130 FALSE); 01131 01132 // 01133 // write the new command line to the screen 01134 // 01135 01136 NumToWrite = CookedReadData->BytesRead; 01137 *Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 01138 CookedReadData->BackupLimit, 01139 CookedReadData->BackupLimit, 01140 CookedReadData->BackupLimit, 01141 &NumToWrite, 01142 (PLONG)&CookedReadData->NumberOfVisibleChars, 01143 CookedReadData->OriginalCursorPosition.X, 01144 (Char != UNICODE_CARRIAGERETURN) ? 01145 WC_DESTRUCTIVE_BACKSPACE | WC_ECHO : 01146 WC_DESTRUCTIVE_BACKSPACE | WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 01147 &ScrollY 01148 ); 01149 if (!NT_SUCCESS(*Status)) { 01150 RIPMSG1(RIP_WARNING, "WriteCharsFromInput failed %x", *Status); 01151 CookedReadData->BytesRead = 0; 01152 return TRUE; 01153 } 01154 01155 // 01156 // update cursor position 01157 // 01158 01159 if (Char != UNICODE_CARRIAGERETURN) { 01160 #if defined(FE_SB) 01161 if (CheckBisectProcessW(CookedReadData->ScreenInfo, 01162 CookedReadData->ScreenInfo->Console->CP, 01163 CookedReadData->BackupLimit, 01164 CookedReadData->CurrentPosition+1, 01165 CookedReadData->ScreenInfo->ScreenBufferSize.X 01166 -CookedReadData->OriginalCursorPosition.X, 01167 CookedReadData->OriginalCursorPosition.X, 01168 TRUE)) { 01169 if (CursorPosition.X == (CookedReadData->ScreenInfo->ScreenBufferSize.X-1)) 01170 CursorPosition.X++; 01171 } 01172 #endif 01173 01174 // adjust cursor position for WriteChars 01175 CookedReadData->OriginalCursorPosition.Y += ScrollY; 01176 CursorPosition.Y += ScrollY; 01177 *Status = AdjustCursorPosition(CookedReadData->ScreenInfo, 01178 CursorPosition, 01179 TRUE, 01180 NULL); 01181 ASSERT(NT_SUCCESS(*Status)); 01182 if (!NT_SUCCESS(*Status)) { 01183 CookedReadData->BytesRead = 0; 01184 return TRUE; 01185 } 01186 } 01187 } 01188 } 01189 01190 // 01191 // in cooked mode, enter (carriage return) is converted to 01192 // carriage return linefeed (0xda). carriage return is always 01193 // stored at the end of the buffer. 01194 // 01195 01196 if (Char == UNICODE_CARRIAGERETURN) { 01197 if (CookedReadData->Processed) { 01198 if (CookedReadData->BytesRead < CookedReadData->BufferSize) { 01199 *CookedReadData->BufPtr = UNICODE_LINEFEED; 01200 if (CookedReadData->Echo) { 01201 NumToWrite=sizeof(WCHAR); 01202 *Status = WriteCharsFromInput(CookedReadData->ScreenInfo, 01203 CookedReadData->BackupLimit, 01204 CookedReadData->BufPtr, 01205 CookedReadData->BufPtr, 01206 &NumToWrite, 01207 NULL, 01208 CookedReadData->OriginalCursorPosition.X, 01209 WC_DESTRUCTIVE_BACKSPACE | 01210 WC_KEEP_CURSOR_VISIBLE | WC_ECHO, 01211 NULL); 01212 01213 if (!NT_SUCCESS(*Status)) { 01214 RIPMSG1(RIP_WARNING, "WriteCharsFromInput failed %x", *Status); 01215 } 01216 } 01217 CookedReadData->BytesRead += sizeof(WCHAR); 01218 CookedReadData->BufPtr++; 01219 CookedReadData->CurrentPosition += 1; 01220 } 01221 } 01222 // 01223 // reset the cursor back to 25% if necessary 01224 // 01225 if (CookedReadData->Line) { 01226 if (CookedReadData->InsertMode != CookedReadData->Console->InsertMode) { 01227 ProcessCommandLine(CookedReadData,VK_INSERT,0,NULL,NULL,FALSE); // make cursor small 01228 } 01229 *Status = STATUS_SUCCESS; 01230 return TRUE; 01231 } 01232 } 01233 return FALSE; 01234 }

VOID ReadRectFromScreenBuffer IN PSCREEN_INFORMATION  ScreenInfo,
IN COORD  SourcePoint,
IN PCHAR_INFO  Target,
IN COORD  TargetSize,
IN PSMALL_RECT  TargetRect
 

Definition at line 1415 of file output.c.

01425 : 01426 01427 This routine copies a rectangular region from the screen buffer. 01428 no clipping is done. 01429 01430 Arguments: 01431 01432 ScreenInfo - pointer to screen info 01433 01434 SourcePoint - upper left coordinates of source rectangle 01435 01436 Target - pointer to target buffer 01437 01438 TargetSize - dimensions of target buffer 01439 01440 TargetRect - rectangle in source buffer to copy 01441 01442 Return Value: 01443 01444 none. 01445 01446 --*/ 01447 01448 { 01449 01450 PCHAR_INFO TargetPtr; 01451 SHORT i,j,k; 01452 SHORT XSize,YSize; 01453 BOOLEAN WholeTarget; 01454 SHORT RowIndex; 01455 PROW Row; 01456 PWCHAR Char; 01457 PATTR_PAIR Attr; 01458 SHORT CountOfAttr; 01459 01460 DBGOUTPUT(("ReadRectFromScreenBuffer\n")); 01461 01462 XSize = (SHORT)(TargetRect->Right - TargetRect->Left + 1); 01463 YSize = (SHORT)(TargetRect->Bottom - TargetRect->Top + 1); 01464 01465 TargetPtr = Target; 01466 WholeTarget = FALSE; 01467 if (XSize == TargetSize.X) { 01468 ASSERT (TargetRect->Left == 0); 01469 if (TargetRect->Top != 0) { 01470 TargetPtr = (PCHAR_INFO) 01471 ((PBYTE)Target + SCREEN_BUFFER_POINTER(TargetRect->Left, 01472 TargetRect->Top, 01473 TargetSize.X, 01474 sizeof(CHAR_INFO))); 01475 } 01476 WholeTarget = TRUE; 01477 } 01478 RowIndex = (ScreenInfo->BufferInfo.TextInfo.FirstRow+SourcePoint.Y) % ScreenInfo->ScreenBufferSize.Y; 01479 for (i=0;i<YSize;i++) { 01480 if (!WholeTarget) { 01481 TargetPtr = (PCHAR_INFO) 01482 ((PBYTE)Target + SCREEN_BUFFER_POINTER(TargetRect->Left, 01483 TargetRect->Top+i, 01484 TargetSize.X, 01485 sizeof(CHAR_INFO))); 01486 } 01487 01488 // 01489 // copy the chars and attrs from their respective arrays 01490 // 01491 01492 Row = &ScreenInfo->BufferInfo.TextInfo.Rows[RowIndex]; 01493 Char = &Row->CharRow.Chars[SourcePoint.X]; 01494 FindAttrIndex(Row->AttrRow.Attrs, 01495 SourcePoint.X, 01496 &Attr, 01497 &CountOfAttr 01498 ); 01499 k=0; 01500 #if defined(FE_SB) 01501 if (CONSOLE_IS_DBCS_OUTPUTCP(ScreenInfo->Console)) { 01502 PBYTE AttrP = &Row->CharRow.KAttrs[SourcePoint.X]; 01503 for (j=0;j<XSize;TargetPtr++) { 01504 BYTE AttrR; 01505 AttrR = *AttrP++; 01506 if (j==0 && AttrR & ATTR_TRAILING_BYTE) 01507 { 01508 TargetPtr->Char.UnicodeChar = UNICODE_SPACE; 01509 AttrR = 0; 01510 } 01511 else if (j+1 >= XSize && AttrR & ATTR_LEADING_BYTE) 01512 { 01513 TargetPtr->Char.UnicodeChar = UNICODE_SPACE; 01514 AttrR = 0; 01515 } 01516 else 01517 TargetPtr->Char.UnicodeChar = *Char; 01518 Char++; 01519 TargetPtr->Attributes = Attr->Attr | (WCHAR)(AttrR & ATTR_DBCSSBCS_BYTE) << 8; 01520 j+=1; 01521 if (++k==CountOfAttr && j<XSize) { 01522 Attr++; 01523 k=0; 01524 CountOfAttr = Attr->Length; 01525 } 01526 } 01527 } 01528 else{ 01529 #endif 01530 for (j=0;j<XSize;TargetPtr++) { 01531 TargetPtr->Char.UnicodeChar = *Char++; 01532 TargetPtr->Attributes = Attr->Attr; 01533 j+=1; 01534 if (++k==CountOfAttr && j<XSize) { 01535 Attr++; 01536 k=0; 01537 CountOfAttr = Attr->Length; 01538 } 01539 } 01540 #if defined(FE_SB) 01541 } 01542 #endif 01543 01544 if (++RowIndex == ScreenInfo->ScreenBufferSize.Y) { 01545 RowIndex = 0; 01546 } 01547 } 01548 }

PCOMMAND_HISTORY ReallocCommandHistory IN PCONSOLE_INFORMATION  Console,
IN PCOMMAND_HISTORY  CurrentCommandHistory,
IN DWORD  NumCommands
 

Definition at line 1597 of file server/cmdline.c.

References CLE_RESET, COMMAND_HISTORY, COMMAND_NUM_TO_INDEX, ConsoleHeapAlloc, ConsoleHeapFree, History, HISTORY_TAG, MAKE_TAG, min, NULL, and SHORT.

Referenced by ResizeCommandHistoryBuffers(), and SrvSetConsoleNumberOfCommands().

01602 { 01603 PCOMMAND_HISTORY History; 01604 int i; 01605 01606 if (CurrentCommandHistory == NULL || 01607 CurrentCommandHistory->MaximumNumberOfCommands==(SHORT)NumCommands) { 01608 return CurrentCommandHistory; 01609 } 01610 History = (PCOMMAND_HISTORY)ConsoleHeapAlloc(MAKE_TAG( HISTORY_TAG ),sizeof(COMMAND_HISTORY) + ((NumCommands-1) * sizeof(PCOMMAND))); 01611 if (History == NULL) { 01612 return CurrentCommandHistory; 01613 } 01614 *History=*CurrentCommandHistory; 01615 History->Flags |= CLE_RESET; 01616 History->NumberOfCommands = min(History->NumberOfCommands, (SHORT)NumCommands); 01617 History->LastAdded = History->NumberOfCommands - 1; 01618 History->LastDisplayed = History->NumberOfCommands - 1; 01619 History->FirstCommand = 0; 01620 History->MaximumNumberOfCommands=(SHORT)NumCommands; 01621 for (i=0; i<History->NumberOfCommands; i++) { 01622 History->Commands[i] = CurrentCommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CurrentCommandHistory)]; 01623 } 01624 for (; i<CurrentCommandHistory->NumberOfCommands; i++) { 01625 ConsoleHeapFree(CurrentCommandHistory->Commands[COMMAND_NUM_TO_INDEX(i,CurrentCommandHistory)]); 01626 } 01627 01628 RemoveEntryList(&CurrentCommandHistory->ListLink); 01629 InitializeListHead(&History->PopupList); 01630 InsertHeadList(&Console->CommandHistoryList,&History->ListLink); 01631 01632 ConsoleHeapFree(CurrentCommandHistory); 01633 return History; 01634 }

VOID RedrawCommandLine IN PCOOKED_READ_DATA  CookedReadData  ) 
 

Referenced by PropertiesUpdate().

ULONG RetrieveNumberOfSpaces IN SHORT  OriginalCursorPositionX,
IN PWCHAR  Buffer,
IN ULONG  CurrentPosition
 

Definition at line 818 of file server/stream.c.

References Buffer, IS_CONTROL_CHAR, NUMBER_OF_SPACES_IN_TAB, SHORT, and UNICODE_TAB.

Referenced by ProcessCommandLine(), ProcessCookedReadInput(), and WWSB_WriteChars().

00836 { 00837 WCHAR Char; 00838 ULONG i,NumSpaces; 00839 SHORT XPosition; 00840 00841 Char = Buffer[CurrentPosition]; 00842 if (Char == UNICODE_TAB) { 00843 NumSpaces=0; 00844 XPosition=OriginalCursorPositionX; 00845 for (i=0;i<=CurrentPosition;i++) { 00846 Char = Buffer[i]; 00847 if (Char == UNICODE_TAB) { 00848 NumSpaces = NUMBER_OF_SPACES_IN_TAB(XPosition); 00849 } else if (IS_CONTROL_CHAR(Char)) { 00850 NumSpaces = 2; 00851 #if defined(FE_SB) 00852 } else if (IsConsoleFullWidth(Console->hDC,CodePage,Char)) { 00853 NumSpaces = 2; 00854 #endif 00855 } else { 00856 NumSpaces = 1; 00857 } 00858 XPosition = (SHORT)(XPosition+NumSpaces); 00859 } 00860 return NumSpaces; 00861 } 00862 else if (IS_CONTROL_CHAR(Char)) { 00863 return 2; 00864 } 00865 #if defined(FE_SB) 00866 else if (IsConsoleFullWidth(Console->hDC,CodePage,Char)) { 00867 return 2; 00868 } 00869 #endif 00870 else { 00871 return 1; 00872 } 00873 }

ULONG RetrieveTotalNumberOfSpaces IN SHORT  OriginalCursorPositionX,
IN PWCHAR  Buffer,
IN ULONG  CurrentPosition
 

Definition at line 774 of file server/stream.c.

References Buffer, IS_CONTROL_CHAR, NUMBER_OF_SPACES_IN_TAB, SHORT, and UNICODE_TAB.

Referenced by ProcessCommandLine(), and RedrawCommandLine().

00791 { 00792 WCHAR Char; 00793 ULONG i,NumSpacesForChar,NumSpaces; 00794 SHORT XPosition; 00795 00796 XPosition=OriginalCursorPositionX; 00797 NumSpaces=0; 00798 for (i=0;i<CurrentPosition;i++) { 00799 Char = Buffer[i]; 00800 if (Char == UNICODE_TAB) { 00801 NumSpacesForChar = NUMBER_OF_SPACES_IN_TAB(XPosition); 00802 } else if (IS_CONTROL_CHAR(Char)) { 00803 NumSpacesForChar = 2; 00804 #if defined(FE_SB) 00805 } else if (IsConsoleFullWidth(Console->hDC,Console->CP,Char)) { 00806 NumSpacesForChar = 2; 00807 #endif 00808 } else { 00809 NumSpacesForChar = 1; 00810 } 00811 XPosition = (SHORT)(XPosition+NumSpacesForChar); 00812 NumSpaces += NumSpacesForChar; 00813 } 00814 return NumSpaces; 00815 }

VOID UpdateCommandListPopup IN SHORT  Delta,
IN OUT PSHORT  CurrentCommand,
IN PCOMMAND_HISTORY  CommandHistory,
IN PCLE_POPUP  Popup,
IN PSCREEN_INFORMATION  ScreenInfo,
IN DWORD  Flags
 

Definition at line 4500 of file server/cmdline.c.

References BOOL, COMMAND_INDEX_TO_NUM, COMMAND_NUM_TO_INDEX, DrawCommandListPopup(), FALSE, POPUP_SIZE_Y, SHORT, Size, TRUE, UCLP_WRAP, and UpdateHighlight().

Referenced by ProcessCommandListInput().

04508 { 04509 SHORT Size; 04510 SHORT CurCmdNum; 04511 SHORT NewCmdNum; 04512 BOOL Scroll=FALSE; 04513 04514 if (Delta == 0) { 04515 return; 04516 } 04517 Size = POPUP_SIZE_Y(Popup); 04518 04519 if (Flags & UCLP_WRAP) { 04520 CurCmdNum = *CurrentCommand; 04521 NewCmdNum = CurCmdNum + Delta; 04522 NewCmdNum = COMMAND_INDEX_TO_NUM(NewCmdNum, CommandHistory); 04523 CurCmdNum = COMMAND_INDEX_TO_NUM(CurCmdNum, CommandHistory); 04524 } else { 04525 CurCmdNum = COMMAND_INDEX_TO_NUM(*CurrentCommand, CommandHistory); 04526 NewCmdNum = CurCmdNum + Delta; 04527 if (NewCmdNum >= CommandHistory->NumberOfCommands) { 04528 NewCmdNum = (SHORT)(CommandHistory->NumberOfCommands-1); 04529 } else if (NewCmdNum < 0) { 04530 NewCmdNum = 0; 04531 } 04532 } 04533 Delta = NewCmdNum - CurCmdNum; 04534 04535 // determine amount to scroll, if any 04536 04537 if (NewCmdNum <= Popup->BottomIndex-Size) { 04538 Popup->BottomIndex += Delta; 04539 if (Popup->BottomIndex < (SHORT)(Size-1)) { 04540 Popup->BottomIndex = (SHORT)(Size-1); 04541 } 04542 Scroll = TRUE; 04543 } else if (NewCmdNum > Popup->BottomIndex) { 04544 Popup->BottomIndex += Delta; 04545 if (Popup->BottomIndex >= CommandHistory->NumberOfCommands) { 04546 Popup->BottomIndex = (SHORT)(CommandHistory->NumberOfCommands-1); 04547 } 04548 Scroll = TRUE; 04549 } 04550 04551 04552 // 04553 // write commands to popup 04554 // 04555 if (Scroll) { 04556 DrawCommandListPopup(Popup,COMMAND_NUM_TO_INDEX(NewCmdNum,CommandHistory),CommandHistory,ScreenInfo); 04557 } else { 04558 UpdateHighlight(Popup,COMMAND_INDEX_TO_NUM((*CurrentCommand),CommandHistory),NewCmdNum,ScreenInfo); 04559 } 04560 *CurrentCommand = COMMAND_NUM_TO_INDEX(NewCmdNum,CommandHistory); 04561 }

NTSTATUS WriteCharsFromInput IN PSCREEN_INFORMATION  ScreenInfo,
IN PWCHAR  lpBufferBackupLimit,
IN PWCHAR  lpBuffer,
IN PWCHAR  lpString,
IN OUT PDWORD  NumBytes,
OUT PLONG NumSpaces  OPTIONAL,
IN SHORT  OriginalXPosition,
IN DWORD  dwFlags,
OUT PSHORT ScrollY  OPTIONAL
 

Definition at line 3047 of file server/stream.c.

References CONSOLE_GRAPHICS_BUFFER, CONSOLE_OEMFONT_DISPLAY, dwFlags, DWORD, WC_FALSIFY_UNICODE, and WriteChars.

Referenced by ProcessCommandLine(), ProcessCommandNumberInput(), ProcessCookedReadInput(), ProcessCopyFromCharInput(), ProcessCopyToCharInput(), RedrawCommandLine(), and SetCurrentCommandLine().

03061 : 03062 03063 This routine converts chars from their true unicode representation 03064 to the Unicode representation (UnicodeAnsi) that will generate 03065 the correct glyph given an OEM font and an ANSI translation by GDI. 03066 It then calls WriteChars. 03067 03068 Arguments: 03069 03070 ScreenInfo - Pointer to screen buffer information structure. 03071 03072 lpBufferBackupLimit - Pointer to beginning of buffer. 03073 03074 lpBuffer - Pointer to buffer to copy string to. assumed to be at least 03075 as long as lpString. This pointer is updated to point to the next 03076 position in the buffer. 03077 03078 lpString - Pointer to string to write. 03079 03080 NumBytes - On input, number of bytes to write. On output, number of 03081 bytes written. 03082 03083 NumSpaces - On output, the number of spaces consumed by the written characters. 03084 03085 dwFlags - 03086 WC_DESTRUCTIVE_BACKSPACE backspace overwrites characters. 03087 WC_KEEP_CURSOR_VISIBLE change window origin desirable when hit rt. edge 03088 WC_ECHO if called by Read (echoing characters) 03089 WC_FALSIFY_UNICODE if RealUnicodeToFalseUnicode need be called. 03090 03091 Return Value: 03092 03093 Note: 03094 03095 This routine does not process tabs and backspace properly. That code 03096 will be implemented as part of the line editing services. 03097 03098 --*/ 03099 03100 { 03101 DWORD Length,i; 03102 03103 if (ScreenInfo->Flags & CONSOLE_GRAPHICS_BUFFER) { 03104 return STATUS_UNSUCCESSFUL; 03105 } 03106 03107 if (!(ScreenInfo->Flags & CONSOLE_OEMFONT_DISPLAY) || 03108 (ScreenInfo->Console->FullScreenFlags & CONSOLE_FULLSCREEN)) { 03109 goto SimpleWrite; 03110 } 03111 03112 Length = *NumBytes / sizeof(WCHAR); 03113 for (i=0;i<Length;i++) { 03114 if (lpString[i] > 0x7f) { 03115 dwFlags |= WC_FALSIFY_UNICODE; 03116 break; 03117 } 03118 } 03119 03120 SimpleWrite: 03121 return WriteChars(ScreenInfo, 03122 lpBufferBackupLimit, 03123 lpBuffer, 03124 lpString, 03125 NumBytes, 03126 NumSpaces, 03127 OriginalXPosition, 03128 dwFlags, 03129 ScrollY 03130 ); 03131 }


Variable Documentation

WCHAR gaWordDelimChars[]
 

Definition at line 401 of file cmdline.h.

Referenced by GetRegistryValues(), and IsWordDelim().

CONST WCHAR gaWordDelimCharsDefault[]
 

Definition at line 402 of file cmdline.h.

Referenced by GetRegistryValues().


Generated on Sat May 15 19:43:08 2004 for test by doxygen 1.3.7