Fixed drawing debugger text of (escape) color chars

This commit is contained in:
mpohoreski 2006-07-07 19:30:39 +00:00
parent deb46979e5
commit 20a1cb2449
6 changed files with 544 additions and 631 deletions

View File

@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// TODO: COLOR LOAD ["filename"]
// See Debugger_Changelong.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,7,1);
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,7,2);
// Public _________________________________________________________________________________________
@ -5305,7 +5305,7 @@ Update_t CmdOutputEcho (int nArgs)
}
else
{
const TCHAR *pText = g_pConsoleFirstArg; // ConsoleInputPeek();
const char *pText = g_pConsoleFirstArg; // ConsoleInputPeek();
if (pText)
{
ConsoleDisplayPush( pText );

View File

@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#pragma hdrstop
#include <assert.h>
// Console ________________________________________________________________________________________
@ -47,144 +48,174 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// g_aBufferedInput[3] |
// Buffer
bool g_bConsoleBufferPaused = false; // buffered output is waiting for user to continue
int g_nConsoleBuffer = 0;
conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH*2 ]; // TODO: stl::vector< line_t >
bool g_bConsoleBufferPaused = false; // buffered output is waiting for user to continue
int g_nConsoleBuffer = 0;
conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
// Cursor
char g_sConsoleCursor[] = "_";
// Display
conchar_t g_aConsolePrompt[] = TEXT(">!"); // input, assembler // NUM_PROMPTS
char g_aConsolePrompt[] = ">!"; // input, assembler // NUM_PROMPTS
char g_sConsolePrompt[] = ">"; // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
int g_nConsolePromptLen = 1;
conchar_t g_sConsolePrompt[] = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
int g_nConsolePromptLen = 1;
bool g_bConsoleFullWidth = true; // false
bool g_bConsoleFullWidth = true; // false
int g_iConsoleDisplayStart = 0; // to allow scrolling
int g_nConsoleDisplayTotal = 0; // number of lines added to console
int g_nConsoleDisplayLines = 0;
int g_nConsoleDisplayWidth = 0;
conchar_t g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH*2 ];
int g_iConsoleDisplayStart = 0; // to allow scrolling
int g_nConsoleDisplayTotal = 0; // number of lines added to console
int g_nConsoleDisplayLines = 0;
int g_nConsoleDisplayWidth = 0;
conchar_t g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];
// Input History
int g_nHistoryLinesStart = 0;
int g_nHistoryLinesTotal = 0; // number of commands entered
TCHAR g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ] = {TEXT("")};
char g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ] = {""};
// Input Line
conchar_t g_sConsoleCursor[] = "_";
// Raw input Line (has prompt)
conchar_t * const g_aConsoleInput = g_aConsoleDisplay[0];
// Cooked input line (no prompt)
int g_nConsoleInputChars = 0;
conchar_t * g_pConsoleInput = 0; // points to past prompt
const conchar_t * g_pConsoleFirstArg = 0; // points to first arg
bool g_bConsoleInputQuoted = false; // Allows lower-case to be entered
char g_nConsoleInputSkip = '~';
int g_nConsoleInputChars = 0;
char * g_pConsoleInput = 0; // points to past prompt
const char * g_pConsoleFirstArg = 0; // points to first arg
bool g_bConsoleInputQuoted = false; // Allows lower-case to be entered
char g_nConsoleInputSkip = '~';
// Prototypes _______________________________________________________________
// Console ________________________________________________________________________________________
//===========================================================================
LPCSTR ConsoleBufferPeek()
const conchar_t* ConsoleBufferPeek ()
{
return g_aConsoleBuffer[ 0 ];
}
//===========================================================================
bool ConsolePrint( const char * pText )
bool ConsolePrint ( const char * pText )
{
// TODO: Must convert color string to native console color text
const int nMaxWidth = (CONSOLE_WIDTH * 2) - 1; // g_nConsoleDisplayWidth;
int nLen = _tcslen( pText );
// push multiple lines
while ((nLen > 0) && (g_nConsoleBuffer < CONSOLE_BUFFER_HEIGHT))
while (g_nConsoleBuffer >= CONSOLE_BUFFER_HEIGHT)
{
_tcsncpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pText, nMaxWidth );
pText += nMaxWidth;
g_nConsoleBuffer++;
nLen -= nMaxWidth;
ConsoleBufferToDisplay();
}
// Convert color string to native console color text
// Ignores g_nConsoleDisplayWidth
conchar_t c;
int x = 0;
const char * pSrc = pText;
conchar_t *pDst = & g_aConsoleBuffer[ g_nConsoleBuffer ][ 0 ];
while ((x < CONSOLE_WIDTH) && (c = *pSrc))
{
if ((c == '\n') || (x == (CONSOLE_WIDTH - 1)))
{
*pDst = 0;
x = 0;
if (g_nConsoleBuffer >= CONSOLE_BUFFER_HEIGHT)
{
ConsoleBufferToDisplay();
}
else
{
g_nConsoleBuffer++;
}
pSrc++;
pDst = & g_aConsoleBuffer[ g_nConsoleBuffer ][ 0 ];
}
else
if (ConsoleColor_IsCharMeta( c ))
{
pSrc++;
c = *pSrc;
if (c)
{
if (ConsoleColor_IsCharMeta( c ))
*pDst = c;
else
*pDst = ConsoleColor_Make( c );
x++;
pSrc++;
pDst++;
}
else
break;
}
else
{
*pDst = (c & _CONSOLE_COLOR_MASK);
x++;
pSrc++;
pDst++;
}
}
*pDst = 0;
g_nConsoleBuffer++;
return true;
}
// Add string to buffered output
// Shifts the buffered console output lines "Up"
//===========================================================================
bool ConsoleBufferPush( const TCHAR * pString ) // LPCSTR
bool ConsoleBufferPush ( const char * pText )
{
int nLen = _tcslen( pString );
while (g_nConsoleBuffer >= CONSOLE_BUFFER_HEIGHT)
{
ConsoleBufferToDisplay();
}
#if USE_APPLE_FONT
// TODO/FIXME: Must convert console over to CHAR16 type, since colored strings are of varying length
const int nMaxWidth = CONSOLE_WIDTH; // + (CONSOLE_WIDTH / 2); // g_nConsoleDisplayWidth;
#else
const int nMaxWidth = CONSOLE_WIDTH-1; // g_nConsoleDisplayWidth;
#endif
conchar_t c;
int x = 0;
const char *pSrc = pText;
conchar_t *pDst = & g_aConsoleBuffer[ g_nConsoleBuffer ][ 0 ];
while ((nLen > 0) && (g_nConsoleBuffer < CONSOLE_HEIGHT))
while ((x < CONSOLE_WIDTH) && (c = *pSrc))
{
x = min( nLen, nMaxWidth );
_tcsncpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pString, x );
nLen -= x;
conchar_t *pLine = & g_aConsoleBuffer[ g_nConsoleBuffer ][ x ];
/*
for ( ; x < nMaxWidth; x++ )
if ((c == '\n') || (x == (CONSOLE_WIDTH - 1)))
{
*pLine++ = CHAR_SPACE;
}
*/
*pLine = 0;
g_nConsoleBuffer++;
}
return true;
// return true;
/*
*pDst = 0;
x = 0;
if (g_nConsoleBuffer >= CONSOLE_BUFFER_HEIGHT)
{
ConsoleBufferToDisplay();
}
else
{
g_nConsoleBuffer++;
}
pSrc++;
pDst = & g_aConsoleBuffer[ g_nConsoleBuffer ][ 0 ];
}
else
{
#if _DEBUG
TCHAR sText[ CONSOLE_WIDTH * 2 ];
sprintf( sText, "String length > Console display width\n%d > %d", nLen, g_nConsoleDisplayWidth );
MessageBox( g_hFrameWindow, sText, "ConsoleBufferPush(pString)", MB_OK );
#endif
// push multiple lines
while ((nLen > 0) && (g_nConsoleBuffer < CONSOLE_HEIGHT))
{
_tcsncpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pString, nMaxWidth );
pString += nMaxWidth;
g_nConsoleBuffer++;
nLen -= nMaxWidth;
}
return true;
*pDst = (c & _CONSOLE_COLOR_MASK);
x++;
pSrc++;
pDst++;
}
*/
}
*pDst = 0;
g_nConsoleBuffer++;
// TODO: Warning: Too much output.
// return false;
return true;
}
// Shifts the buffered console output "down"
//===========================================================================
void ConsoleBufferPop()
void ConsoleBufferPop ()
{
int y = 0;
while (y < g_nConsoleBuffer)
{
_tcscpy( g_aConsoleBuffer[ y ], g_aConsoleBuffer[ y+1 ] );
strcpy( (char*)g_aConsoleBuffer[ y ], (char*)g_aConsoleBuffer[ y+1 ] );
y++;
}
@ -195,39 +226,36 @@ void ConsoleBufferPop()
// Remove string from buffered output
//===========================================================================
void ConsoleBufferToDisplay()
void ConsoleBufferToDisplay ()
{
ConsoleDisplayPush( ConsoleBufferPeek() );
ConsoleDisplayPush( (char*) ConsoleBufferPeek() );
ConsoleBufferPop();
}
//===========================================================================
Update_t ConsoleDisplayError (LPCTSTR pText)
Update_t ConsoleDisplayError ( const char * pText)
{
ConsoleBufferPush( pText );
return ConsoleUpdate();
}
// ConsoleDisplayPush()
// Shifts the console display lines "up"
//===========================================================================
void ConsoleDisplayPush( LPCSTR pText )
void ConsoleDisplayPush ( const char * pText )
{
int nLen = MIN( g_nConsoleDisplayTotal, CONSOLE_HEIGHT - 1 - CONSOLE_FIRST_LINE);
while (nLen--)
{
// _tcsncpy(
_tcscpy(
g_aConsoleDisplay[(nLen + 1 + CONSOLE_FIRST_LINE )]
, g_aConsoleDisplay[nLen + CONSOLE_FIRST_LINE]
strcpy(
(char*) g_aConsoleDisplay[(nLen + 1 + CONSOLE_FIRST_LINE )]
,(char*) g_aConsoleDisplay[nLen + CONSOLE_FIRST_LINE]
);
// , CONSOLE_WIDTH );
}
if (pText)
// _tcsncpy(
_tcscpy(
g_aConsoleDisplay[ CONSOLE_FIRST_LINE ]
strcpy(
(char*) g_aConsoleDisplay[ CONSOLE_FIRST_LINE ]
, pText
);
// , CONSOLE_WIDTH );
@ -240,11 +268,14 @@ void ConsoleDisplayPush( LPCSTR pText )
//===========================================================================
void ConsoleDisplayPause()
void ConsoleDisplayPause ()
{
if (g_nConsoleBuffer)
{
strcpy( g_aConsoleInput, "...press SPACE continue, ESC skip..." );
strcpy(
(char*) g_aConsoleInput,
"...press SPACE continue, ESC skip..."
);
g_nConsolePromptLen = strlen( g_pConsoleInput ) + 1;
g_nConsoleInputChars = 0;
g_bConsoleBufferPaused = true;
@ -256,7 +287,7 @@ void ConsoleDisplayPause()
}
//===========================================================================
bool ConsoleInputBackSpace()
bool ConsoleInputBackSpace ()
{
if (g_nConsoleInputChars)
{
@ -264,8 +295,8 @@ bool ConsoleInputBackSpace()
g_nConsoleInputChars--;
if ((g_pConsoleInput[ g_nConsoleInputChars ] == TCHAR_QUOTE_DOUBLE) ||
(g_pConsoleInput[ g_nConsoleInputChars ] == TCHAR_QUOTE_SINGLE))
if ((g_pConsoleInput[ g_nConsoleInputChars ] == CHAR_QUOTE_DOUBLE) ||
(g_pConsoleInput[ g_nConsoleInputChars ] == CHAR_QUOTE_SINGLE))
g_bConsoleInputQuoted = ! g_bConsoleInputQuoted;
g_pConsoleInput[ g_nConsoleInputChars ] = CHAR_SPACE;
@ -276,7 +307,7 @@ bool ConsoleInputBackSpace()
// Clears prompt too
//===========================================================================
bool ConsoleInputClear()
bool ConsoleInputClear ()
{
ZeroMemory( g_aConsoleInput, CONSOLE_WIDTH );
// Note: Alternate console, with no NULL end of line terminator
@ -293,7 +324,7 @@ bool ConsoleInputClear()
}
//===========================================================================
bool ConsoleInputChar( TCHAR ch )
bool ConsoleInputChar ( const char ch )
{
if (g_nConsoleInputChars < g_nConsoleDisplayWidth) // bug? include prompt?
{
@ -305,7 +336,7 @@ bool ConsoleInputChar( TCHAR ch )
}
//===========================================================================
void ConsoleUpdateCursor( char ch )
void ConsoleUpdateCursor ( char ch )
{
if (ch)
g_sConsoleCursor[0] = ch;
@ -322,9 +353,9 @@ void ConsoleUpdateCursor( char ch )
//===========================================================================
LPCSTR ConsoleInputPeek()
const char * ConsoleInputPeek ()
{
return g_aConsoleDisplay[0];
return (char*) g_aConsoleDisplay[0];
}
//===========================================================================
@ -342,8 +373,8 @@ void ConsoleInputReset ()
// _tcscat( g_aConsoleInput, TEXT(" " ) );
int nLen = _tcslen( g_aConsoleInput );
g_pConsoleInput = &g_aConsoleInput[ g_nConsolePromptLen ]; // nLen];
int nLen = strlen( (char*) g_aConsoleInput );
g_pConsoleInput = (char*) &g_aConsoleInput[ g_nConsolePromptLen ]; // nLen];
g_nConsoleInputChars = 0;
}
@ -404,7 +435,7 @@ Update_t ConsoleScrollPageUp ()
}
//===========================================================================
Update_t ConsoleScrollPageDn()
Update_t ConsoleScrollPageDn ()
{
ConsoleScrollDn( g_nConsoleDisplayLines - CONSOLE_FIRST_LINE );
@ -431,7 +462,7 @@ Update_t ConsoleBufferTryUnpause (int nLines)
}
//===========================================================================
Update_t ConsoleUpdate()
Update_t ConsoleUpdate ()
{
if (! g_bConsoleBufferPaused)
{

View File

@ -1,14 +1,13 @@
#ifndef DEBUGGER_CONSOLE_H
#define DEBUGGER_CONSOLE_H
// const int CONSOLE_HEIGHT = 384; // Lines, was 128, but need ~ 256+16 for PROFILE LIST
// const int CONSOLE_WIDTH = 80;
enum
{
CONSOLE_HEIGHT = 384, // Lines, was 128, but need ~ 256+16 for PROFILE LIST
CONSOLE_WIDTH = 80,
CONSOLE_BUFFER_HEIGHT = 128,
// need min 256+ lines for "profile list"
CONSOLE_BUFFER_HEIGHT = 384,
HISTORY_HEIGHT = 128,
HISTORY_WIDTH = 128,
@ -16,47 +15,164 @@
CONSOLE_FIRST_LINE = 1, // where ConsoleDisplay is pushed up from
};
// 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;
}
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 __________________________________________________________________
typedef TCHAR conchar_t;
// Buffer
extern bool g_bConsoleBufferPaused;// = false; // buffered output is waiting for user to continue
extern int g_nConsoleBuffer; //= 0;
extern TCHAR g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH*2 ]; // TODO: stl::vector< line_t >
extern bool g_bConsoleBufferPaused;
extern int g_nConsoleBuffer;
extern conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
// Cursor
extern char g_sConsoleCursor[];
extern char g_sConsoleCursor[];
// Display
extern TCHAR g_aConsolePrompt[];// = TEXT(">!"); // input, assembler // NUM_PROMPTS
extern TCHAR g_sConsolePrompt[];// = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
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. :-(
extern int g_nConsolePromptLen;
extern bool g_bConsoleFullWidth;// = false;
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 TCHAR g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH*2 ];
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 ];
// Input History
extern int g_nHistoryLinesStart;// = 0;
extern int g_nHistoryLinesTotal;// = 0; // number of commands entered
extern TCHAR g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ];// = {TEXT("")};
extern char g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ];// = {TEXT("")};
// Input Line
// Raw input Line (has prompt)
extern TCHAR * const g_aConsoleInput; // = g_aConsoleDisplay[0];
extern conchar_t * const g_aConsoleInput; // = g_aConsoleDisplay[0];
// Cooked input line (no prompt)
extern int g_nConsoleInputChars ;//= 0;
extern TCHAR * g_pConsoleInput ;//= 0; // points to past prompt
extern const TCHAR * g_pConsoleFirstArg ;//= 0; // points to first arg
extern bool g_bConsoleInputQuoted ;//= false; // Allows lower-case to be entered
extern char g_nConsoleInputSkip ;//= false;
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 ;
// Prototypes _______________________________________________________________
@ -64,21 +180,21 @@
// Console
// Buffered
bool ConsolePrint( const char * pText );
void ConsoleBufferToDisplay ();
LPCSTR ConsoleBufferPeek ();
void ConsoleBufferPop ();
bool ConsoleBufferPush ( const TCHAR * pString );
bool ConsolePrint( const char * pText );
void ConsoleBufferToDisplay ();
const conchar_t* ConsoleBufferPeek ();
void ConsoleBufferPop ();
bool ConsoleBufferPush ( const char * pString );
// Display
Update_t ConsoleDisplayError (LPCTSTR errortext);
Update_t ConsoleDisplayError ( const char * pTextError );
void ConsoleDisplayPause ();
void ConsoleDisplayPush ( LPCSTR pText );
void ConsoleDisplayPush ( const char * pText );
Update_t ConsoleUpdate ();
// Input
void ConsoleInputToDisplay ();
LPCSTR ConsoleInputPeek ();
const char *ConsoleInputPeek ();
bool ConsoleInputClear ();
bool ConsoleInputBackSpace ();
bool ConsoleInputChar ( TCHAR ch );

File diff suppressed because it is too large Load Diff

View File

@ -49,92 +49,6 @@
extern HBRUSH g_hConsoleFontBrush;
extern HBITMAP g_hConsoleFontBitmap;
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 ];
// extern const char *g_asConsoleColor[ MAX_CONSOLE_COLORS ];
// Note: THe ` ~ key should always display ~ to prevent rendering errors
#define CONSOLE_COLOR_ESCAPE_CHAR '`'
// 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 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
inline bool ConsoleColorIsEscapeMeta( char c )
{
if (CONSOLE_COLOR_ESCAPE_CHAR == c)
return true;
return false;
}
inline bool ConsoleColorIsEscapeData( char c )
{
if ((c >= '0') && (c <= '7'))
return true;
return false;
}
inline COLORREF ConsoleColorGetEscapeData( char c )
{
int iColor = (c - '0') & (MAX_CONSOLE_COLORS - 1);
return g_anConsoleColor[ iColor ];
}
inline void ConsoleColorMake( char * pText, ConsoleColors_e eColor )
{
#if USE_APPLE_FONT
pText[0] = CONSOLE_COLOR_ESCAPE_CHAR;
pText[1] = eColor + '0';
pText[2] = 0;
#else
pText[0] = 0;
#endif
}
enum
{
DISPLAY_HEIGHT = 384,
@ -148,18 +62,17 @@
void DebuggerSetColorFG( COLORREF nRGB );
void DebuggerSetColorBG( COLORREF nRGB, bool bTransparent = false );
void DebuggerPrintChar( const int x, const int y, const int iChar );
int DebugDrawText ( LPCTSTR pText, RECT & rRect );
int DebugDrawTextFixed ( LPCTSTR pText, RECT & rRect );
int DebugDrawTextLine ( LPCTSTR pText, RECT & rRect );
int DebugDrawTextHorz ( LPCTSTR pText, RECT & rRect );
void PrintGlyph ( const int x, const int y, const int iChar );
int PrintText ( const char * pText, RECT & rRect );
void PrintTextColor ( const char * pText, RECT & rRect );
int PrintTextCursorX( const char * pText, RECT & rRect );
int PrintTextCursorY( const char * pText, RECT & rRect );
void DrawWindow_Source (Update_t bUpdate);
void DrawBreakpoints ( int line);
void DrawConsoleInput ();
void DrawConsoleLine (LPCSTR pText, int y);
void DrawConsoleLine ( const char * pText, int y);
void DrawConsoleCursor ();
WORD DrawDisassemblyLine ( int line, WORD offset, LPTSTR text);

View File

@ -247,7 +247,7 @@ void Help_Operators()
}
}
_tcscat( sText, CON_COLOR_DEFAULT );
ConsoleBufferPush( sText );
ConsolePrint( sText );
}
void Help_KeyboardShortcuts()
@ -270,9 +270,9 @@ void Help_KeyboardShortcuts()
//===========================================================================
Update_t CmdMOTD( int nArgs )
{
TCHAR sText[ CONSOLE_WIDTH ];
char sText[ CONSOLE_WIDTH ];
ConsoleBufferPush( TEXT(" Apple ][ ][+ //e Emulator for Windows") );
ConsoleBufferPush( " Apple ][ ][+ //e Emulator for Windows" );
CmdVersion(0);
CmdSymbols(0);
wsprintf( sText, " '%sCtrl ~%s' console, '%s%s%s' (specific), '%s%s%s' (all)"
@ -287,7 +287,7 @@ Update_t CmdMOTD( int nArgs )
, CON_COLOR_DEFAULT
// , g_aCommands[ CMD_HELP_LIST ].pHelpSummary
);
ConsoleBufferPush( sText );
ConsolePrint( sText );
ConsoleUpdate();
@ -1126,7 +1126,7 @@ Update_t CmdVersion (int nArgs)
, nMajor, nMinor, nFixMajor, nFixMinor
, CON_COLOR_DEFAULT
);
ConsoleBufferPush( sText );
ConsolePrint( sText );
if (nArgs)
{