mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-03-11 07:42:06 +00:00
1204 debugger long input crash (#1213)
* Debugger: Clamp long input * Fix backspace when input line has 78 characters * Colorize console error line * Cleanup alignment * Init * Refactor common expression * Add support for a long input line when we decide to enable it * Unabbreviate SOL and EOL
This commit is contained in:
committed by
GitHub
parent
a140946a23
commit
f8da683d45
@@ -1246,8 +1246,10 @@ void DrawConsoleCursor ()
|
||||
int nLineHeight = GetConsoleLineHeightPixels();
|
||||
int y = 0;
|
||||
|
||||
const int nInputWidth = min( g_nConsoleInputChars, g_nConsoleInputScrollWidth ); // NOTE: Keep in Sync! DrawConsoleInput() and DrawConsoleCursor()
|
||||
|
||||
RECT rect;
|
||||
rect.left = (g_nConsoleInputChars + g_nConsolePromptLen) * nWidth;
|
||||
rect.left = (nInputWidth + g_nConsolePromptLen) * nWidth;
|
||||
rect.top = GetConsoleTopPixels( y );
|
||||
rect.bottom = rect.top + nLineHeight; //g_nFontHeight;
|
||||
rect.right = rect.left + nWidth;
|
||||
@@ -1295,9 +1297,31 @@ void DrawConsoleInput ()
|
||||
RECT rect;
|
||||
GetConsoleRect( 0, rect );
|
||||
|
||||
// Console background is drawn in DrawWindowBackground_Info
|
||||
// DrawConsoleLine( g_aConsoleInput, 0 );
|
||||
PrintText( g_aConsoleInput, rect );
|
||||
// For long input only show last g_nConsoleInputScrollWidth characters
|
||||
if (g_nConsoleInputChars > g_nConsoleInputScrollWidth)
|
||||
{
|
||||
assert(g_nConsoleInputScrollWidth <= CONSOLE_WIDTH); // NOTE: To support a wider input line the size of g_aConsoleInput[] must be increased
|
||||
|
||||
// g_nConsoleInputMaxLen = 16;
|
||||
// g_nConsoleInputScrollWidth = 10;
|
||||
//
|
||||
// 123456789ABCDEF g_aConsoleInput[]
|
||||
// ^ g_nConsoleInputChars = 15
|
||||
// [--------] g_nConsoleInputScrollWidth = 10
|
||||
// >6789ABCDEF_ g_nConsoleInputMaxLen = 16
|
||||
static char aScrollingInput[ CONSOLE_WIDTH+1 ];
|
||||
aScrollingInput[0] = g_aConsoleInput[0]; // 1. Start-of-Line
|
||||
|
||||
const int nInputOffset = g_nConsoleInputChars - g_nConsoleInputScrollWidth ; // 2. Middle
|
||||
const int nInputWidth = min( g_nConsoleInputChars, g_nConsoleInputScrollWidth ); // NOTE: Keep in Sync! DrawConsoleInput() and DrawConsoleCursor()
|
||||
strncpy( aScrollingInput+1, g_aConsoleInput + 1 + nInputOffset, nInputWidth ); // +1 to skip prompt
|
||||
|
||||
aScrollingInput[ g_nConsoleInputScrollWidth+1 ] = 0; // 3. End-of-Line leave room for cursor
|
||||
|
||||
PrintText( aScrollingInput, rect );
|
||||
}
|
||||
else
|
||||
PrintText( g_aConsoleInput, rect );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user