forked from qt-creator/qt-creator
Merge commit 'fred/fakevim-write'
This commit is contained in:
@@ -35,6 +35,10 @@
|
|||||||
|
|
||||||
#include "fakevimconstants.h"
|
#include "fakevimconstants.h"
|
||||||
|
|
||||||
|
#include <coreplugin/filemanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
@@ -220,6 +224,7 @@ public:
|
|||||||
bool m_wasReadOnly; // saves read-only state of document
|
bool m_wasReadOnly; // saves read-only state of document
|
||||||
|
|
||||||
FakeVimHandler *q;
|
FakeVimHandler *q;
|
||||||
|
Core::ICore *m_core;
|
||||||
Mode m_mode;
|
Mode m_mode;
|
||||||
SubMode m_submode;
|
SubMode m_submode;
|
||||||
SubSubMode m_subsubmode;
|
SubSubMode m_subsubmode;
|
||||||
@@ -239,6 +244,7 @@ public:
|
|||||||
|
|
||||||
QString m_commandBuffer;
|
QString m_commandBuffer;
|
||||||
QString m_currentFileName;
|
QString m_currentFileName;
|
||||||
|
Core::IFile* m_currentFile;
|
||||||
QString m_currentMessage;
|
QString m_currentMessage;
|
||||||
|
|
||||||
bool m_lastSearchForward;
|
bool m_lastSearchForward;
|
||||||
@@ -301,6 +307,8 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
|||||||
m_visualMode = NoVisualMode;
|
m_visualMode = NoVisualMode;
|
||||||
m_desiredColumn = 0;
|
m_desiredColumn = 0;
|
||||||
|
|
||||||
|
m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
|
||||||
|
|
||||||
m_config[ConfigStartOfLine] = ConfigOn;
|
m_config[ConfigStartOfLine] = ConfigOn;
|
||||||
m_config[ConfigTabStop] = "8";
|
m_config[ConfigTabStop] = "8";
|
||||||
m_config[ConfigSmartTab] = ConfigOff;
|
m_config[ConfigSmartTab] = ConfigOff;
|
||||||
@@ -1190,12 +1198,18 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
|||||||
bool exists = file.exists();
|
bool exists = file.exists();
|
||||||
if (exists && !forced && !noArgs) {
|
if (exists && !forced && !noArgs) {
|
||||||
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
|
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
|
||||||
} else if (file.open(QIODevice::ReadWrite)) {
|
} else if (m_currentFile || file.open(QIODevice::ReadWrite)) {
|
||||||
QTextCursor tc = selectRange(beginLine, endLine);
|
if(m_currentFile) {
|
||||||
qDebug() << "ANCHOR: " << tc.position() << tc.anchor()
|
m_core->fileManager()->blockFileChange(m_currentFile);
|
||||||
<< tc.selection().toPlainText();
|
m_currentFile->save(fileName);
|
||||||
{ QTextStream ts(&file); ts << tc.selection().toPlainText(); }
|
m_core->fileManager()->unblockFileChange(m_currentFile);
|
||||||
file.close();
|
} else {
|
||||||
|
QTextCursor tc = selectRange(beginLine, endLine);
|
||||||
|
qDebug() << "ANCHOR: " << tc.position() << tc.anchor()
|
||||||
|
<< tc.selection().toPlainText();
|
||||||
|
{ QTextStream ts(&file); ts << tc.selection().toPlainText(); }
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
QByteArray ba = file.readAll();
|
QByteArray ba = file.readAll();
|
||||||
showBlackMessage(tr("\"%1\" %2 %3L, %4C written")
|
showBlackMessage(tr("\"%1\" %2 %3L, %4C written")
|
||||||
@@ -1725,6 +1739,11 @@ void FakeVimHandler::Private::setWidget(QWidget *ob)
|
|||||||
{
|
{
|
||||||
m_textedit = qobject_cast<QTextEdit *>(ob);
|
m_textedit = qobject_cast<QTextEdit *>(ob);
|
||||||
m_plaintextedit = qobject_cast<QPlainTextEdit *>(ob);
|
m_plaintextedit = qobject_cast<QPlainTextEdit *>(ob);
|
||||||
|
TextEditor::BaseTextEditor* editor = qobject_cast<TextEditor::BaseTextEditor*>(ob);
|
||||||
|
if (editor) {
|
||||||
|
m_currentFile = editor->file();
|
||||||
|
m_currentFileName = m_currentFile->fileName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user