Merge pull request #1790 from ChillerDragon/pr_ctrl_k_console

Add ctrl-k delete in client console
This commit is contained in:
Dennis Felsing 2019-06-19 12:12:19 +02:00 committed by GitHub
commit 6e24bf9ae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -200,6 +200,10 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
{
m_Input.DeleteUntilCursor();
}
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_K))
{
m_Input.DeleteFromCursor();
}
if(Event.m_Flags&IInput::FLAG_PRESS)
{

View file

@ -149,6 +149,14 @@ void CLineInput::DeleteUntilCursor()
Set(aBuf); SetCursorOffset(0);
}
void CLineInput::DeleteFromCursor()
{
char aBuf[MAX_SIZE];
str_copy(aBuf, m_Str, sizeof(aBuf));
aBuf[m_CursorPos] = '\0';
Set(aBuf);
}
void CLineInput::ProcessInput(IInput::CEvent e)
{
Manipulate(e, m_Str, MAX_SIZE, MAX_CHARS, &m_Len, &m_CursorPos, &m_NumChars);

View file

@ -42,6 +42,7 @@ public:
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