2006-02-26 06:26:56 +00:00
|
|
|
#ifndef DEBUGGER_CONSOLE_H
|
|
|
|
#define DEBUGGER_CONSOLE_H
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CONSOLE_HEIGHT = 384, // Lines, was 128, but need ~ 256+16 for PROFILE LIST
|
|
|
|
CONSOLE_WIDTH = 80,
|
|
|
|
|
2006-07-07 19:30:39 +00:00
|
|
|
// need min 256+ lines for "profile list"
|
|
|
|
CONSOLE_BUFFER_HEIGHT = 384,
|
2006-07-05 21:23:13 +00:00
|
|
|
|
|
|
|
HISTORY_HEIGHT = 128,
|
|
|
|
HISTORY_WIDTH = 128,
|
|
|
|
|
2006-02-26 06:26:56 +00:00
|
|
|
CONSOLE_FIRST_LINE = 1, // where ConsoleDisplay is pushed up from
|
|
|
|
};
|
|
|
|
|
2006-07-07 19:30:39 +00:00
|
|
|
// Color ____________________________________________________________________
|
|
|
|
|
|
|
|
//typedef short conchar_t;
|
|
|
|
typedef unsigned char conchar_t;
|
|
|
|
|
|
|
|
enum ConsoleColors_e
|
|
|
|
{
|
|
|
|
CONSOLE_COLOR_K,
|
|
|
|
CONSOLE_COLOR_x = 0, // default console foreground
|
|
|
|
CONSOLE_COLOR_R,
|
|
|
|
CONSOLE_COLOR_G,
|
|
|
|
CONSOLE_COLOR_Y,
|
|
|
|
CONSOLE_COLOR_B,
|
|
|
|
CONSOLE_COLOR_M,
|
|
|
|
CONSOLE_COLOR_C,
|
|
|
|
CONSOLE_COLOR_W,
|
|
|
|
|
|
|
|
MAX_CONSOLE_COLORS
|
|
|
|
};
|
|
|
|
|
|
|
|
extern COLORREF g_anConsoleColor[ MAX_CONSOLE_COLORS ];
|
|
|
|
|
|
|
|
// Note: THe ` ~ key should always display ~ to prevent rendering errors
|
|
|
|
#define CONSOLE_COLOR_ESCAPE_CHAR '`'
|
|
|
|
#define _CONSOLE_COLOR_MASK 0x7F
|
|
|
|
|
|
|
|
// Help Colors
|
|
|
|
/*
|
|
|
|
Types
|
|
|
|
Plain White
|
|
|
|
Header Yellow i.e. Usage
|
|
|
|
Operator Yellow
|
|
|
|
Command Green
|
|
|
|
Key Red
|
|
|
|
ArgMandatory Magenta < >
|
|
|
|
ArgOptional Blue [ ]
|
|
|
|
ArgSeperator White |
|
|
|
|
|
|
|
|
#define CON_COLOR_DEFAULT g_asConsoleColor[ CONSOLE_COLOR_x ]
|
|
|
|
#define CON_COLOR_DEFAULT "`0"
|
|
|
|
|
|
|
|
*/
|
|
|
|
#if 1 // USE_APPLE_FONT
|
|
|
|
#define CON_COLOR_DEFAULT "`0"
|
|
|
|
#define CON_COLOR_USAGE "`3"
|
|
|
|
#define CON_COLOR_PARAM "`2"
|
|
|
|
#define CON_COLOR_KEY "`1"
|
|
|
|
#define CON_COLOR_ARG_MAND "`5"
|
|
|
|
#define CON_COLOR_ARG_OPT "`4"
|
|
|
|
#define CON_COLOR_ARG_SEP "`3"
|
|
|
|
#define CON_COLOR_NUM "`2"
|
|
|
|
#else
|
|
|
|
#define CON_COLOR_DEFAULT ""
|
|
|
|
#define CON_COLOR_USAGE ""
|
|
|
|
#define CON_COLOR_PARAM ""
|
|
|
|
#define CON_COLOR_KEY ""
|
|
|
|
#define CON_COLOR_ARG_MAND ""
|
|
|
|
#define CON_COLOR_ARG_OPT ""
|
|
|
|
#define CON_COLOR_ARG_SEP ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ascii markup
|
|
|
|
inline bool ConsoleColor_IsCharMeta( unsigned char c )
|
|
|
|
{
|
|
|
|
if (CONSOLE_COLOR_ESCAPE_CHAR == c)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ConsoleColor_IsCharColor( unsigned char c )
|
|
|
|
{
|
|
|
|
if ((c >= '0') && (c <= '7'))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// native char
|
|
|
|
// There are a few different ways of encoding color chars & mouse text
|
|
|
|
// 0x80 Console Color
|
|
|
|
// 0xC0 Mouse Text
|
|
|
|
// High Low
|
|
|
|
// 1) xx n/a Extended ASCII (Multi-Byte to Single-Byte)
|
|
|
|
// 0..7 = Color
|
|
|
|
// @..Z = Mouse Text
|
|
|
|
// Con: Colors chars take up extra chars
|
|
|
|
// 2) ccxx Color ASCII Con: need to provide char8 and char16 API
|
|
|
|
// 3) xxcc ASCII Color Con: ""
|
|
|
|
// 4) fxx Flag ASCII Con: Colors chars take up extra chars
|
|
|
|
inline bool ConsoleColor_IsMeta( conchar_t g )
|
|
|
|
{
|
|
|
|
if (g > _CONSOLE_COLOR_MASK)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// inline bool ConsoleColor_IsCharColor( unsigned char c )
|
|
|
|
inline bool ConsoleColor_IsColor( conchar_t g )
|
|
|
|
{
|
|
|
|
if (((g - '0') & _CONSOLE_COLOR_MASK) < MAX_CONSOLE_COLORS)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-26 06:26:56 +00:00
|
|
|
|
2006-07-07 19:30:39 +00:00
|
|
|
inline COLORREF ConsoleColor_GetColor( conchar_t g )
|
|
|
|
{
|
|
|
|
const int iColor = g & (MAX_CONSOLE_COLORS - 1);
|
|
|
|
return g_anConsoleColor[ iColor ];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline char ConsoleColor_GetChar( conchar_t g )
|
|
|
|
{
|
|
|
|
return (g & _CONSOLE_COLOR_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline conchar_t ConsoleColor_Make( unsigned char c )
|
|
|
|
{
|
|
|
|
conchar_t g = c | (_CONSOLE_COLOR_MASK + 1);
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Globals __________________________________________________________________
|
2006-07-05 21:23:13 +00:00
|
|
|
|
2006-02-26 06:26:56 +00:00
|
|
|
// Buffer
|
2006-07-07 19:30:39 +00:00
|
|
|
extern bool g_bConsoleBufferPaused;
|
|
|
|
extern int g_nConsoleBuffer;
|
|
|
|
extern conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
|
2006-07-05 21:23:13 +00:00
|
|
|
|
|
|
|
// Cursor
|
2006-07-07 19:30:39 +00:00
|
|
|
extern char g_sConsoleCursor[];
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Display
|
2006-07-07 19:30:39 +00:00
|
|
|
extern char g_aConsolePrompt[];// = TEXT(">!"); // input, assembler // NUM_PROMPTS
|
|
|
|
extern char g_sConsolePrompt[];// = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
|
2006-07-05 21:23:13 +00:00
|
|
|
extern int g_nConsolePromptLen;
|
|
|
|
|
2006-02-26 06:26:56 +00:00
|
|
|
extern bool g_bConsoleFullWidth;// = false;
|
|
|
|
|
2006-07-07 19:30:39 +00:00
|
|
|
extern int g_iConsoleDisplayStart ; // to allow scrolling
|
|
|
|
extern int g_nConsoleDisplayTotal ; // number of lines added to console
|
|
|
|
extern int g_nConsoleDisplayLines ;
|
|
|
|
extern int g_nConsoleDisplayWidth ;
|
|
|
|
extern conchar_t g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Input History
|
|
|
|
extern int g_nHistoryLinesStart;// = 0;
|
|
|
|
extern int g_nHistoryLinesTotal;// = 0; // number of commands entered
|
2006-07-07 19:30:39 +00:00
|
|
|
extern char g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ];// = {TEXT("")};
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Input Line
|
|
|
|
// Raw input Line (has prompt)
|
2006-07-07 19:30:39 +00:00
|
|
|
extern conchar_t * const g_aConsoleInput; // = g_aConsoleDisplay[0];
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Cooked input line (no prompt)
|
2006-07-07 19:30:39 +00:00
|
|
|
extern int g_nConsoleInputChars ;
|
|
|
|
extern char * g_pConsoleInput ;//= 0; // points to past prompt
|
|
|
|
extern const char * g_pConsoleFirstArg ;//= 0; // points to first arg
|
|
|
|
extern bool g_bConsoleInputQuoted ;
|
|
|
|
extern char g_nConsoleInputSkip ;
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Prototypes _______________________________________________________________
|
|
|
|
|
|
|
|
// Console
|
|
|
|
|
|
|
|
// Buffered
|
2006-07-07 19:30:39 +00:00
|
|
|
bool ConsolePrint( const char * pText );
|
|
|
|
void ConsoleBufferToDisplay ();
|
|
|
|
const conchar_t* ConsoleBufferPeek ();
|
|
|
|
void ConsoleBufferPop ();
|
|
|
|
bool ConsoleBufferPush ( const char * pString );
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Display
|
2006-07-07 19:30:39 +00:00
|
|
|
Update_t ConsoleDisplayError ( const char * pTextError );
|
2006-02-26 06:26:56 +00:00
|
|
|
void ConsoleDisplayPause ();
|
2006-07-07 19:30:39 +00:00
|
|
|
void ConsoleDisplayPush ( const char * pText );
|
2006-02-26 06:26:56 +00:00
|
|
|
Update_t ConsoleUpdate ();
|
|
|
|
|
|
|
|
// Input
|
|
|
|
void ConsoleInputToDisplay ();
|
2006-07-07 19:30:39 +00:00
|
|
|
const char *ConsoleInputPeek ();
|
2006-02-26 06:26:56 +00:00
|
|
|
bool ConsoleInputClear ();
|
|
|
|
bool ConsoleInputBackSpace ();
|
|
|
|
bool ConsoleInputChar ( TCHAR ch );
|
|
|
|
void ConsoleInputReset ();
|
|
|
|
int ConsoleInputTabCompletion ();
|
|
|
|
|
2006-07-05 21:23:13 +00:00
|
|
|
void ConsoleUpdateCursor( char ch );
|
|
|
|
|
|
|
|
Update_t ConsoleBufferTryUnpause (int nLines);
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
Update_t ConsoleScrollHome ();
|
|
|
|
Update_t ConsoleScrollEnd ();
|
|
|
|
Update_t ConsoleScrollUp ( int nLines );
|
|
|
|
Update_t ConsoleScrollDn ( int nLines );
|
|
|
|
Update_t ConsoleScrollPageUp ();
|
|
|
|
Update_t ConsoleScrollPageDn ();
|
|
|
|
|
|
|
|
#endif
|