Sync to master

This commit is contained in:
michaelangel007 2023-04-24 20:07:07 -07:00
commit d2aeb96653
5 changed files with 52 additions and 23 deletions

View File

@ -7163,6 +7163,9 @@ void WindowUpdateConsoleDisplayedSize ()
g_nConsoleDisplayWidth = CONSOLE_WIDTH - 1;
g_bConsoleFullWidth = true;
}
g_nConsoleInputMaxLen = g_nConsoleDisplayWidth-1; // -1 prompt at Start-of-Line, -1 for cursor at End-of-Line
g_nConsoleInputScrollWidth = g_nConsoleDisplayWidth-1; // Maximum number of characters for the horizontol scrolling window on the input line
#else
g_nConsoleDisplayWidth = (CONSOLE_WIDTH / 2) + 10;
g_bConsoleFullWidth = false;
@ -9049,7 +9052,7 @@ void DebuggerInputConsoleChar ( TCHAR ch )
return;
}
if (g_nConsoleInputChars > (g_nConsoleDisplayWidth-1))
if (g_nConsoleInputChars > g_nConsoleInputMaxLen)
return;
if ((ch >= CHAR_SPACE) && (ch <= 126)) // HACK MAGIC # 32 -> ' ', # 126

View File

@ -80,11 +80,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
char g_aConsoleInput[ CONSOLE_WIDTH ]; // = g_aConsoleDisplay[0];
// Cooked input line (no prompt)
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 = '~';
int g_nConsoleInputChars = 0;
char * g_pConsoleInput = 0; // points to past prompt
int g_nConsoleInputMaxLen = 0;
int g_nConsoleInputScrollWidth = 0;
const char * g_pConsoleFirstArg = 0; // points to first arg
bool g_bConsoleInputQuoted = false; // Allows lower-case to be entered
char g_nConsoleInputSkip = '~';
// Prototypes _______________________________________________________________
@ -354,7 +356,7 @@ void ConsoleConvertFromText ( conchar_t * sText, const char * pText )
//===========================================================================
Update_t ConsoleDisplayError ( const char * pText )
{
ConsoleBufferPush( pText );
ConsolePrintFormat( CHC_ERROR "%s", pText );
return ConsoleUpdate();
}
@ -430,7 +432,7 @@ bool ConsoleInputBackSpace ()
{
if (g_nConsoleInputChars)
{
g_pConsoleInput[ g_nConsoleInputChars ] = CHAR_SPACE;
g_pConsoleInput[ g_nConsoleInputChars ] = 0;
g_nConsoleInputChars--;
@ -461,7 +463,7 @@ bool ConsoleInputClear ()
//===========================================================================
bool ConsoleInputChar ( char ch )
{
if (g_nConsoleInputChars < g_nConsoleDisplayWidth) // bug? include prompt?
if (g_nConsoleInputChars < g_nConsoleInputMaxLen) // GH #1204 Need to count the space at EOL for the cursor
{
g_pConsoleInput[ g_nConsoleInputChars ] = ch;
g_nConsoleInputChars++;

View File

@ -245,11 +245,12 @@
extern char g_aConsoleInput[ CONSOLE_WIDTH ];
// Cooked input line (no prompt)
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 int g_nConsoleInputChars ;
extern char * g_pConsoleInput ; // points to past prompt
extern int g_nConsoleInputMaxLen ; // = g_nConsoleDisplayWidth-1 = 78 // Maximum number of characters allowed on input line
extern int g_nConsoleInputScrollWidth; // = g_nConsoleDisplayWidth-1 = 78 // Maximum number of characters for the horizontol scrolling window on the input line
extern const char * g_pConsoleFirstArg ; // points to first arg
extern bool g_bConsoleInputQuoted ;
extern char g_nConsoleInputSkip ;

View File

@ -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 );
}

View File

@ -32,7 +32,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static HANDLE g_hRiffFile = INVALID_HANDLE_VALUE;
static DWORD dwTotalOffset;
static DWORD dwDataOffset;
static DWORD g_dwTotalNumberOfBytesWritten = 0;
static unsigned int g_NumChannels = 2;
bool RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels)
@ -106,11 +105,13 @@ bool RiffFinishWriteFile()
DWORD dwNumberOfBytesWritten;
temp32 = g_dwTotalNumberOfBytesWritten - (dwTotalOffset + 4);
DWORD fileSize = SetFilePointer(g_hRiffFile, 0, NULL, FILE_END);
temp32 = fileSize - (dwTotalOffset + 4);
SetFilePointer(g_hRiffFile, dwTotalOffset, NULL, FILE_BEGIN);
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
temp32 = g_dwTotalNumberOfBytesWritten - (dwDataOffset + 4);
temp32 = fileSize - (dwDataOffset + 4);
SetFilePointer(g_hRiffFile, dwDataOffset, NULL, FILE_BEGIN);
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
@ -133,7 +134,5 @@ bool RiffPutSamples(const short* buf, unsigned int uSamples)
&dwNumberOfBytesWritten,
NULL);
g_dwTotalNumberOfBytesWritten += dwNumberOfBytesWritten;
return true;
}