mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Merge pull request #1790 from ChillerDragon/pr_ctrl_k_console
Add ctrl-k delete in client console
This commit is contained in:
commit
6e24bf9ae2
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue