mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Vim: double-click to enter Visual mode
This commit is contained in:
parent
837fb47d4d
commit
14ab49165e
@ -186,6 +186,8 @@ VVim::VVim(VEditor *p_editor)
|
||||
this, &VVim::handleMouseMoved);
|
||||
connect(m_editor->object(), &VEditorObject::mouseReleased,
|
||||
this, &VVim::handleMouseReleased);
|
||||
connect(m_editor->object(), &VEditorObject::mouseDoubleClicked,
|
||||
this, &VVim::handleMouseDoubleClicked);
|
||||
}
|
||||
|
||||
void VVim::initLeaderKey()
|
||||
@ -6357,12 +6359,17 @@ void VVim::amendCursorPosition()
|
||||
void VVim::handleMousePressed(QMouseEvent *p_event)
|
||||
{
|
||||
Q_UNUSED(p_event);
|
||||
QTextCursor cursor = m_editor->textCursorW();
|
||||
if ((checkMode(VimMode::Visual) || checkMode(VimMode::VisualLine))
|
||||
&& p_event->buttons() != Qt::RightButton) {
|
||||
setMode(VimMode::Normal);
|
||||
} else if (checkMode(VimMode::Normal)) {
|
||||
if (cursor.hasSelection()) {
|
||||
}
|
||||
}
|
||||
|
||||
void VVim::handleMouseDoubleClicked(QMouseEvent *p_event)
|
||||
{
|
||||
Q_UNUSED(p_event);
|
||||
if (checkMode(VimMode::Normal)) {
|
||||
if (m_editor->textCursorW().hasSelection()) {
|
||||
setMode(VimMode::Visual, false);
|
||||
maintainSelectionInVisualMode();
|
||||
}
|
||||
|
@ -251,6 +251,8 @@ private slots:
|
||||
|
||||
void handleMouseReleased(QMouseEvent *p_event);
|
||||
|
||||
void handleMouseDoubleClicked(QMouseEvent *p_event);
|
||||
|
||||
// When we display cursor as block, it makes no sense to put cursor at the
|
||||
// end of line.
|
||||
void amendCursorPosition();
|
||||
|
@ -598,6 +598,8 @@ signals:
|
||||
|
||||
void mouseReleased(QMouseEvent *p_event);
|
||||
|
||||
void mouseDoubleClicked(QMouseEvent *p_event);
|
||||
|
||||
void cursorPositionChanged();
|
||||
|
||||
private slots:
|
||||
|
@ -426,6 +426,13 @@ void VMdEditor::mousePressEvent(QMouseEvent *p_event)
|
||||
emit m_object->mousePressed(p_event);
|
||||
}
|
||||
|
||||
void VMdEditor::mouseDoubleClickEvent(QMouseEvent *p_event)
|
||||
{
|
||||
VTextEdit::mouseDoubleClickEvent(p_event);
|
||||
|
||||
emit m_object->mouseDoubleClicked(p_event);
|
||||
}
|
||||
|
||||
void VMdEditor::mouseReleaseEvent(QMouseEvent *p_event)
|
||||
{
|
||||
if (handleMouseReleaseEvent(p_event)) {
|
||||
|
@ -235,6 +235,8 @@ protected:
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
void mouseDoubleClickEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
bool canInsertFromMimeData(const QMimeData *p_source) const Q_DECL_OVERRIDE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user