📄 tconsole.h
字号:
/*****************************************************************************/
/* TConsole.h Copyright (c) Ladislav Zezula 2003 */
/*---------------------------------------------------------------------------*/
/* Class for a console window */
/*---------------------------------------------------------------------------*/
/* Date Ver Who Comment */
/* -------- ---- --- ------- */
/* 02.06.03 1.00 Lad The first version of TConsole.h */
/*****************************************************************************/
#ifndef __TCONSOLE_H__
#define __TCONSOLE_H__
#define WM_CLOSECONSOLE (WM_USER + 0x1100)
#define WM_CONSOLEDESTROYED (WM_USER + 0x1101)
#define WM_RUNCOMMAND (WM_USER + 0x1102)
class TConsole;
typedef int (TConsole::*SCRIPTCMDFUNC)(char ** Args);
//-----------------------------------------------------------------------------
// Structures and classes
struct TCommandInfo
{
const char * szCommand; // Full command
const char * szCmd; // Abbreviated command
SCRIPTCMDFUNC DoCommand; // Performing function
int nMinArgs; // Minimum number of args
int nMaxArgs; // Maximum number of args
UINT nIDHelp; // ID of the help
};
class TConsole
{
public:
TConsole();
~TConsole();
int CreateConsoleWindow(HWND hParent, RECT & rect);
int RunConsoleMode();
int RunCurrentCommand();
int SetWorkDir(const char * szWorkDir);
void ShowPrompt();
HWND GetWindow() { return m_hConsole; }
int printf(const char * fmt, ...);
int printf(UINT nIDFmt, ...);
char m_szCommand[MAX_PATH];
BOOL m_bShowPrompt;
protected:
// Helper functions
int ReadLine(FILE * fp, TCHAR * szBuffer, int nMaxChars);
int ProcessMessages();
int ExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted, LCID lcLocale);
int AddFiles(HANDLE hMpq, char * szToAdd, int nRelOffs);
int AddFolder(HANDLE hMpq, char * szFileMask, int nRelOffs);
int CloseLastAccessedMpq();
int ChangeArchive(const char * szMpq);
int OpenOrCreate(char ** Args, DWORD dwDisposition);
BOOL SaveCommand();
int _printf(const char * fmt, va_list argList);
// Console command handlers
int Open(char ** Args);
int New(char ** Args);
int Add(char ** Args);
int Extract(char ** Args);
int Rename(char ** Args);
int Move(char ** Args);
int Delete(char ** Args);
int Flush(char ** Args);
int Close(char ** Args);
int Script(char ** Args);
int Chdir(char ** Args);
int Dir(char ** Args);
int Exit(char ** Args);
int Help(char ** Args);
int RunCommand();
// Message handlers
LRESULT OnCtlColorEdit(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT OnKeyDownUp(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT OnChar(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ConsoleWindowProc(HWND hConsole, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK SubclassedWindowProc(HWND hConsole, UINT uMsg, WPARAM wParam, LPARAM lParam);
enum TState
{
stIdle, // Doing nothing
stGetch, // Waiting for keypress
stConsole, // Waiting for commands and processing them
stRunning, // Running a command
};
static TCommandInfo m_Commands[]; // Script commands
char m_szScriptName[MAX_PATH]; // Recently open MPQ archive name
char m_szSaveDir[MAX_PATH];
char m_szLastMpq[MAX_PATH]; // Recently open MPQ archive name
WNDPROC m_pfnOldWndProc;
HBRUSH m_hBrush;
HANDLE m_hLastMpq; // Recently open MPQ archive handle
HFONT m_hFont;
HWND m_hConsole;
int m_nCmdLength;
int m_nMaxLength; // Max length of edit box text
BOOL m_bEnablePaint; // If TRUE, redrawing is enabled
int m_nStart; // Command start position
TState m_nState; // Current edit state
int m_nLevel; // Run nest level
};
#endif // __TCONSOLE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -