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 ____________________________________________________________________
|
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
// typedef unsigned char conchar_t;
|
|
|
|
typedef short conchar_t;
|
2006-07-07 19:30:39 +00:00
|
|
|
|
|
|
|
enum ConsoleColors_e
|
|
|
|
{
|
2006-07-09 04:53:08 +00:00
|
|
|
CONSOLE_COLOR_K, // 0
|
2006-07-07 19:30:39 +00:00
|
|
|
CONSOLE_COLOR_x = 0, // default console foreground
|
2006-07-09 04:53:08 +00:00
|
|
|
CONSOLE_COLOR_R, // 1
|
|
|
|
CONSOLE_COLOR_G, // 2
|
|
|
|
CONSOLE_COLOR_Y, // 3
|
|
|
|
CONSOLE_COLOR_B, // 4
|
|
|
|
CONSOLE_COLOR_M, // 5 Lite Blue
|
|
|
|
CONSOLE_COLOR_C, // 6
|
|
|
|
CONSOLE_COLOR_W, // 7
|
|
|
|
CONSOLE_COLOR_O, // 8
|
|
|
|
CONSOLE_COLOR_k, // 9 Grey
|
|
|
|
NUM_CONSOLE_COLORS
|
2006-07-07 19:30:39 +00:00
|
|
|
};
|
2006-07-09 04:53:08 +00:00
|
|
|
extern COLORREF g_anConsoleColor[ NUM_CONSOLE_COLORS ];
|
2006-07-07 19:30:39 +00:00
|
|
|
|
|
|
|
// Note: THe ` ~ key should always display ~ to prevent rendering errors
|
|
|
|
#define CONSOLE_COLOR_ESCAPE_CHAR '`'
|
|
|
|
#define _CONSOLE_COLOR_MASK 0x7F
|
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
/* Help Colors
|
2006-07-07 19:30:39 +00:00
|
|
|
*/
|
|
|
|
#if 1 // USE_APPLE_FONT
|
2006-07-09 04:53:08 +00:00
|
|
|
// Console Help Color
|
|
|
|
#define CHC_DEFAULT "`0"
|
|
|
|
#define CHC_USAGE "`3"
|
|
|
|
#define CHC_CATEGORY "`6"
|
|
|
|
#define CHC_COMMAND "`2"
|
|
|
|
#define CHC_KEY "`1"
|
|
|
|
#define CHC_ARG_MAND "`7" // < >
|
|
|
|
#define CHC_ARG_OPT "`4" // [ ]
|
|
|
|
#define CHC_ARG_SEP "`9" // | grey
|
2006-08-16 18:58:56 +00:00
|
|
|
#define CHC_NUM_DEC "`6" // cyan looks better then yellow
|
|
|
|
#define CHC_NUM_HEX "`3"
|
2006-07-09 04:53:08 +00:00
|
|
|
#define CHC_SYMBOL "`2"
|
|
|
|
#define CHC_ADDRESS "`8"
|
|
|
|
#define CHC_ERROR "`1"
|
|
|
|
#define CHC_STRING "`6"
|
|
|
|
#define CHC_EXAMPLE "`5"
|
2006-07-07 19:30:39 +00:00
|
|
|
#else
|
2006-07-09 04:53:08 +00:00
|
|
|
#define CHC_DEFAULT ""
|
|
|
|
#define CHC_USAGE ""
|
|
|
|
#define CHC_COMMAND ""
|
|
|
|
#define CHC_KEY ""
|
|
|
|
#define CHC_ARG_MAND ""
|
|
|
|
#define CHC_ARG_OPT ""
|
|
|
|
#define CHC_ARG_SEP ""
|
|
|
|
#define CHC_NUMBER ""
|
|
|
|
#define CHC_SYMBOL ""
|
|
|
|
#define CHC_ADDRESS ""
|
|
|
|
#define CHC_ERROR ""
|
|
|
|
#define CHC_STRING ""
|
|
|
|
#define CHC_EXAMPLE ""
|
2006-07-07 19:30:39 +00:00
|
|
|
#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 )
|
|
|
|
{
|
2006-07-09 04:53:08 +00:00
|
|
|
if ((c >= '0') && ((c - '0') < NUM_CONSOLE_COLORS))
|
2006-07-07 19:30:39 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
// Console "Native" Chars
|
|
|
|
//
|
2006-07-07 19:30:39 +00:00
|
|
|
// There are a few different ways of encoding color chars & mouse text
|
2006-07-09 04:53:08 +00:00
|
|
|
// Simplist method is to use a user-defined ESCAPE char to shift
|
|
|
|
// into color mode, or mouse text mode. The other solution
|
|
|
|
// is to use a wide-char, simulating unicode16.
|
|
|
|
//
|
|
|
|
// C1C0 char16 of High Byte (c1) and Low Byte (c0)
|
|
|
|
// 1) --?? Con: Colors chars take up extra chars.
|
|
|
|
// Con: String Length is complicated.
|
|
|
|
// Pro: simple to parse
|
|
|
|
//
|
|
|
|
// <-- WE USE THIS
|
|
|
|
// 2) ccea Pro: Efficient packing of plain text and mouse text
|
|
|
|
// Pro: Color is optional (only record new color)
|
|
|
|
// Con: need to provide char8 and char16 API
|
|
|
|
// Con: little more difficult to parse/convert plain text
|
|
|
|
// i.e.
|
|
|
|
// ea = 0x20 - 0x7F ASCII
|
|
|
|
// 0x80 - 0xFF Mouse Text '@'-'Z' -> 0x00 - 0x1F
|
|
|
|
// cc = ASCII '0' - '9' (color)
|
|
|
|
// 3) ??cc Con: Colors chars take up extra chars
|
|
|
|
// 4) f?? Con: Colors chars take up extra chars
|
|
|
|
//
|
|
|
|
// Legend:
|
|
|
|
// f Flag
|
|
|
|
// -- Not Applicable (n/a)
|
|
|
|
// ?? ASCII (0x20 - 0x7F)
|
|
|
|
// ea Extended ASCII with High-Bit representing Mouse Text
|
|
|
|
// cc Encoded Color / Mouse Text
|
|
|
|
//
|
|
|
|
inline bool ConsoleColor_IsColorOrMouse( conchar_t g )
|
2006-07-07 19:30:39 +00:00
|
|
|
{
|
|
|
|
if (g > _CONSOLE_COLOR_MASK)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ConsoleColor_IsColor( conchar_t g )
|
|
|
|
{
|
2006-07-09 04:53:08 +00:00
|
|
|
return ConsoleColor_IsCharColor (g >> 8);
|
2006-07-07 19:30:39 +00:00
|
|
|
}
|
2006-02-26 06:26:56 +00:00
|
|
|
|
2006-07-07 19:30:39 +00:00
|
|
|
inline COLORREF ConsoleColor_GetColor( conchar_t g )
|
|
|
|
{
|
2006-07-09 04:53:08 +00:00
|
|
|
const int iColor = (g >> 8) - '0';
|
|
|
|
if (iColor < NUM_CONSOLE_COLORS)
|
|
|
|
return g_anConsoleColor[ iColor ];
|
|
|
|
|
|
|
|
return g_anConsoleColor[ 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline char ConsoleColor_GetMeta( conchar_t g )
|
|
|
|
{
|
|
|
|
return ((g >> 8) & _CONSOLE_COLOR_MASK);
|
2006-07-07 19:30:39 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
inline char ConsoleChar_GetChar( conchar_t g )
|
2006-07-07 19:30:39 +00:00
|
|
|
{
|
|
|
|
return (g & _CONSOLE_COLOR_MASK);
|
|
|
|
}
|
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
inline char ConsoleColor_MakeMouse( unsigned char c )
|
|
|
|
{
|
|
|
|
return ((c - '@') + (_CONSOLE_COLOR_MASK + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline conchar_t ConsoleColor_MakeMeta( unsigned char c )
|
|
|
|
{
|
|
|
|
conchar_t g = (ConsoleColor_MakeMouse(c) << 8);
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline conchar_t ConsoleColor_MakeColor( unsigned char color, unsigned char text )
|
2006-07-07 19:30:39 +00:00
|
|
|
{
|
2006-07-09 04:53:08 +00:00
|
|
|
conchar_t g = (color << 8) | text;
|
2006-07-07 19:30:39 +00:00
|
|
|
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-09 04:53:08 +00:00
|
|
|
extern char g_aConsoleInput[ CONSOLE_WIDTH ];
|
2006-02-26 06:26:56 +00:00
|
|
|
|
|
|
|
// Cooked input line (no prompt)
|
2006-07-09 04:53:08 +00:00
|
|
|
extern int g_nConsoleInputChars ;
|
|
|
|
extern char * g_pConsoleInput ; // points to past prompt
|
|
|
|
extern const char * g_pConsoleFirstArg ; // 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
|
|
|
|
2006-07-09 04:53:08 +00:00
|
|
|
void ConsoleConvertFromText( conchar_t * sText, const char * pText );
|
|
|
|
|
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-07-09 04:53:08 +00:00
|
|
|
void ConsoleDisplayPush ( const conchar_t * 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
|