| @@ -91,23 +91,23 @@ void TextField::onSelectKey(const event::SelectKey& e) { | |||
| } | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_LEFT && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| else if (e.key == GLFW_KEY_LEFT) { | |||
| if (e.mods & RACK_MOD_CTRL) { | |||
| while (--cursor > 0) { | |||
| if (text[cursor] == ' ') | |||
| if (text[cursor - 1] == ' ') | |||
| break; | |||
| } | |||
| } | |||
| else { | |||
| cursor--; | |||
| } | |||
| if ((e.mods & RACK_MOD_MASK) == 0) { | |||
| if (!(e.mods & GLFW_MOD_SHIFT)) { | |||
| selection = cursor; | |||
| } | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_RIGHT && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| else if (e.key == GLFW_KEY_RIGHT) { | |||
| if (e.mods & RACK_MOD_CTRL) { | |||
| while (++cursor < (int) text.size()) { | |||
| if (text[cursor] == ' ') | |||
| break; | |||
| @@ -116,7 +116,7 @@ void TextField::onSelectKey(const event::SelectKey& e) { | |||
| else { | |||
| cursor++; | |||
| } | |||
| if ((e.mods & RACK_MOD_MASK) == 0) { | |||
| if (!(e.mods & GLFW_MOD_SHIFT)) { | |||
| selection = cursor; | |||
| } | |||
| e.consume(this); | |||
| @@ -125,45 +125,45 @@ void TextField::onSelectKey(const event::SelectKey& e) { | |||
| selection = cursor = 0; | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_HOME && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| cursor = 0; | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_END && (e.mods & RACK_MOD_MASK) == 0) { | |||
| selection = cursor = text.size(); | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_V && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| const char* newText = glfwGetClipboardString(APP->window->win); | |||
| if (newText) | |||
| insertText(newText); | |||
| } | |||
| else if (e.key == GLFW_KEY_END && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| cursor = text.size(); | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_X && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| if (cursor != selection) { | |||
| int begin = std::min(cursor, selection); | |||
| std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | |||
| glfwSetClipboardString(APP->window->win, selectedText.c_str()); | |||
| insertText(""); | |||
| } | |||
| } | |||
| else if (e.key == GLFW_KEY_V && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| const char* newText = glfwGetClipboardString(APP->window->win); | |||
| if (newText) | |||
| insertText(newText); | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_C && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| if (cursor != selection) { | |||
| int begin = std::min(cursor, selection); | |||
| std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | |||
| glfwSetClipboardString(APP->window->win, selectedText.c_str()); | |||
| } | |||
| else if (e.key == GLFW_KEY_X && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| if (cursor != selection) { | |||
| int begin = std::min(cursor, selection); | |||
| std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | |||
| glfwSetClipboardString(APP->window->win, selectedText.c_str()); | |||
| insertText(""); | |||
| } | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_A && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| selectAll(); | |||
| else if (e.key == GLFW_KEY_C && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| if (cursor != selection) { | |||
| int begin = std::min(cursor, selection); | |||
| std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | |||
| glfwSetClipboardString(APP->window->win, selectedText.c_str()); | |||
| } | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_A && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| selectAll(); | |||
| e.consume(this); | |||
| } | |||
| else if (e.key == GLFW_KEY_ENTER && (e.mods & RACK_MOD_MASK) == 0) { | |||
| if (multiline) { | |||
| insertText("\n"); | |||