00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 typedef struct _COMMAND {
00023 USHORT CommandLength;
00024 WCHAR
Command[1];
00025 }
COMMAND, *
PCOMMAND;
00026
00027
typedef
00028 ULONG
00029 (*PCLE_POPUP_INPUT_ROUTINE)(
00030 IN PVOID CookedReadData,
00031 IN PCSR_API_MSG WaitReplyMessage,
00032 IN PCSR_THREAD WaitingThread,
00033 IN BOOLEAN WaitRoutine
00034 );
00035
00036
00037
00038
00039 #define CLEPF_FALSE_UNICODE 0x0001
00040
00041 typedef struct _CLE_POPUP {
00042 LIST_ENTRY
ListLink;
00043 SMALL_RECT
Region;
00044 WORD
Attributes;
00045 WORD
Flags;
00046 PCHAR_INFO
OldContents;
00047 SHORT BottomIndex;
00048 SHORT CurrentCommand;
00049 WCHAR
NumberBuffer[6];
00050 SHORT NumberRead;
00051 PCLE_POPUP_INPUT_ROUTINE PopupInputRoutine;
00052
#if defined(FE_SB)
00053
COORD OldScreenSize;
00054
#endif
00055
}
CLE_POPUP, *
PCLE_POPUP;
00056
00057 #define POPUP_SIZE_X(POPUP) (SHORT)(((POPUP)->Region.Right - (POPUP)->Region.Left - 1))
00058 #define POPUP_SIZE_Y(POPUP) (SHORT)(((POPUP)->Region.Bottom - (POPUP)->Region.Top - 1))
00059 #define COMMAND_NUMBER_SIZE 8 // size of command number buffer
00060
00061
00062
00063
00064
00065 #define CLE_ALLOCATED 0x00000001
00066 #define CLE_RESET 0x00000002
00067
00068 typedef struct _COMMAND_HISTORY {
00069 DWORD Flags;
00070 LIST_ENTRY
ListLink;
00071 PWCHAR
AppName;
00072 SHORT NumberOfCommands;
00073 SHORT LastAdded;
00074 SHORT LastDisplayed;
00075 SHORT FirstCommand;
00076 SHORT MaximumNumberOfCommands;
00077 HANDLE
ProcessHandle;
00078 LIST_ENTRY
PopupList;
00079 PCOMMAND Commands[1];
00080 }
COMMAND_HISTORY, *
PCOMMAND_HISTORY;
00081
00082 #define DEFAULT_NUMBER_OF_COMMANDS 25
00083 #define DEFAULT_NUMBER_OF_BUFFERS 4
00084
00085 typedef struct _COOKED_READ_DATA {
00086 PINPUT_INFORMATION InputInfo;
00087 PSCREEN_INFORMATION ScreenInfo;
00088 PCONSOLE_INFORMATION Console;
00089 HANDLE_DATA TempHandle;
00090 ULONG
UserBufferSize;
00091 PWCHAR
UserBuffer;
00092 ULONG
BufferSize;
00093 ULONG
BytesRead;
00094 ULONG
CurrentPosition;
00095 PWCHAR
BufPtr;
00096 PWCHAR
BackupLimit;
00097 COORD
OriginalCursorPosition;
00098 DWORD NumberOfVisibleChars;
00099 PCOMMAND_HISTORY CommandHistory;
00100 BOOLEAN
Echo;
00101 BOOLEAN
Processed;
00102 BOOLEAN
Line;
00103 BOOLEAN
InsertMode;
00104 PCONSOLE_PER_PROCESS_DATA ProcessData;
00105 HANDLE
HandleIndex;
00106 PWCHAR
ExeName;
00107 USHORT ExeNameLength;
00108 ULONG
CtrlWakeupMask;
00109 ULONG
ControlKeyState;
00110 }
COOKED_READ_DATA, *
PCOOKED_READ_DATA;
00111
00112 #define COMMAND_NUM_TO_INDEX(NUM,CMDHIST) (SHORT)(((NUM+(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
00113 #define COMMAND_INDEX_TO_NUM(INDEX,CMDHIST) (SHORT)(((INDEX+((CMDHIST)->MaximumNumberOfCommands)-(CMDHIST)->FirstCommand)%((CMDHIST)->MaximumNumberOfCommands)))
00114
00115
00116
00117
00118
00119
00120
00121
00122 #define COMMAND_IND_PREV(IND,CMDHIST) \
00123
{ \
00124
if (IND <= 0) { \
00125
IND = (CMDHIST)->NumberOfCommands; \
00126
} \
00127
IND--; \
00128
}
00129
00130 #define COMMAND_IND_NEXT(IND,CMDHIST) \
00131
{ \
00132
++IND; \
00133
if (IND >= (CMDHIST)->NumberOfCommands){ \
00134
IND = 0; \
00135
} \
00136
}
00137
00138 #define COMMAND_IND_DEC(IND,CMDHIST) \
00139
{ \
00140
if (IND <= 0) { \
00141
IND = (CMDHIST)->MaximumNumberOfCommands; \
00142
} \
00143
IND--; \
00144
}
00145
00146 #define COMMAND_IND_INC(IND,CMDHIST) \
00147
{ \
00148
++IND; \
00149
if (IND >= (CMDHIST)->MaximumNumberOfCommands){ \
00150
IND = 0; \
00151
} \
00152
}
00153
00154 #define CLE_NO_POPUPS(COMMAND_HISTORY) (&(COMMAND_HISTORY)->PopupList == (COMMAND_HISTORY)->PopupList.Blink)
00155
00156
00157
00158
00159
00160 typedef struct _ALIAS {
00161 LIST_ENTRY
ListLink;
00162 USHORT SourceLength;
00163 USHORT TargetLength;
00164 PWCHAR
Source;
00165 PWCHAR
Target;
00166 }
ALIAS, *
PALIAS;
00167
00168 typedef struct _EXE_ALIAS_LIST {
00169 LIST_ENTRY
ListLink;
00170 USHORT ExeLength;
00171 PWCHAR
ExeName;
00172 LIST_ENTRY
AliasList;
00173 }
EXE_ALIAS_LIST, *
PEXE_ALIAS_LIST;
00174
00175
NTSTATUS
00176
ProcessCommandLine(
00177 IN PCOOKED_READ_DATA CookedReadData,
00178 IN WCHAR Char,
00179 IN DWORD KeyState,
00180 IN PCSR_API_MSG WaitReplyMessage,
00181 IN PCSR_THREAD WaitingThread,
00182 IN BOOLEAN WaitRoutine
00183 );
00184
00185
VOID
00186
DeleteCommandLine(
00187 IN OUT PCOOKED_READ_DATA CookedReadData,
00188 IN BOOL UpdateFields
00189 );
00190
00191
VOID
00192
RedrawCommandLine(
00193 IN PCOOKED_READ_DATA CookedReadData
00194 );
00195
00196
VOID
00197
EmptyCommandHistory(
00198 IN PCOMMAND_HISTORY CommandHistory
00199 );
00200
00201
PCOMMAND_HISTORY
00202
ReallocCommandHistory(
00203 IN
PCONSOLE_INFORMATION Console,
00204 IN PCOMMAND_HISTORY CurrentCommandHistory,
00205 IN DWORD NumCommands
00206 );
00207
00208
PCOMMAND_HISTORY
00209
FindExeCommandHistory(
00210 IN
PCONSOLE_INFORMATION Console,
00211 IN PVOID AppName,
00212 IN DWORD AppNameLength,
00213 IN BOOLEAN UnicodeExe
00214 );
00215
00216
PCOMMAND_HISTORY
00217
FindCommandHistory(
00218 IN
PCONSOLE_INFORMATION Console,
00219 IN HANDLE ProcessHandle
00220 );
00221
00222 ULONG
00223
RetrieveNumberOfSpaces(
00224 IN SHORT OriginalCursorPositionX,
00225 IN PWCHAR Buffer,
00226 IN ULONG CurrentPosition
00227 #
if defined(FE_SB)
00228 ,
00229 IN
PCONSOLE_INFORMATION Console,
00230 IN DWORD CodePage
00231 #endif
00232 );
00233
00234 ULONG
00235
RetrieveTotalNumberOfSpaces(
00236 IN SHORT OriginalCursorPositionX,
00237 IN PWCHAR Buffer,
00238 IN ULONG CurrentPosition
00239 #
if defined(FE_SB)
00240 ,
00241 IN
PCONSOLE_INFORMATION Console
00242 #endif
00243 );
00244
00245
NTSTATUS
00246
GetChar(
00247 IN
PINPUT_INFORMATION InputInfo,
00248 OUT PWCHAR Char,
00249 IN BOOLEAN Wait,
00250 IN
PCONSOLE_INFORMATION Console,
00251 IN
PHANDLE_DATA HandleData,
00252 IN PCSR_API_MSG Message OPTIONAL,
00253 IN CSR_WAIT_ROUTINE WaitRoutine OPTIONAL,
00254 IN PVOID WaitParameter OPTIONAL,
00255 IN ULONG WaitParameterLength OPTIONAL,
00256 IN BOOLEAN WaitBlockExists OPTIONAL,
00257 OUT PBOOLEAN CommandLineEditingKeys OPTIONAL,
00258 OUT PBOOLEAN CommandLinePopupKeys OPTIONAL,
00259 OUT PBOOLEAN EnableScrollMode OPTIONAL,
00260 OUT PDWORD KeyState OPTIONAL
00261 );
00262
00263
BOOL
00264
IsCommandLinePopupKey(
00265 IN OUT PKEY_EVENT_RECORD KeyEvent
00266 );
00267
00268
BOOL
00269
IsCommandLineEditingKey(
00270 IN OUT PKEY_EVENT_RECORD KeyEvent
00271 );
00272
00273
VOID
00274
CleanUpPopups(
00275 IN PCOOKED_READ_DATA CookedReadData
00276 );
00277
00278
BOOL
00279
ProcessCookedReadInput(
00280 IN PCOOKED_READ_DATA CookedReadData,
00281 IN WCHAR Char,
00282 IN DWORD KeyState,
00283 OUT PNTSTATUS Status
00284 );
00285
00286
VOID
00287
DrawCommandListBorder(
00288 IN PCLE_POPUP Popup,
00289 IN
PSCREEN_INFORMATION ScreenInfo
00290 );
00291
00292
PCOMMAND
00293
GetLastCommand(
00294 IN PCOMMAND_HISTORY CommandHistory
00295 );
00296
00297
SHORT
00298
FindMatchingCommand(
00299 IN PCOMMAND_HISTORY CommandHistory,
00300 IN PWCHAR CurrentCommand,
00301 IN ULONG CurrentCommandLength,
00302 IN SHORT CurrentIndex,
00303 IN DWORD Flags
00304 );
00305
00306 #define FMCFL_EXACT_MATCH 1
00307 #define FMCFL_JUST_LOOKING 2
00308
00309
NTSTATUS
00310
CommandNumberPopup(
00311 IN PCOOKED_READ_DATA CookedReadData,
00312 IN PCSR_API_MSG WaitReplyMessage,
00313 IN PCSR_THREAD WaitingThread,
00314 IN BOOLEAN WaitRoutine
00315 );
00316
00317 BOOLEAN
00318
CookedReadWaitRoutine(
00319 IN PLIST_ENTRY WaitQueue,
00320 IN PCSR_THREAD WaitingThread,
00321 IN PCSR_API_MSG WaitReplyMessage,
00322 IN PVOID WaitParameter,
00323 IN PVOID SatisfyParameter1,
00324 IN PVOID SatisfyParameter2,
00325 IN ULONG WaitFlags
00326 );
00327
00328
VOID
00329
ReadRectFromScreenBuffer(
00330 IN
PSCREEN_INFORMATION ScreenInfo,
00331 IN COORD SourcePoint,
00332 IN PCHAR_INFO Target,
00333 IN COORD TargetSize,
00334 IN PSMALL_RECT TargetRect
00335 );
00336
00337
NTSTATUS
00338
WriteCharsFromInput(
00339 IN
PSCREEN_INFORMATION ScreenInfo,
00340 IN PWCHAR lpBufferBackupLimit,
00341 IN PWCHAR lpBuffer,
00342 IN PWCHAR lpString,
00343 IN OUT PDWORD NumBytes,
00344 OUT PLONG NumSpaces OPTIONAL,
00345 IN SHORT OriginalXPosition,
00346 IN DWORD dwFlags,
00347 OUT PSHORT ScrollY OPTIONAL
00348 );
00349
00350
00351
00352
00353 #define WC_DESTRUCTIVE_BACKSPACE 0x01
00354 #define WC_KEEP_CURSOR_VISIBLE 0x02
00355 #define WC_ECHO 0x04
00356 #define WC_FALSIFY_UNICODE 0x08
00357 #define WC_LIMIT_BACKSPACE 0x10
00358
00359
00360
VOID
00361
DrawCommandListPopup(
00362 IN PCLE_POPUP Popup,
00363 IN SHORT CurrentCommand,
00364 IN PCOMMAND_HISTORY CommandHistory,
00365 IN
PSCREEN_INFORMATION ScreenInfo
00366 );
00367
00368
VOID
00369
UpdateCommandListPopup(
00370 IN SHORT Delta,
00371 IN OUT PSHORT CurrentCommand,
00372 IN PCOMMAND_HISTORY CommandHistory,
00373 IN PCLE_POPUP Popup,
00374 IN
PSCREEN_INFORMATION ScreenInfo,
00375 IN DWORD Flags
00376 );
00377
00378 #define UCLP_WRAP 1
00379
00380
00381
00382
00383
00384
00385
VOID InitExtendedEditKeys(CONST ExtKeyDefBuf* lpbuf);
00386
00387
00388
00389
00390
00391
00392
BOOL IsPauseKey(IN PKEY_EVENT_RECORD pKeyEvent);
00393
00394
00395
00396
00397
00398
00399 #define IS_WORD_DELIM(wch) ((wch) == L' ' || (gaWordDelimChars[0] && IsWordDelim(wch)))
00400
00401 extern WCHAR
gaWordDelimChars[];
00402 extern CONST WCHAR
gaWordDelimCharsDefault[];
00403
extern BOOL IsWordDelim(WCHAR);
00404
00405 #define WORD_DELIM_MAX 32
00406