Fixed drawing debugger text of (escape) color chars

This commit is contained in:
mpohoreski 2006-07-07 19:30:39 +00:00
parent 83dbe3f69c
commit 56de402581
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"] // TODO: COLOR LOAD ["filename"]
// See Debugger_Changelong.txt for full details // 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 _________________________________________________________________________________________ // Public _________________________________________________________________________________________
@ -5305,7 +5305,7 @@ Update_t CmdOutputEcho (int nArgs)
} }
else else
{ {
const TCHAR *pText = g_pConsoleFirstArg; // ConsoleInputPeek(); const char *pText = g_pConsoleFirstArg; // ConsoleInputPeek();
if (pText) if (pText)
{ {
ConsoleDisplayPush( pText ); ConsoleDisplayPush( pText );

View File

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

View File

@ -1,14 +1,13 @@
#ifndef DEBUGGER_CONSOLE_H #ifndef DEBUGGER_CONSOLE_H
#define 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 enum
{ {
CONSOLE_HEIGHT = 384, // Lines, was 128, but need ~ 256+16 for PROFILE LIST CONSOLE_HEIGHT = 384, // Lines, was 128, but need ~ 256+16 for PROFILE LIST
CONSOLE_WIDTH = 80, CONSOLE_WIDTH = 80,
CONSOLE_BUFFER_HEIGHT = 128, // need min 256+ lines for "profile list"
CONSOLE_BUFFER_HEIGHT = 384,
HISTORY_HEIGHT = 128, HISTORY_HEIGHT = 128,
HISTORY_WIDTH = 128, HISTORY_WIDTH = 128,
@ -16,47 +15,164 @@
CONSOLE_FIRST_LINE = 1, // where ConsoleDisplay is pushed up from 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 __________________________________________________________________ // Globals __________________________________________________________________
typedef TCHAR conchar_t;
// Buffer // Buffer
extern bool g_bConsoleBufferPaused;// = false; // buffered output is waiting for user to continue extern bool g_bConsoleBufferPaused;
extern int g_nConsoleBuffer; //= 0; extern int g_nConsoleBuffer;
extern TCHAR g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH*2 ]; // TODO: stl::vector< line_t > extern conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
// Cursor // Cursor
extern char g_sConsoleCursor[]; extern char g_sConsoleCursor[];
// Display // Display
extern TCHAR g_aConsolePrompt[];// = TEXT(">!"); // input, assembler // NUM_PROMPTS extern char 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_sConsolePrompt[];// = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
extern int g_nConsolePromptLen; extern int g_nConsolePromptLen;
extern bool g_bConsoleFullWidth;// = false; extern bool g_bConsoleFullWidth;// = false;
extern int g_iConsoleDisplayStart ; // to allow scrolling extern int g_iConsoleDisplayStart ; // to allow scrolling
extern int g_nConsoleDisplayTotal ; // number of lines added to console extern int g_nConsoleDisplayTotal ; // number of lines added to console
extern int g_nConsoleDisplayLines ; extern int g_nConsoleDisplayLines ;
extern int g_nConsoleDisplayWidth ; extern int g_nConsoleDisplayWidth ;
extern TCHAR g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH*2 ]; extern conchar_t g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];
// Input History // Input History
extern int g_nHistoryLinesStart;// = 0; extern int g_nHistoryLinesStart;// = 0;
extern int g_nHistoryLinesTotal;// = 0; // number of commands entered 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 // Input Line
// Raw input Line (has prompt) // 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) // Cooked input line (no prompt)
extern int g_nConsoleInputChars ;//= 0; extern int g_nConsoleInputChars ;
extern TCHAR * g_pConsoleInput ;//= 0; // points to past prompt extern char * g_pConsoleInput ;//= 0; // points to past prompt
extern const TCHAR * g_pConsoleFirstArg ;//= 0; // points to first arg extern const char * g_pConsoleFirstArg ;//= 0; // points to first arg
extern bool g_bConsoleInputQuoted ;//= false; // Allows lower-case to be entered extern bool g_bConsoleInputQuoted ;
extern char g_nConsoleInputSkip ;//= false; extern char g_nConsoleInputSkip ;
// Prototypes _______________________________________________________________ // Prototypes _______________________________________________________________
@ -64,21 +180,21 @@
// Console // Console
// Buffered // Buffered
bool ConsolePrint( const char * pText ); bool ConsolePrint( const char * pText );
void ConsoleBufferToDisplay (); void ConsoleBufferToDisplay ();
LPCSTR ConsoleBufferPeek (); const conchar_t* ConsoleBufferPeek ();
void ConsoleBufferPop (); void ConsoleBufferPop ();
bool ConsoleBufferPush ( const TCHAR * pString ); bool ConsoleBufferPush ( const char * pString );
// Display // Display
Update_t ConsoleDisplayError (LPCTSTR errortext); Update_t ConsoleDisplayError ( const char * pTextError );
void ConsoleDisplayPause (); void ConsoleDisplayPause ();
void ConsoleDisplayPush ( LPCSTR pText ); void ConsoleDisplayPush ( const char * pText );
Update_t ConsoleUpdate (); Update_t ConsoleUpdate ();
// Input // Input
void ConsoleInputToDisplay (); void ConsoleInputToDisplay ();
LPCSTR ConsoleInputPeek (); const char *ConsoleInputPeek ();
bool ConsoleInputClear (); bool ConsoleInputClear ();
bool ConsoleInputBackSpace (); bool ConsoleInputBackSpace ();
bool ConsoleInputChar ( TCHAR ch ); 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 HBRUSH g_hConsoleFontBrush;
extern HBITMAP g_hConsoleFontBitmap; 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 enum
{ {
DISPLAY_HEIGHT = 384, DISPLAY_HEIGHT = 384,
@ -148,18 +62,17 @@
void DebuggerSetColorFG( COLORREF nRGB ); void DebuggerSetColorFG( COLORREF nRGB );
void DebuggerSetColorBG( COLORREF nRGB, bool bTransparent = false ); void DebuggerSetColorBG( COLORREF nRGB, bool bTransparent = false );
void DebuggerPrintChar( const int x, const int y, const int iChar ); void PrintGlyph ( const int x, const int y, const int iChar );
int PrintText ( const char * pText, RECT & rRect );
int DebugDrawText ( LPCTSTR pText, RECT & rRect ); void PrintTextColor ( const char * pText, RECT & rRect );
int DebugDrawTextFixed ( LPCTSTR pText, RECT & rRect ); int PrintTextCursorX( const char * pText, RECT & rRect );
int DebugDrawTextLine ( LPCTSTR pText, RECT & rRect ); int PrintTextCursorY( const char * pText, RECT & rRect );
int DebugDrawTextHorz ( LPCTSTR pText, RECT & rRect );
void DrawWindow_Source (Update_t bUpdate); void DrawWindow_Source (Update_t bUpdate);
void DrawBreakpoints ( int line); void DrawBreakpoints ( int line);
void DrawConsoleInput (); void DrawConsoleInput ();
void DrawConsoleLine (LPCSTR pText, int y); void DrawConsoleLine ( const char * pText, int y);
void DrawConsoleCursor (); void DrawConsoleCursor ();
WORD DrawDisassemblyLine ( int line, WORD offset, LPTSTR text); WORD DrawDisassemblyLine ( int line, WORD offset, LPTSTR text);

View File

@ -247,7 +247,7 @@ void Help_Operators()
} }
} }
_tcscat( sText, CON_COLOR_DEFAULT ); _tcscat( sText, CON_COLOR_DEFAULT );
ConsoleBufferPush( sText ); ConsolePrint( sText );
} }
void Help_KeyboardShortcuts() void Help_KeyboardShortcuts()
@ -270,9 +270,9 @@ void Help_KeyboardShortcuts()
//=========================================================================== //===========================================================================
Update_t CmdMOTD( int nArgs ) 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); CmdVersion(0);
CmdSymbols(0); CmdSymbols(0);
wsprintf( sText, " '%sCtrl ~%s' console, '%s%s%s' (specific), '%s%s%s' (all)" 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 , CON_COLOR_DEFAULT
// , g_aCommands[ CMD_HELP_LIST ].pHelpSummary // , g_aCommands[ CMD_HELP_LIST ].pHelpSummary
); );
ConsoleBufferPush( sText ); ConsolePrint( sText );
ConsoleUpdate(); ConsoleUpdate();
@ -1126,7 +1126,7 @@ Update_t CmdVersion (int nArgs)
, nMajor, nMinor, nFixMajor, nFixMinor , nMajor, nMinor, nFixMajor, nFixMinor
, CON_COLOR_DEFAULT , CON_COLOR_DEFAULT
); );
ConsoleBufferPush( sText ); ConsolePrint( sText );
if (nArgs) if (nArgs)
{ {