mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #474 from Henningstone/pr-ddnet-chat-input-jump
Jump to special characters with CTRL+arrowkeys in chat input
This commit is contained in:
commit
fe3e05cee5
|
@ -150,6 +150,35 @@ bool CChat::OnInput(IInput::CEvent Event)
|
|||
Input()->SetClipboardText(m_Input.GetString());
|
||||
}
|
||||
|
||||
if(Input()->KeyIsPressed(KEY_LCTRL)) // jump to spaces and special ASCII characters
|
||||
{
|
||||
int SearchDirection = 0;
|
||||
if(Input()->KeyPress(KEY_LEFT))
|
||||
SearchDirection = -1;
|
||||
else if(Input()->KeyPress(KEY_RIGHT))
|
||||
SearchDirection = 1;
|
||||
|
||||
if(SearchDirection != 0)
|
||||
{
|
||||
int FoundAt = SearchDirection > 0 ? m_Input.GetLength()-1 : 0;
|
||||
for(int i = m_Input.GetCursorOffset()+SearchDirection; SearchDirection > 0 ? i < m_Input.GetLength()-1 : i > 0; i+=SearchDirection)
|
||||
{
|
||||
int next = i+SearchDirection;
|
||||
if( (m_Input.GetString()[next] == ' ') ||
|
||||
(m_Input.GetString()[next] >= 32 && m_Input.GetString()[next] <= 47) ||
|
||||
(m_Input.GetString()[next] >= 58 && m_Input.GetString()[next] <= 64) ||
|
||||
(m_Input.GetString()[next] >= 91 && m_Input.GetString()[next] <= 96) )
|
||||
{
|
||||
FoundAt = i;
|
||||
if(SearchDirection < 0)
|
||||
FoundAt++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_Input.SetCursorOffset(FoundAt);
|
||||
}
|
||||
}
|
||||
|
||||
if(Event.m_Flags&IInput::FLAG_PRESS && Event.m_Key == KEY_ESCAPE)
|
||||
{
|
||||
m_Mode = MODE_NONE;
|
||||
|
|
Loading…
Reference in a new issue