mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Support longer lines being rendered in console
Don't truncate console lines at 255 bytes anymore. Especially lines containing many Unicode characters would be adversely affected by this limitation. Instead, truncate console lines after 10 wrapped lines are rendered. Rendering too many lines at once currently breaks the console scrolling. Rendering an ellipsis is currently not possible when rendering text with a maximum line count. Increase buffer sizes to handle long (esp. invalid) command inputs. Closes #7132.
This commit is contained in:
parent
f136bfa359
commit
fe95919f63
|
@ -543,7 +543,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
|
|||
// ends at the first whitespace, which breaks for unknown commands (filenames) containing spaces.
|
||||
if(!m_pfnUnknownCommandCallback(pStr, m_pUnknownCommandUserdata))
|
||||
{
|
||||
char aBuf[256];
|
||||
char aBuf[512 + 32];
|
||||
str_format(aBuf, sizeof(aBuf), "No such command: %s.", Result.m_pCommand);
|
||||
Print(OUTPUT_LEVEL_STANDARD, "chatresp", aBuf);
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ void CConsole::TraverseChain(FCommandCallback *ppfnCallback, void **ppUserData)
|
|||
void CConsole::ConToggle(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
CConsole *pConsole = static_cast<CConsole *>(pUser);
|
||||
char aBuf[128] = {0};
|
||||
char aBuf[512 + 32] = {0};
|
||||
CCommand *pCommand = pConsole->FindCommand(pResult->GetString(0), pConsole->m_FlagMask);
|
||||
if(pCommand)
|
||||
{
|
||||
|
@ -933,7 +933,7 @@ void CConsole::ConToggle(IConsole::IResult *pResult, void *pUser)
|
|||
void CConsole::ConToggleStroke(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
CConsole *pConsole = static_cast<CConsole *>(pUser);
|
||||
char aBuf[128] = {0};
|
||||
char aBuf[512 + 32] = {0};
|
||||
CCommand *pCommand = pConsole->FindCommand(pResult->GetString(1), pConsole->m_FlagMask);
|
||||
if(pCommand)
|
||||
{
|
||||
|
|
|
@ -346,7 +346,7 @@ bool CGameConsole::CInstance::OnInput(const IInput::CEvent &Event)
|
|||
|
||||
// find the current command
|
||||
{
|
||||
char aBuf[128];
|
||||
char aBuf[512];
|
||||
StrCopyUntilSpace(aBuf, sizeof(aBuf), GetString());
|
||||
const IConsole::CCommandInfo *pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf, m_CompletionFlagmask,
|
||||
m_Type != CGameConsole::CONSOLETYPE_LOCAL && m_pGameConsole->Client()->RconAuthed() && m_pGameConsole->Client()->UseTempRconCommands());
|
||||
|
@ -367,9 +367,6 @@ bool CGameConsole::CInstance::OnInput(const IInput::CEvent &Event)
|
|||
|
||||
void CGameConsole::CInstance::PrintLine(const char *pLine, int Len, ColorRGBA PrintColor)
|
||||
{
|
||||
if(Len > 255)
|
||||
Len = 255;
|
||||
|
||||
m_BacklogLock.lock();
|
||||
CBacklogEntry *pEntry = m_Backlog.Allocate(sizeof(CBacklogEntry) + Len);
|
||||
pEntry->m_YOffset = -1.0f;
|
||||
|
@ -694,7 +691,7 @@ void CGameConsole::OnRender()
|
|||
|
||||
if(NumArguments <= 0 && pConsole->m_IsCommand)
|
||||
{
|
||||
char aBuf[512];
|
||||
char aBuf[1024];
|
||||
str_format(aBuf, sizeof(aBuf), "Help: %s ", pConsole->m_pCommandHelp);
|
||||
TextRender()->TextEx(&Info.m_Cursor, aBuf, -1);
|
||||
TextRender()->TextColor(0.75f, 0.75f, 0.75f, 1);
|
||||
|
@ -729,8 +726,9 @@ void CGameConsole::OnRender()
|
|||
{
|
||||
TextRender()->SetCursor(&Cursor, 0.0f, 0.0f, FontSize, 0);
|
||||
Cursor.m_LineWidth = Screen.w - 10;
|
||||
Cursor.m_MaxLines = 10;
|
||||
TextRender()->TextEx(&Cursor, pEntry->m_aText, -1);
|
||||
pEntry->m_YOffset = Cursor.m_Y + Cursor.m_AlignedFontSize + LineOffset;
|
||||
pEntry->m_YOffset = Cursor.Height() + LineOffset;
|
||||
}
|
||||
OffsetY += pEntry->m_YOffset;
|
||||
|
||||
|
@ -751,6 +749,7 @@ void CGameConsole::OnRender()
|
|||
{
|
||||
TextRender()->SetCursor(&Cursor, 0.0f, y - OffsetY, FontSize, TEXTFLAG_RENDER);
|
||||
Cursor.m_LineWidth = Screen.w - 10.0f;
|
||||
Cursor.m_MaxLines = 10;
|
||||
Cursor.m_CalculateSelectionMode = (m_ConsoleState == CONSOLE_OPEN && pConsole->m_MousePress.y < pConsole->m_BoundingBox.m_Y && (pConsole->m_MouseIsPress || (pConsole->m_CurSelStart != pConsole->m_CurSelEnd) || pConsole->m_HasSelection)) ? TEXT_CURSOR_SELECTION_MODE_CALCULATE : TEXT_CURSOR_SELECTION_MODE_NONE;
|
||||
Cursor.m_PressMouse = pConsole->m_MousePress;
|
||||
Cursor.m_ReleaseMouse = pConsole->m_MouseRelease;
|
||||
|
|
Loading…
Reference in a new issue