forked from qt-creator/qt-creator
Fixes: fakwvim: fix recently broken selection in standalone application
This commit is contained in:
@@ -158,6 +158,13 @@ QDebug &operator<<(QDebug &ts, const EditOperation &op)
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDebug &operator<<(QDebug &ts, const QList<QTextEdit::ExtraSelection> &sels)
|
||||||
|
{
|
||||||
|
foreach (QTextEdit::ExtraSelection sel, sels)
|
||||||
|
ts << "SEL: " << sel.cursor.anchor() << sel.cursor.position();
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
int lineCount(const QString &text)
|
int lineCount(const QString &text)
|
||||||
{
|
{
|
||||||
//return text.count(QChar(ParagraphSeparator));
|
//return text.count(QChar(ParagraphSeparator));
|
||||||
@@ -456,6 +463,7 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
|
|||||||
|
|
||||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ANCHOR: " << m_anchor;
|
||||||
if (m_submode == FilterSubMode) {
|
if (m_submode == FilterSubMode) {
|
||||||
int beginLine = lineForPosition(anchor());
|
int beginLine = lineForPosition(anchor());
|
||||||
int endLine = lineForPosition(position());
|
int endLine = lineForPosition(position());
|
||||||
@@ -526,10 +534,13 @@ void FakeVimHandler::Private::updateSelection()
|
|||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
sel.cursor = m_tc;
|
sel.cursor = m_tc;
|
||||||
sel.format = m_tc.blockCharFormat();
|
sel.format = m_tc.blockCharFormat();
|
||||||
//sel.format.setFontWeight(QFont::Bold);
|
#if 0
|
||||||
//sel.format.setFontUnderline(true);
|
sel.format.setFontWeight(QFont::Bold);
|
||||||
|
sel.format.setFontUnderline(true);
|
||||||
|
#else
|
||||||
sel.format.setForeground(Qt::white);
|
sel.format.setForeground(Qt::white);
|
||||||
sel.format.setBackground(Qt::black);
|
sel.format.setBackground(Qt::black);
|
||||||
|
#endif
|
||||||
int cursorPos = m_tc.position();
|
int cursorPos = m_tc.position();
|
||||||
int anchorPos = m_marks['<'];
|
int anchorPos = m_marks['<'];
|
||||||
//qDebug() << "POS: " << cursorPos << " ANCHOR: " << anchorPos;
|
//qDebug() << "POS: " << cursorPos << " ANCHOR: " << anchorPos;
|
||||||
@@ -566,6 +577,7 @@ void FakeVimHandler::Private::updateSelection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//qDebug() << "SELECTION: " << selections;
|
||||||
emit q->selectionChanged(selections);
|
emit q->selectionChanged(selections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,7 +846,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
} else if (key == 'd') {
|
} else if (key == 'd') {
|
||||||
setAnchor();
|
//setAnchor();
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
int beginLine = lineForPosition(m_marks['<']);
|
int beginLine = lineForPosition(m_marks['<']);
|
||||||
int endLine = lineForPosition(m_marks['>']);
|
int endLine = lineForPosition(m_marks['>']);
|
||||||
@@ -1819,6 +1831,7 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
|
|||||||
|
|
||||||
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
|
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
|
||||||
{
|
{
|
||||||
|
setAnchor();
|
||||||
m_visualMode = visualMode;
|
m_visualMode = visualMode;
|
||||||
m_marks['<'] = m_tc.position();
|
m_marks['<'] = m_tc.position();
|
||||||
m_marks['>'] = m_tc.position();
|
m_marks['>'] = m_tc.position();
|
||||||
|
@@ -258,8 +258,9 @@ void FakeVimPluginPrivate::removeHandler()
|
|||||||
|
|
||||||
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(editor);
|
||||||
//qDebug() << "OPENING: " << editor << editor->widget();
|
//qDebug() << "OPENING: " << editor << editor->widget();
|
||||||
installHandler(editor);
|
//installHandler(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
||||||
|
@@ -24,9 +24,9 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void changeSelection(const QList<QTextEdit::ExtraSelection> &s)
|
void changeSelection(const QList<QTextEdit::ExtraSelection> &s)
|
||||||
{
|
{
|
||||||
if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(sender()))
|
if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(m_widget))
|
||||||
ed->setExtraSelections(s);
|
ed->setExtraSelections(s);
|
||||||
else if (QTextEdit *ed = qobject_cast<QTextEdit *>(sender()))
|
else if (QTextEdit *ed = qobject_cast<QTextEdit *>(m_widget))
|
||||||
ed->setExtraSelections(s);
|
ed->setExtraSelections(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user