|
1 | 1 | #include <algorithm> |
2 | 2 | #include <string> |
3 | | -#include <cmath> |
4 | 3 | #include <set> |
5 | 4 |
|
6 | 5 | #include "TextEditor.h" |
@@ -2000,71 +1999,71 @@ void TextEditor::HandleKeyboardInputs(bool aParentIsFocused) |
2000 | 1999 | io.WantCaptureKeyboard = true; |
2001 | 2000 | io.WantTextInput = true; |
2002 | 2001 |
|
2003 | | - if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z))) |
| 2002 | + if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGuiKey_Z)) |
2004 | 2003 | Undo(); |
2005 | | - else if (!mReadOnly && isAltOnly && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) |
| 2004 | + else if (!mReadOnly && isAltOnly && ImGui::IsKeyPressed(ImGuiKey_Backspace)) |
2006 | 2005 | Undo(); |
2007 | | - else if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Y))) |
| 2006 | + else if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGuiKey_Y)) |
2008 | 2007 | Redo(); |
2009 | | - else if (!mReadOnly && isShiftShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z))) |
| 2008 | + else if (!mReadOnly && isShiftShortcut && ImGui::IsKeyPressed(ImGuiKey_Z)) |
2010 | 2009 | Redo(); |
2011 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) |
| 2010 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) |
2012 | 2011 | MoveUp(1, shift); |
2013 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) |
| 2012 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) |
2014 | 2013 | MoveDown(1, shift); |
2015 | | - else if ((isOSX ? !ctrl : !alt) && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow))) |
| 2014 | + else if ((isOSX ? !ctrl : !alt) && !super && ImGui::IsKeyPressed(ImGuiKey_LeftArrow)) |
2016 | 2015 | MoveLeft(shift, isWordmoveKey); |
2017 | | - else if ((isOSX ? !ctrl : !alt) && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow))) |
| 2016 | + else if ((isOSX ? !ctrl : !alt) && !super && ImGui::IsKeyPressed(ImGuiKey_RightArrow)) |
2018 | 2017 | MoveRight(shift, isWordmoveKey); |
2019 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp))) |
| 2018 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_PageUp)) |
2020 | 2019 | MoveUp(mVisibleLineCount - 2, shift); |
2021 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown))) |
| 2020 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_PageDown)) |
2022 | 2021 | MoveDown(mVisibleLineCount - 2, shift); |
2023 | | - else if (ctrl && !alt && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) |
| 2022 | + else if (ctrl && !alt && !super && ImGui::IsKeyPressed(ImGuiKey_Home)) |
2024 | 2023 | MoveTop(shift); |
2025 | | - else if (ctrl && !alt && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) |
| 2024 | + else if (ctrl && !alt && !super && ImGui::IsKeyPressed(ImGuiKey_End)) |
2026 | 2025 | MoveBottom(shift); |
2027 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) |
| 2026 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_Home)) |
2028 | 2027 | MoveHome(shift); |
2029 | | - else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) |
| 2028 | + else if (!alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_End)) |
2030 | 2029 | MoveEnd(shift); |
2031 | | - else if (!mReadOnly && !alt && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) |
| 2030 | + else if (!mReadOnly && !alt && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_Delete)) |
2032 | 2031 | Delete(ctrl); |
2033 | | - else if (!mReadOnly && !alt && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) |
| 2032 | + else if (!mReadOnly && !alt && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_Backspace)) |
2034 | 2033 | Backspace(ctrl); |
2035 | | - else if (!mReadOnly && !alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_K))) |
| 2034 | + else if (!mReadOnly && !alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGuiKey_K)) |
2036 | 2035 | RemoveCurrentLines(); |
2037 | | - else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftBracket))) |
| 2036 | + else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_LeftBracket)) |
2038 | 2037 | ChangeCurrentLinesIndentation(false); |
2039 | | - else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightBracket))) |
| 2038 | + else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_RightBracket)) |
2040 | 2039 | ChangeCurrentLinesIndentation(true); |
2041 | | - else if (!alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) |
| 2040 | + else if (!alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) |
2042 | 2041 | MoveUpCurrentLines(); |
2043 | | - else if (!alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) |
| 2042 | + else if (!alt && ctrl && shift && !super && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) |
2044 | 2043 | MoveDownCurrentLines(); |
2045 | | - else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Slash))) |
| 2044 | + else if (!mReadOnly && !alt && ctrl && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_Slash)) |
2046 | 2045 | ToggleLineComment(); |
2047 | | - else if (!alt && !ctrl && !shift && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) |
| 2046 | + else if (!alt && !ctrl && !shift && !super && ImGui::IsKeyPressed(ImGuiKey_Insert)) |
2048 | 2047 | mOverwrite ^= true; |
2049 | | - else if (isCtrlOnly && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) |
| 2048 | + else if (isCtrlOnly && ImGui::IsKeyPressed(ImGuiKey_Insert)) |
2050 | 2049 | Copy(); |
2051 | | - else if (isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C))) |
| 2050 | + else if (isShortcut && ImGui::IsKeyPressed(ImGuiKey_C)) |
2052 | 2051 | Copy(); |
2053 | | - else if (!mReadOnly && isShiftOnly && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) |
| 2052 | + else if (!mReadOnly && isShiftOnly && ImGui::IsKeyPressed(ImGuiKey_Insert)) |
2054 | 2053 | Paste(); |
2055 | | - else if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V))) |
| 2054 | + else if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGuiKey_V)) |
2056 | 2055 | Paste(); |
2057 | | - else if (isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X))) |
| 2056 | + else if (isShortcut && ImGui::IsKeyPressed(ImGuiKey_X)) |
2058 | 2057 | Cut(); |
2059 | | - else if (isShiftOnly && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) |
| 2058 | + else if (isShiftOnly && ImGui::IsKeyPressed(ImGuiKey_Delete)) |
2060 | 2059 | Cut(); |
2061 | | - else if (isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_A))) |
| 2060 | + else if (isShortcut && ImGui::IsKeyPressed(ImGuiKey_A)) |
2062 | 2061 | SelectAll(); |
2063 | | - else if (isShortcut && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_D))) |
| 2062 | + else if (isShortcut && ImGui::IsKeyPressed(ImGuiKey_D)) |
2064 | 2063 | AddCursorForNextOccurrence(); |
2065 | | - else if (!mReadOnly && !alt && !ctrl && !shift && !super && (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_KeypadEnter)))) |
| 2064 | + else if (!mReadOnly && !alt && !ctrl && !shift && !super && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter))) |
2066 | 2065 | EnterCharacter('\n', false); |
2067 | | - else if (!mReadOnly && !alt && !ctrl && !super && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Tab))) |
| 2066 | + else if (!mReadOnly && !alt && !ctrl && !super && ImGui::IsKeyPressed(ImGuiKey_Tab)) |
2068 | 2067 | EnterCharacter('\t', shift); |
2069 | 2068 | if (!mReadOnly && !io.InputQueueCharacters.empty() && ctrl == alt && !super) |
2070 | 2069 | { |
|
0 commit comments