Add ctrl-u delete in client console

Extends shortcuts from:
e9f8bd42b7
This commit is contained in:
ChillerDragon 2019-06-01 17:11:35 +02:00
parent e8b8a3c60a
commit ed8a0b5eee
3 changed files with 13 additions and 0 deletions

View file

@ -149,6 +149,11 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
{ {
m_Input.SetCursorOffset(m_Input.GetLength()); m_Input.SetCursorOffset(m_Input.GetLength());
} }
else if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL) && m_pGameConsole->Input()->KeyPress(KEY_U))
{
m_Input.DeleteFromCursor();
Handled = true;
}
if(Event.m_Flags&IInput::FLAG_PRESS) if(Event.m_Flags&IInput::FLAG_PRESS)
{ {

View file

@ -142,6 +142,13 @@ bool CLineInput::Manipulate(IInput::CEvent Event, char *pStr, int StrMaxSize, in
return Changes; return Changes;
} }
void CLineInput::DeleteFromCursor()
{
char aBuf[MAX_SIZE];
str_copy(aBuf, &m_Str[m_CursorPos], sizeof(aBuf));
Set(aBuf); SetCursorOffset(0);
}
void CLineInput::ProcessInput(IInput::CEvent e) void CLineInput::ProcessInput(IInput::CEvent e)
{ {
Manipulate(e, m_Str, MAX_SIZE, MAX_CHARS, &m_Len, &m_CursorPos, &m_NumChars); Manipulate(e, m_Str, MAX_SIZE, MAX_CHARS, &m_Len, &m_CursorPos, &m_NumChars);

View file

@ -41,6 +41,7 @@ public:
int GetLength(bool Editing = false) const { return Editing ? m_FakeLen : m_Len; } int GetLength(bool Editing = false) const { return Editing ? m_FakeLen : m_Len; }
int GetCursorOffset(bool Editing = false) const { return Editing ? m_FakeCursorPos : m_CursorPos; } 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 SetCursorOffset(int Offset) { m_CursorPos = Offset > m_Len ? m_Len : Offset < 0 ? 0 : Offset; }
void DeleteFromCursor();
}; };
#endif #endif