forked from qt-creator/qt-creator
Fixes: fakevim: suppress cursor when in ex mode
This commit is contained in:
@@ -201,7 +201,8 @@ private:
|
|||||||
int count() const { return mvCount() * opCount(); }
|
int count() const { return mvCount() * opCount(); }
|
||||||
int leftDist() const { return m_tc.position() - m_tc.block().position(); }
|
int leftDist() const { return m_tc.position() - m_tc.block().position(); }
|
||||||
int rightDist() const { return m_tc.block().length() - leftDist() - 1; }
|
int rightDist() const { return m_tc.block().length() - leftDist() - 1; }
|
||||||
bool atEndOfLine() const { return m_tc.atBlockEnd() && m_tc.block().length()>1; }
|
bool atEndOfLine() const
|
||||||
|
{ return m_tc.atBlockEnd() && m_tc.block().length() > 1; }
|
||||||
|
|
||||||
int lastPositionInDocument() const;
|
int lastPositionInDocument() const;
|
||||||
int positionForLine(int line) const; // 1 based line, 0 based pos
|
int positionForLine(int line) const; // 1 based line, 0 based pos
|
||||||
@@ -218,7 +219,7 @@ private:
|
|||||||
|
|
||||||
// helper functions for indenting
|
// helper functions for indenting
|
||||||
bool isElectricCharacter(QChar c) const
|
bool isElectricCharacter(QChar c) const
|
||||||
{ return (c == '{' || c == '}' || c == '#'); }
|
{ return c == '{' || c == '}' || c == '#'; }
|
||||||
int indentDist() const;
|
int indentDist() const;
|
||||||
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
||||||
void indentCurrentLine(QChar typedChar);
|
void indentCurrentLine(QChar typedChar);
|
||||||
@@ -251,6 +252,7 @@ private:
|
|||||||
|
|
||||||
void enterInsertMode();
|
void enterInsertMode();
|
||||||
void enterCommandMode();
|
void enterCommandMode();
|
||||||
|
void enterExMode();
|
||||||
void showRedMessage(const QString &msg);
|
void showRedMessage(const QString &msg);
|
||||||
void showBlackMessage(const QString &msg);
|
void showBlackMessage(const QString &msg);
|
||||||
void notImplementedYet();
|
void notImplementedYet();
|
||||||
@@ -340,6 +342,7 @@ public:
|
|||||||
int m_desiredColumn;
|
int m_desiredColumn;
|
||||||
|
|
||||||
QPointer<QObject> m_extraData;
|
QPointer<QObject> m_extraData;
|
||||||
|
int m_cursorWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
||||||
@@ -361,6 +364,7 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
|||||||
m_moveType = MoveInclusive;
|
m_moveType = MoveInclusive;
|
||||||
m_anchor = 0;
|
m_anchor = 0;
|
||||||
m_savedYankPosition = 0;
|
m_savedYankPosition = 0;
|
||||||
|
m_cursorWidth = EDITOR(cursorWidth());
|
||||||
|
|
||||||
m_config[ConfigStartOfLine] = ConfigOn;
|
m_config[ConfigStartOfLine] = ConfigOn;
|
||||||
m_config[ConfigTabStop] = "8";
|
m_config[ConfigTabStop] = "8";
|
||||||
@@ -419,17 +423,14 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
void FakeVimHandler::Private::setupWidget()
|
void FakeVimHandler::Private::setupWidget()
|
||||||
{
|
{
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
|
EDITOR(installEventFilter(q));
|
||||||
|
//EDITOR(setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||||
if (m_textedit) {
|
if (m_textedit) {
|
||||||
m_textedit->installEventFilter(q);
|
|
||||||
//m_textedit->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
|
||||||
m_textedit->setLineWrapMode(QTextEdit::NoWrap);
|
m_textedit->setLineWrapMode(QTextEdit::NoWrap);
|
||||||
m_wasReadOnly = m_textedit->isReadOnly();
|
|
||||||
} else if (m_plaintextedit) {
|
} else if (m_plaintextedit) {
|
||||||
m_plaintextedit->installEventFilter(q);
|
|
||||||
//plaintextedit->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
|
||||||
m_plaintextedit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
m_plaintextedit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||||
m_wasReadOnly = m_plaintextedit->isReadOnly();
|
|
||||||
}
|
}
|
||||||
|
m_wasReadOnly = EDITOR(isReadOnly());
|
||||||
showBlackMessage("vi emulation mode.");
|
showBlackMessage("vi emulation mode.");
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
}
|
}
|
||||||
@@ -438,13 +439,8 @@ void FakeVimHandler::Private::restoreWidget()
|
|||||||
{
|
{
|
||||||
//showBlackMessage(QString());
|
//showBlackMessage(QString());
|
||||||
//updateMiniBuffer();
|
//updateMiniBuffer();
|
||||||
if (m_textedit) {
|
EDITOR(removeEventFilter(q));
|
||||||
m_textedit->removeEventFilter(q);
|
EDITOR(setReadOnly(m_wasReadOnly));
|
||||||
m_textedit->setReadOnly(m_wasReadOnly);
|
|
||||||
} else if (m_plaintextedit) {
|
|
||||||
m_plaintextedit->removeEventFilter(q);
|
|
||||||
m_plaintextedit->setReadOnly(m_wasReadOnly);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text)
|
bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text)
|
||||||
|
@@ -50,14 +50,18 @@ int main(int argc, char *argv[])
|
|||||||
QString title;
|
QString title;
|
||||||
bool usePlainTextEdit = args.size() < 2;
|
bool usePlainTextEdit = args.size() < 2;
|
||||||
if (usePlainTextEdit) {
|
if (usePlainTextEdit) {
|
||||||
widget = new QPlainTextEdit;
|
QPlainTextEdit *w = new QPlainTextEdit;
|
||||||
|
w->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
title = "PlainTextEdit";
|
title = "PlainTextEdit";
|
||||||
|
widget = w;
|
||||||
} else {
|
} else {
|
||||||
widget = new QTextEdit;
|
QTextEdit *w = new QTextEdit;
|
||||||
|
w->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
title = "TextEdit";
|
title = "TextEdit";
|
||||||
|
widget = w;
|
||||||
}
|
}
|
||||||
widget->setObjectName("Editor");
|
widget->setObjectName("Editor");
|
||||||
widget->resize(450, 350);
|
//widget->resize(450, 350);
|
||||||
widget->setFocus();
|
widget->setFocus();
|
||||||
|
|
||||||
Proxy proxy(widget);
|
Proxy proxy(widget);
|
||||||
@@ -67,7 +71,7 @@ int main(int argc, char *argv[])
|
|||||||
QMainWindow mw;
|
QMainWindow mw;
|
||||||
mw.setWindowTitle("Fakevim (" + title + ")");
|
mw.setWindowTitle("Fakevim (" + title + ")");
|
||||||
mw.setCentralWidget(widget);
|
mw.setCentralWidget(widget);
|
||||||
mw.resize(500, 650);
|
mw.resize(600, 650);
|
||||||
mw.move(0, 0);
|
mw.move(0, 0);
|
||||||
mw.show();
|
mw.show();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user