mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #4182
4182: add ctrl+backspace for ingame console r=def- a=BloodWod-513 <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: BloodWod-513 <dayn_2013@mail.ru>
This commit is contained in:
commit
c0cdfdac95
|
@ -117,7 +117,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
|
|||
if(m_pGameConsole->Input()->KeyIsPressed(KEY_LCTRL)) // jump to spaces and special ASCII characters
|
||||
{
|
||||
int SearchDirection = 0;
|
||||
if(m_pGameConsole->Input()->KeyPress(KEY_LEFT))
|
||||
if(m_pGameConsole->Input()->KeyPress(KEY_LEFT) || m_pGameConsole->Input()->KeyPress(KEY_BACKSPACE))
|
||||
SearchDirection = -1;
|
||||
else if(m_pGameConsole->Input()->KeyPress(KEY_RIGHT) || m_pGameConsole->Input()->KeyPress(KEY_DELETE))
|
||||
SearchDirection = 1;
|
||||
|
@ -142,6 +142,20 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
|
|||
}
|
||||
}
|
||||
|
||||
if(m_pGameConsole->Input()->KeyPress(KEY_BACKSPACE))
|
||||
{
|
||||
if(m_Input.GetCursorOffset() != 0)
|
||||
{
|
||||
char aText[512];
|
||||
str_copy(aText, m_Input.GetString(), FoundAt + 1);
|
||||
|
||||
if(m_Input.GetCursorOffset() != str_length(m_Input.GetString()))
|
||||
str_append(aText, m_Input.GetString() + m_Input.GetCursorOffset(), str_length(m_Input.GetString()));
|
||||
|
||||
m_Input.Set(aText);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_pGameConsole->Input()->KeyPress(KEY_DELETE))
|
||||
{
|
||||
if(m_Input.GetCursorOffset() != m_Input.GetLength())
|
||||
|
|
Loading…
Reference in a new issue