m_DisplayStr -> m_aDisplayStr

This commit is contained in:
Dennis Felsing 2022-03-31 12:44:27 +02:00
parent f953a9850e
commit 2c1dfb3684
2 changed files with 8 additions and 8 deletions

View file

@ -60,17 +60,17 @@ void CLineInput::SetRange(const char *pString, int Begin, int End)
void CLineInput::Editing(const char *pString, int Cursor)
{
str_copy(m_DisplayStr, m_aStr, sizeof(m_DisplayStr));
str_copy(m_aDisplayStr, m_aStr, sizeof(m_aDisplayStr));
char aEditingText[IInput::INPUT_TEXT_SIZE + 2];
str_format(aEditingText, sizeof(aEditingText), "[%s]", pString);
int NewTextLen = str_length(aEditingText);
int CharsLeft = (int)sizeof(m_DisplayStr) - str_length(m_DisplayStr) - 1;
int CharsLeft = (int)sizeof(m_aDisplayStr) - str_length(m_aDisplayStr) - 1;
int FillCharLen = NewTextLen < CharsLeft ? NewTextLen : CharsLeft;
for(int i = str_length(m_DisplayStr) - 1; i >= m_CursorPos; i--)
m_DisplayStr[i + FillCharLen] = m_DisplayStr[i];
for(int i = str_length(m_aDisplayStr) - 1; i >= m_CursorPos; i--)
m_aDisplayStr[i + FillCharLen] = m_aDisplayStr[i];
for(int i = 0; i < FillCharLen; i++)
m_DisplayStr[m_CursorPos + i] = aEditingText[i];
m_FakeLen = str_length(m_DisplayStr);
m_aDisplayStr[m_CursorPos + i] = aEditingText[i];
m_FakeLen = str_length(m_aDisplayStr);
m_FakeCursorPos = m_CursorPos + Cursor + 1;
}

View file

@ -18,7 +18,7 @@ class CLineInput
int m_CursorPos;
int m_NumChars;
char m_DisplayStr[MAX_SIZE + IInput::INPUT_TEXT_SIZE + 2];
char m_aDisplayStr[MAX_SIZE + IInput::INPUT_TEXT_SIZE + 2];
int m_FakeLen;
int m_FakeCursorPos;
@ -48,7 +48,7 @@ public:
void SetRange(const char *pString, int Begin, int End);
void Insert(const char *pString, int Begin);
void Append(const char *pString);
const char *GetString(bool Editing = false) const { return Editing ? m_DisplayStr : m_aStr; }
const char *GetString(bool Editing = false) const { return Editing ? m_aDisplayStr : m_aStr; }
int GetLength(bool Editing = false) const { return Editing ? m_FakeLen : m_Len; }
int GetCursorOffset(bool Editing = false) const { return Editing ? m_FakeCursorPos : m_CursorPos; }
void SetCursorOffset(int Offset) { m_CursorPos = Offset > m_Len ? m_Len : Offset < 0 ? 0 : Offset; }