replace DeleteUntilCursor and DeleteFromCursor with SetRange

This commit is contained in:
Robert Müller 2021-11-24 23:44:11 +01:00
parent dcdea25284
commit d747edd1cf
3 changed files with 2 additions and 20 deletions

View file

@ -217,11 +217,11 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_U))
{
m_Input.DeleteUntilCursor();
m_Input.SetRange("", 0, m_Input.GetCursorOffset());
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_K))
{
m_Input.DeleteFromCursor();
m_Input.SetRange("", m_Input.GetCursorOffset(), m_Input.GetLength());
}
if(Event.m_Flags & IInput::FLAG_PRESS)

View file

@ -218,22 +218,6 @@ int32_t CLineInput::Manipulate(IInput::CEvent Event, char *pStr, int StrMaxSize,
return Changes;
}
void CLineInput::DeleteUntilCursor()
{
char aBuf[MAX_SIZE];
str_copy(aBuf, &m_aStr[m_CursorPos], sizeof(aBuf));
Set(aBuf);
SetCursorOffset(0);
}
void CLineInput::DeleteFromCursor()
{
char aBuf[MAX_SIZE];
str_copy(aBuf, m_aStr, sizeof(aBuf));
aBuf[m_CursorPos] = '\0';
Set(aBuf);
}
void CLineInput::ProcessInput(IInput::CEvent e)
{
Manipulate(e, m_aStr, MAX_SIZE, MAX_CHARS, &m_Len, &m_CursorPos, &m_NumChars, 0, 0);

View file

@ -52,8 +52,6 @@ public:
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; }
void DeleteUntilCursor();
void DeleteFromCursor();
};
#endif