mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
replace DeleteUntilCursor and DeleteFromCursor with SetRange
This commit is contained in:
parent
dcdea25284
commit
d747edd1cf
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue