📄 editorclientgtk.cpp
字号:
void EditorClient::redo(){ notImplemented();}bool EditorClient::shouldInsertNode(Node*, Range*, EditorInsertAction){ notImplemented(); return true;}void EditorClient::pageDestroyed(){ delete this;}bool EditorClient::smartInsertDeleteEnabled(){ notImplemented(); return false;}bool EditorClient::isSelectTrailingWhitespaceEnabled(){ notImplemented(); return false;}void EditorClient::toggleContinuousSpellChecking(){ notImplemented();}void EditorClient::toggleGrammarChecking(){}void EditorClient::handleKeyboardEvent(KeyboardEvent* event){ Frame* frame = core(m_webView)->focusController()->focusedOrMainFrame(); if (!frame || !frame->document()->focusedNode()) return; const PlatformKeyboardEvent* kevent = event->keyEvent(); if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) return; Node* start = frame->selection()->start().node(); if (!start) return; // FIXME: Use GtkBindingSet instead of this hard-coded switch // http://bugs.webkit.org/show_bug.cgi?id=15911 if (start->isContentEditable()) { switch (kevent->windowsVirtualKeyCode()) { case VK_BACK: frame->editor()->deleteWithDirection(SelectionController::BACKWARD, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, false, true); break; case VK_DELETE: frame->editor()->deleteWithDirection(SelectionController::FORWARD, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, false, true); break; case VK_LEFT: frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::LEFT, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, true); break; case VK_RIGHT: frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::RIGHT, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, true); break; case VK_UP: frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::BACKWARD, kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, true); break; case VK_DOWN: frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::FORWARD, kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, true); break; case VK_PRIOR: // PageUp frame->editor()->command(kevent->shiftKey() ? "MovePageUpAndModifySelection" : "MovePageUp").execute(); break; case VK_NEXT: // PageDown frame->editor()->command(kevent->shiftKey() ? "MovePageDownAndModifySelection" : "MovePageDown").execute(); break; case VK_HOME: if (kevent->ctrlKey() && kevent->shiftKey()) frame->editor()->command("MoveToBeginningOfDocumentAndModifySelection").execute(); else if (kevent->ctrlKey()) frame->editor()->command("MoveToBeginningOfDocument").execute(); else if (kevent->shiftKey()) frame->editor()->command("MoveToBeginningOfLineAndModifySelection").execute(); else frame->editor()->command("MoveToBeginningOfLine").execute(); break; case VK_END: if (kevent->ctrlKey() && kevent->shiftKey()) frame->editor()->command("MoveToEndOfDocumentAndModifySelection").execute(); else if (kevent->ctrlKey()) frame->editor()->command("MoveToEndOfDocument").execute(); else if (kevent->shiftKey()) frame->editor()->command("MoveToEndOfLineAndModifySelection").execute(); else frame->editor()->command("MoveToEndOfLine").execute(); break; case VK_RETURN: frame->editor()->command("InsertLineBreak").execute(); break; case VK_TAB: return; default: if (!kevent->ctrlKey() && !kevent->altKey() && !kevent->text().isEmpty()) { if (kevent->text().length() == 1) { UChar ch = kevent->text()[0]; // Don't insert null or control characters as they can result in unexpected behaviour if (ch < ' ') break; } frame->editor()->insertText(kevent->text(), event); } else if (kevent->ctrlKey()) { switch (kevent->windowsVirtualKeyCode()) { case VK_B: frame->editor()->command("ToggleBold").execute(); break; case VK_I: frame->editor()->command("ToggleItalic").execute(); break; case VK_Y: frame->editor()->command("Redo").execute(); break; case VK_Z: frame->editor()->command("Undo").execute(); break; default: return; } } else return; } } else { switch (kevent->windowsVirtualKeyCode()) { case VK_UP: frame->editor()->command("MoveUp").execute(); break; case VK_DOWN: frame->editor()->command("MoveDown").execute(); break; case VK_PRIOR: // PageUp frame->editor()->command("MovePageUp").execute(); break; case VK_NEXT: // PageDown frame->editor()->command("MovePageDown").execute(); break; case VK_HOME: if (kevent->ctrlKey()) frame->editor()->command("MoveToBeginningOfDocument").execute(); break; case VK_END: if (kevent->ctrlKey()) frame->editor()->command("MoveToEndOfDocument").execute(); break; default: return; } } event->setDefaultHandled();}void EditorClient::handleInputMethodKeydown(KeyboardEvent* event){ Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame(); if (!targetFrame || !targetFrame->editor()->canEdit()) return; WebKitWebViewPrivate* priv = m_webView->priv; // TODO: Dispatch IE-compatible text input events for IM events. if (gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey())) event->setDefaultHandled();}EditorClient::EditorClient(WebKitWebView* webView) : m_webView(webView){ WebKitWebViewPrivate* priv = m_webView->priv; g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this); g_signal_connect(priv->imContext, "preedit-changed", G_CALLBACK(imContextPreeditChanged), this);}EditorClient::~EditorClient(){ WebKitWebViewPrivate* priv = m_webView->priv; g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextCommitted, this); g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextPreeditChanged, this);}void EditorClient::textFieldDidBeginEditing(Element*){}void EditorClient::textFieldDidEndEditing(Element*){}void EditorClient::textDidChangeInTextField(Element*){}bool EditorClient::doTextFieldCommandFromEvent(Element*, KeyboardEvent*){ return false;}void EditorClient::textWillBeDeletedInTextField(Element*){ notImplemented();}void EditorClient::textDidChangeInTextArea(Element*){ notImplemented();}void EditorClient::ignoreWordInSpellDocument(const String&){ notImplemented();}void EditorClient::learnWord(const String&){ notImplemented();}void EditorClient::checkSpellingOfString(const UChar*, int, int*, int*){ notImplemented();}void EditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*){ notImplemented();}void EditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&){ notImplemented();}void EditorClient::updateSpellingUIWithMisspelledWord(const String&){ notImplemented();}void EditorClient::showSpellingUI(bool){ notImplemented();}bool EditorClient::spellingUIIsShowing(){ notImplemented(); return false;}void EditorClient::getGuessesForWord(const String&, Vector<String>&){ notImplemented();}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -