Skip to content
Snippets Groups Projects
Commit 9d8fc287 authored by hjk's avatar hjk
Browse files

Fixes: fakevim: show column/line information in standalone application

parent ac8ed036
No related branches found
No related tags found
No related merge requests found
......@@ -893,6 +893,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveDown(qMax(count() - 1, 0));
moveRight(rightDist());
finishMovement();
} else if (key == control('d')) {
int sline = cursorLineOnScreen();
// FIXME: this should use the "scroll" option, and "count"
moveDown(linesOnScreen() / 2);
moveToFirstNonBlankOnLine();
scrollToLineInDocument(cursorLineInDocument() - sline);
finishMovement();
} else if (key == 'e') {
m_moveType = MoveInclusive;
moveToWordBoundary(false, true);
......@@ -1068,6 +1075,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
// FIXME: this is non-vim, but as Ctrl-R is taken globally
// we have a substitute here
redo();
} else if (key == control('u')) {
int sline = cursorLineOnScreen();
// FIXME: this should use the "scroll" option, and "count"
moveUp(linesOnScreen() / 2);
moveToFirstNonBlankOnLine();
scrollToLineInDocument(cursorLineInDocument() - sline);
finishMovement();
} else if (key == 'v') {
enterVisualMode(VisualCharMode);
} else if (key == 'V') {
......@@ -1137,20 +1151,6 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
}
recordInsertText(str);
recordEndGroup();
} else if (key == control('d')) {
int sline = cursorLineOnScreen();
// FIXME: this should use the "scroll" option, and "count"
moveDown(linesOnScreen() / 2);
moveToFirstNonBlankOnLine();
scrollToLineInDocument(cursorLineInDocument() - sline);
finishMovement();
} else if (key == control('u')) {
int sline = cursorLineOnScreen();
// FIXME: this should use the "scroll" option, and "count"
moveUp(linesOnScreen() / 2);
moveToFirstNonBlankOnLine();
scrollToLineInDocument(cursorLineInDocument() - sline);
finishMovement();
} else if (key == Key_PageDown || key == control('f')) {
moveDown(count() * (linesOnScreen() - 2));
finishMovement();
......@@ -1588,6 +1588,7 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
if (EDITOR(find(needle, flags))) {
m_tc = EDITOR(textCursor());
m_tc.setPosition(m_tc.anchor());
// making this unconditional feels better, but is not "vim like"
if (oldLine != cursorLineInDocument() - cursorLineOnScreen())
scrollToLineInDocument(cursorLineInDocument() - linesOnScreen() / 2);
return;
......
......@@ -17,8 +17,8 @@ class Proxy : public QObject
Q_OBJECT
public:
Proxy(QWidget *widget, QObject *parent = 0)
: QObject(parent), m_widget(widget)
Proxy(QWidget *widget, QMainWindow *mw, QObject *parent = 0)
: QObject(parent), m_widget(widget), m_mainWindow(mw)
{}
public slots:
......@@ -30,13 +30,35 @@ public slots:
ed->setExtraSelections(s);
}
void changeStatusData(const QString &info)
{
m_statusData = info;
updateStatusBar();
}
void changeStatusMessage(const QString &info)
{
m_statusMessage = info;
updateStatusBar();
}
void changeExtraInformation(const QString &info)
{
QMessageBox::information(m_widget, "Information", info);
}
void updateStatusBar()
{
int slack = 80 - m_statusMessage.size() - m_statusData.size();
QString msg = m_statusMessage + QString(slack, QChar(' ')) + m_statusData;
m_mainWindow->statusBar()->showMessage(msg);
}
private:
QWidget *m_widget;
QMainWindow *m_mainWindow;
QString m_statusMessage;
QString m_statusData;
};
int main(int argc, char *argv[])
......@@ -64,11 +86,11 @@ int main(int argc, char *argv[])
//widget->resize(450, 350);
widget->setFocus();
Proxy proxy(widget);
QMainWindow mw;
Proxy proxy(widget, &mw);
FakeVimHandler handler(widget, 0);
QMainWindow mw;
mw.setWindowTitle("Fakevim (" + title + ")");
mw.setCentralWidget(widget);
mw.resize(600, 650);
......@@ -85,15 +107,16 @@ int main(int argc, char *argv[])
mw.statusBar()->setFont(font);
QObject::connect(&handler, SIGNAL(commandBufferChanged(QString)),
mw.statusBar(), SLOT(showMessage(QString)));
&proxy, SLOT(changeStatusMessage(QString)));
QObject::connect(&handler, SIGNAL(quitRequested()),
&app, SLOT(quit()));
QObject::connect(&handler,
SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
&proxy, SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
QObject::connect(&handler,
SIGNAL(extraInformationChanged(QString)),
QObject::connect(&handler, SIGNAL(extraInformationChanged(QString)),
&proxy, SLOT(changeExtraInformation(QString)));
QObject::connect(&handler, SIGNAL(statusDataChanged(QString)),
&proxy, SLOT(changeStatusData(QString)));
handler.setupWidget();
if (args.size() >= 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment