Merge commit 'origin/1.1' into 1.1

This commit is contained in:
dt
2009-04-16 15:26:53 +02:00
17 changed files with 439 additions and 217 deletions

View File

@@ -202,11 +202,12 @@ QT_END_NAMESPACE
#endif // PRIVATE_OBJECT_ALLOWED #endif // PRIVATE_OBJECT_ALLOWED
// this can be mangled typenames of nested templates, each char-by-char // This can be mangled typenames of nested templates, each char-by-char
// comma-separated integer list // comma-separated integer list...
static char qDumpInBuffer[10000]; Q_DECL_EXPORT char qDumpInBuffer[10000];
static char qDumpOutBuffer[100000];
//static char qDumpSize[20]; // The output buffer.
Q_DECL_EXPORT char qDumpOutBuffer[100000];
namespace { namespace {
@@ -2524,7 +2525,7 @@ static void handleProtocolVersion2and3(QDumper & d)
extern "C" Q_DECL_EXPORT extern "C" Q_DECL_EXPORT
void qDumpObjectData440( void *qDumpObjectData440(
int protocolVersion, int protocolVersion,
int token, int token,
void *data, void *data,
@@ -2629,4 +2630,5 @@ void qDumpObjectData440(
else { else {
qDebug() << "Unsupported protocol version" << protocolVersion; qDebug() << "Unsupported protocol version" << protocolVersion;
} }
return qDumpOutBuffer;
} }

View File

@@ -453,7 +453,7 @@ void FileManager::changedFile(const QString &file)
foreach (IFile *fileinterface, managedFiles(file)) foreach (IFile *fileinterface, managedFiles(file))
m_changedFiles << fileinterface; m_changedFiles << fileinterface;
if (wasempty && !m_changedFiles.isEmpty()) { if (wasempty && !m_changedFiles.isEmpty()) {
QTimer::singleShot (200, this, SLOT(checkForReload())); QTimer::singleShot(200, this, SLOT(checkForReload()));
} }
} }

View File

@@ -1070,11 +1070,14 @@ static const char *settingsGroup = "MainWindow";
static const char *geometryKey = "Geometry"; static const char *geometryKey = "Geometry";
static const char *colorKey = "Color"; static const char *colorKey = "Color";
static const char *maxKey = "Maximized"; static const char *maxKey = "Maximized";
static const char *fullScreenKey = "FullScreen";
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
m_settings->beginGroup(QLatin1String(settingsGroup)); m_settings->beginGroup(QLatin1String(settingsGroup));
StyleHelper::setBaseColor(m_settings->value(QLatin1String(colorKey)).value<QColor>()); StyleHelper::setBaseColor(m_settings->value(QLatin1String(colorKey)).value<QColor>());
const QVariant geom = m_settings->value(QLatin1String(geometryKey)); const QVariant geom = m_settings->value(QLatin1String(geometryKey));
if (geom.isValid()) { if (geom.isValid()) {
setGeometry(geom.toRect()); setGeometry(geom.toRect());
@@ -1083,8 +1086,10 @@ void MainWindow::readSettings()
} }
if (m_settings->value(QLatin1String(maxKey), false).toBool()) if (m_settings->value(QLatin1String(maxKey), false).toBool())
setWindowState(Qt::WindowMaximized); setWindowState(Qt::WindowMaximized);
setFullScreen(m_settings->value(QLatin1String(fullScreenKey), false).toBool());
m_settings->endGroup(); m_settings->endGroup();
m_editorManager->readSettings(m_settings); m_editorManager->readSettings(m_settings);
m_navigationWidget->restoreSettings(m_settings); m_navigationWidget->restoreSettings(m_settings);
m_rightPaneWidget->readSettings(m_settings); m_rightPaneWidget->readSettings(m_settings);
@@ -1093,14 +1098,18 @@ void MainWindow::readSettings()
void MainWindow::writeSettings() void MainWindow::writeSettings()
{ {
m_settings->beginGroup(QLatin1String(settingsGroup)); m_settings->beginGroup(QLatin1String(settingsGroup));
m_settings->setValue(colorKey, StyleHelper::baseColor());
const QString maxSettingsKey = QLatin1String(maxKey); m_settings->setValue(QLatin1String(colorKey), StyleHelper::baseColor());
if (windowState() & Qt::WindowMaximized) {
m_settings->setValue(maxSettingsKey, true); if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
m_settings->setValue(QLatin1String(maxKey), (bool) (windowState() & Qt::WindowMaximized));
m_settings->setValue(QLatin1String(fullScreenKey), (bool) (windowState() & Qt::WindowFullScreen));
} else { } else {
m_settings->setValue(maxSettingsKey, false); m_settings->setValue(QLatin1String(maxKey), false);
m_settings->setValue(QLatin1String(fullScreenKey), false);
m_settings->setValue(QLatin1String(geometryKey), geometry()); m_settings->setValue(QLatin1String(geometryKey), geometry());
} }
m_settings->endGroup(); m_settings->endGroup();
m_fileManager->saveRecentFiles(); m_fileManager->saveRecentFiles();
@@ -1209,7 +1218,7 @@ QPrinter *MainWindow::printer() const
{ {
if (!m_printer) if (!m_printer)
m_printer = new QPrinter(QPrinter::HighResolution); m_printer = new QPrinter(QPrinter::HighResolution);
return m_printer; return m_printer;
} }
void MainWindow::setFullScreen(bool on) void MainWindow::setFullScreen(bool on)

View File

@@ -158,7 +158,7 @@ DebuggerSettings *DebuggerSettings::instance()
instance->insertItem(UseDebuggingHelpers, item); instance->insertItem(UseDebuggingHelpers, item);
item->setDefaultValue(true); item->setDefaultValue(true);
item->setSettingsKey("DebugMode", "UseDebuggingHelper"); item->setSettingsKey("DebugMode", "UseDebuggingHelper");
item->setText(tr("Use Debugging Helper")); item->setText(tr("Use debugging helper"));
item->setCheckable(true); item->setCheckable(true);
item->setDefaultValue(true); item->setDefaultValue(true);

View File

@@ -103,6 +103,7 @@ enum GdbCommandType
GdbQuerySources, GdbQuerySources,
GdbAsyncOutput2, GdbAsyncOutput2,
GdbStart, GdbStart,
GdbExit,
GdbAttached, GdbAttached,
GdbStubAttached, GdbStubAttached,
GdbExecRun, GdbExecRun,
@@ -755,6 +756,9 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type,
case GdbInfoThreads: case GdbInfoThreads:
handleInfoThreads(record); handleInfoThreads(record);
break; break;
case GdbExit:
handleExit(record);
break;
case GdbShowVersion: case GdbShowVersion:
handleShowVersion(record); handleShowVersion(record);
@@ -1167,7 +1171,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
+ data.findChild("signal-name").toString(); + data.findChild("signal-name").toString();
} }
q->showStatusMessage(msg); q->showStatusMessage(msg);
sendCommand("-gdb-exit"); sendCommand("-gdb-exit", GdbExit);
return; return;
} }
@@ -1525,7 +1529,7 @@ void GdbEngine::exitDebugger()
sendCommand("detach"); sendCommand("detach");
else else
sendCommand("kill"); sendCommand("kill");
sendCommand("-gdb-exit"); sendCommand("-gdb-exit", GdbExit);
// 20s can easily happen when loading webkit debug information // 20s can easily happen when loading webkit debug information
m_gdbProc.waitForFinished(20000); m_gdbProc.waitForFinished(20000);
if (m_gdbProc.state() != QProcess::Running) { if (m_gdbProc.state() != QProcess::Running) {
@@ -1797,6 +1801,12 @@ void GdbEngine::handleAttach()
qq->reloadRegisters(); qq->reloadRegisters();
} }
void GdbEngine::handleExit(const GdbResultRecord &response)
{
Q_UNUSED(response);
q->showStatusMessage(tr("Debugger exited."));
}
void GdbEngine::stepExec() void GdbEngine::stepExec()
{ {
setTokenBarrier(); setTokenBarrier();
@@ -2210,6 +2220,11 @@ void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointData *
// within namespaces. // within namespaces.
// Sometimes the path is relative too. // Sometimes the path is relative too.
// 2 breakpoint keep y <MULTIPLE> 0x0040168e
// 2.1 y 0x0040168e in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
// 2.2 y 0x00401792 in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
// tested in ../../../tests/auto/debugger/
QRegExp re("MULTIPLE.*(0x[0-9a-f]+) in (.*)\\s+at (.*):([\\d]+)([^\\d]|$)"); QRegExp re("MULTIPLE.*(0x[0-9a-f]+) in (.*)\\s+at (.*):([\\d]+)([^\\d]|$)");
re.setMinimal(true); re.setMinimal(true);
@@ -2218,6 +2233,10 @@ void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointData *
data->bpFuncName = re.cap(2).trimmed(); data->bpFuncName = re.cap(2).trimmed();
data->bpLineNumber = re.cap(4); data->bpLineNumber = re.cap(4);
QString full = fullName(re.cap(3)); QString full = fullName(re.cap(3));
if (full.isEmpty()) {
qDebug() << "NO FULL NAME KNOWN FOR" << re.cap(3);
full = re.cap(3); // FIXME: wrong, but prevents recursion
}
data->markerLineNumber = data->bpLineNumber.toInt(); data->markerLineNumber = data->bpLineNumber.toInt();
data->markerFileName = full; data->markerFileName = full;
data->bpFileName = full; data->bpFileName = full;
@@ -3400,14 +3419,15 @@ void GdbEngine::handleQueryDebuggingHelper(const GdbResultRecord &record)
m_availableSimpleDebuggingHelpers.append(item.data()); m_availableSimpleDebuggingHelpers.append(item.data());
if (m_availableSimpleDebuggingHelpers.isEmpty()) { if (m_availableSimpleDebuggingHelpers.isEmpty()) {
m_debuggingHelperState = DebuggingHelperUnavailable; m_debuggingHelperState = DebuggingHelperUnavailable;
QMessageBox::warning(q->mainWindow(), q->showStatusMessage(tr("Debugging helpers not found."));
tr("Cannot find special data dumpers"), //QMessageBox::warning(q->mainWindow(),
tr("The debugged binary does not contain information needed for " // tr("Cannot find special data dumpers"),
"nice display of Qt data types.\n\n" // tr("The debugged binary does not contain information needed for "
"You might want to try including the file\n\n" // "nice display of Qt data types.\n\n"
".../share/qtcreator/gdbmacros/gdbmacros.cpp\n\n" // "You might want to try including the file\n\n"
"into your project directly.") // ".../share/qtcreator/gdbmacros/gdbmacros.cpp\n\n"
); // "into your project directly.")
// );
} else { } else {
m_debuggingHelperState = DebuggingHelperAvailable; m_debuggingHelperState = DebuggingHelperAvailable;
q->showStatusMessage(tr("%1 custom dumpers found.") q->showStatusMessage(tr("%1 custom dumpers found.")
@@ -4151,10 +4171,10 @@ void GdbEngine::tryLoadDebuggingHelpers()
QString flag = QString::number(RTLD_NOW); QString flag = QString::number(RTLD_NOW);
sendCommand("sharedlibrary libc"); // for malloc sendCommand("sharedlibrary libc"); // for malloc
sendCommand("sharedlibrary libdl"); // for dlopen sendCommand("sharedlibrary libdl"); // for dlopen
sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", sendCommand("call (void*)dlopen(\"" + lib + "\", " + flag + ")",
WatchDebuggingHelperSetup); WatchDebuggingHelperSetup);
// some older systems like CentOS 4.6 prefer this: // some older systems like CentOS 4.6 prefer this:
sendCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", sendCommand("call (void*)__dlopen(\"" + lib + "\", " + flag + ")",
WatchDebuggingHelperSetup); WatchDebuggingHelperSetup);
sendCommand("sharedlibrary " + dotEscape(lib)); sendCommand("sharedlibrary " + dotEscape(lib));
#endif #endif

View File

@@ -199,6 +199,7 @@ private:
void handleQueryPwd(const GdbResultRecord &response); void handleQueryPwd(const GdbResultRecord &response);
void handleQuerySources(const GdbResultRecord &response); void handleQuerySources(const GdbResultRecord &response);
void handleTargetCore(const GdbResultRecord &response); void handleTargetCore(const GdbResultRecord &response);
void handleExit(const GdbResultRecord &response);
void debugMessage(const QString &msg); void debugMessage(const QString &msg);
QString dumperLibraryName() const; QString dumperLibraryName() const;

View File

@@ -932,7 +932,6 @@ QString WatchHandler::watcherName(const QString &exp)
void WatchHandler::watchExpression(const QString &exp) void WatchHandler::watchExpression(const QString &exp)
{ {
// FIXME: 'exp' can contain illegal characters // FIXME: 'exp' can contain illegal characters
//MODEL_DEBUG("WATCH: " << exp);
m_watchers[exp] = watcherCounter++; m_watchers[exp] = watcherCounter++;
WatchData data; WatchData data;
data.exp = exp; data.exp = exp;

View File

@@ -96,7 +96,7 @@ public:
} else if (index.column() == 0) { } else if (index.column() == 0) {
// the watcher name column // the watcher name column
theDebuggerAction(RemoveWatchExpression)->trigger(exp); theDebuggerAction(RemoveWatchExpression)->trigger(exp);
theDebuggerAction(WatchExpression)->trigger(lineEdit->text()); theDebuggerAction(WatchExpression)->trigger(value);
} }
} }
@@ -175,8 +175,6 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QModelIndex idx = indexAt(ev->pos()); QModelIndex idx = indexAt(ev->pos());
QModelIndex mi0 = idx.sibling(idx.row(), 0); QModelIndex mi0 = idx.sibling(idx.row(), 0);
QString exp = model()->data(mi0).toString(); QString exp = model()->data(mi0).toString();
QModelIndex mi1 = idx.sibling(idx.row(), 0);
QString value = model()->data(mi1).toString();
menu.addSeparator(); menu.addSeparator();
int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression; int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression;

View File

@@ -0,0 +1,14 @@
fakevim is based on eventFilters installed on a QTextEdit or a QPlainTextEdit.
It basically catches all keystrokes and modifies some internal state that
make the resulting text in the editor look like it was using vim.
There are only a few files in here:
fakevimplugin.{h,cpp} - interaction with the rest of Creator
fakevimactions.{h,cpp} - settings
fakevimhandler.{h,cpp} - the "real" event
There are some more hints for developers in fakevimhandler.cpp

View File

@@ -29,28 +29,33 @@
#include "fakevimhandler.h" #include "fakevimhandler.h"
// Please do not add any direct dependencies to other Qt Creator code here.
// Instead emit signals and let the FakeVimPlugin channel the information to
// Qt Creator. The idea is to keep this file here in a "clean" state that
// allows easy reuse with any QTextEdit or QPlainTextEdit derived class.
// Some conventions:
// //
// Use 1 based line numbers and 0 based column numbers. Even though // ATTENTION:
// the 1 based line are not nice it matches vim's and QTextEdit's 'line'
// concepts.
// //
// Do not pass QTextCursor etc around unless really needed. Convert // 1 Please do not add any direct dependencies to other Qt Creator code here.
// early to line/column. // Instead emit signals and let the FakeVimPlugin channel the information to
// Qt Creator. The idea is to keep this file here in a "clean" state that
// allows easy reuse with any QTextEdit or QPlainTextEdit derived class.
// //
// There is always a "current" cursor (m_tc). A current "region of interest" // 2 There are a few auto tests located in ../../../tests/auto/fakevim.
// spans between m_anchor (== anchor()) and m_tc.position() (== position()) // Commands that are covered there are marked as "// tested" below.
// The value of m_tc.anchor() is not used. //
// 3 Some conventions:
//
// Use 1 based line numbers and 0 based column numbers. Even though
// the 1 based line are not nice it matches vim's and QTextEdit's 'line'
// concepts.
//
// Do not pass QTextCursor etc around unless really needed. Convert
// early to line/column.
//
// There is always a "current" cursor (m_tc). A current "region of interest"
// spans between m_anchor (== anchor()) and m_tc.position() (== position())
// The value of m_tc.anchor() is not used.
//
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QObject> #include <QtCore/QObject>
@@ -278,7 +283,7 @@ public:
typedef QTextCursor::MoveOperation MoveOperation; typedef QTextCursor::MoveOperation MoveOperation;
typedef QTextCursor::MoveMode MoveMode; typedef QTextCursor::MoveMode MoveMode;
void moveToEndOfDocument() { m_tc.movePosition(EndOfDocument, MoveAnchor); } void moveToEndOfDocument() { m_tc.movePosition(EndOfDocument, MoveAnchor); }
void moveToStartOfLine() { m_tc.movePosition(StartOfLine, MoveAnchor); } void moveToStartOfLine();
void moveToEndOfLine(); void moveToEndOfLine();
void moveUp(int n = 1) { moveDown(-n); } void moveUp(int n = 1) { moveDown(-n); }
void moveDown(int n = 1); // { m_tc.movePosition(Down, MoveAnchor, n); } void moveDown(int n = 1); // { m_tc.movePosition(Down, MoveAnchor, n); }
@@ -353,6 +358,8 @@ public:
// extra data for '.' // extra data for '.'
void replay(const QString &text, int count); void replay(const QString &text, int count);
void setDotCommand(const QString &cmd) { m_dotCommand = cmd; }
void setDotCommand(const QString &cmd, int n) { m_dotCommand = cmd.arg(n); }
QString m_dotCommand; QString m_dotCommand;
bool m_inReplay; // true if we are executing a '.' bool m_inReplay; // true if we are executing a '.'
@@ -613,8 +620,9 @@ void FakeVimHandler::Private::moveDown(int n)
m_tc.movePosition(Down, MoveAnchor, n); m_tc.movePosition(Down, MoveAnchor, n);
#else #else
const int col = m_tc.position() - m_tc.block().position(); const int col = m_tc.position() - m_tc.block().position();
const int line = m_tc.block().blockNumber(); const int lastLine = m_tc.document()->lastBlock().blockNumber();
const QTextBlock &block = m_tc.document()->findBlockByNumber(line + n); const int targetLine = qMax(0, qMin(lastLine, m_tc.block().blockNumber() + n));
const QTextBlock &block = m_tc.document()->findBlockByNumber(targetLine);
const int pos = block.position(); const int pos = block.position();
setPosition(pos + qMin(block.length() - 1, col)); setPosition(pos + qMin(block.length() - 1, col));
moveToTargetColumn(); moveToTargetColumn();
@@ -632,6 +640,17 @@ void FakeVimHandler::Private::moveToEndOfLine()
#endif #endif
} }
void FakeVimHandler::Private::moveToStartOfLine()
{
#if 0
// does not work for "hidden" documents like in the autotests
m_tc.movePosition(StartOfLine, MoveAnchor);
#else
const QTextBlock &block = m_tc.block();
setPosition(block.position());
#endif
}
void FakeVimHandler::Private::finishMovement(const QString &dotCommand) void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
{ {
//qDebug() << "ANCHOR: " << position() << anchor(); //qDebug() << "ANCHOR: " << position() << anchor();
@@ -656,7 +675,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (anchor() >= position()) if (anchor() >= position())
m_anchor++; m_anchor++;
if (!dotCommand.isEmpty()) if (!dotCommand.isEmpty())
m_dotCommand = "c" + dotCommand; setDotCommand("c" + dotCommand);
QString text = removeSelectedText(); QString text = removeSelectedText();
//qDebug() << "CHANGING TO INSERT MODE" << text; //qDebug() << "CHANGING TO INSERT MODE" << text;
m_registers[m_register] = text; m_registers[m_register] = text;
@@ -668,7 +687,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (anchor() >= position()) if (anchor() >= position())
m_anchor++; m_anchor++;
if (!dotCommand.isEmpty()) if (!dotCommand.isEmpty())
m_dotCommand = "d" + dotCommand; setDotCommand("d" + dotCommand);
m_registers[m_register] = removeSelectedText(); m_registers[m_register] = removeSelectedText();
m_submode = NoSubMode; m_submode = NoSubMode;
if (atEndOfLine()) if (atEndOfLine())
@@ -694,8 +713,6 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
updateMiniBuffer(); updateMiniBuffer();
} }
moveToTargetColumn();
m_moveType = MoveInclusive; m_moveType = MoveInclusive;
m_mvcount.clear(); m_mvcount.clear();
m_opcount.clear(); m_opcount.clear();
@@ -847,13 +864,19 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (m_submode == RegisterSubMode) { } else if (m_submode == RegisterSubMode) {
m_register = key; m_register = key;
m_submode = NoSubMode; m_submode = NoSubMode;
} else if (m_submode == ChangeSubMode && key == 'c') { } else if (m_submode == ChangeSubMode && key == 'c') { // tested
moveToStartOfLine(); moveDown(count() - 1);
moveToEndOfLine();
moveLeft();
setAnchor(); setAnchor();
moveDown(count()); moveToStartOfLine();
setTargetColumn();
moveUp(count() - 1);
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
finishMovement("c"); m_lastInsertion.clear();
} else if (m_submode == DeleteSubMode && key == 'd') { setDotCommand("%1cc", count());
finishMovement();
} else if (m_submode == DeleteSubMode && key == 'd') { // tested
moveToStartOfLine(); moveToStartOfLine();
setAnchor(); setAnchor();
moveDown(count()); moveDown(count());
@@ -869,19 +892,19 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
setAnchor(); setAnchor();
moveDown(count() - 1); moveDown(count() - 1);
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
m_dotCommand = QString("%1<<").arg(count()); setDotCommand("%1<<", count());
finishMovement(); finishMovement();
} else if (m_submode == ShiftRightSubMode && key == '>') { } else if (m_submode == ShiftRightSubMode && key == '>') {
setAnchor(); setAnchor();
moveDown(count() - 1); moveDown(count() - 1);
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
m_dotCommand = QString("%1>>").arg(count()); setDotCommand("%1>>", count());
finishMovement(); finishMovement();
} else if (m_submode == IndentSubMode && key == '=') { } else if (m_submode == IndentSubMode && key == '=') {
setAnchor(); setAnchor();
moveDown(count() - 1); moveDown(count() - 1);
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
m_dotCommand = QString("%1>>").arg(count()); setDotCommand("%1>>", count());
finishMovement(); finishMovement();
} else if (m_submode == ZSubMode) { } else if (m_submode == ZSubMode) {
//qDebug() << "Z_MODE " << cursorLineInDocument() << linesOnScreen(); //qDebug() << "Z_MODE " << cursorLineInDocument() << linesOnScreen();
@@ -928,7 +951,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_tc.insertText(QString(count(), text.at(0))); m_tc.insertText(QString(count(), text.at(0)));
m_moveType = MoveExclusive; m_moveType = MoveExclusive;
m_submode = NoSubMode; m_submode = NoSubMode;
m_dotCommand = QString("%1r%2").arg(count()).arg(text); setDotCommand("%1r" + text, count());
finishMovement(); finishMovement();
} else { } else {
m_submode = NoSubMode; m_submode = NoSubMode;
@@ -1125,7 +1148,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
handleStartOfLine(); handleStartOfLine();
scrollToLineInDocument(cursorLineInDocument() - sline); scrollToLineInDocument(cursorLineInDocument() - sline);
finishMovement(); finishMovement();
} else if (key == 'e') { } else if (key == 'e') { // tested
m_moveType = MoveInclusive; m_moveType = MoveInclusive;
moveToWordBoundary(false, true); moveToWordBoundary(false, true);
finishMovement(); finishMovement();
@@ -1175,13 +1198,13 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
handleStartOfLine(); handleStartOfLine();
finishMovement(); finishMovement();
} else if (key == 'i') { } else if (key == 'i') {
m_dotCommand = "i"; //QString("%1i").arg(count()); setDotCommand("i"); // setDotCommand("%1i", count());
enterInsertMode(); enterInsertMode();
updateMiniBuffer(); updateMiniBuffer();
if (atEndOfLine()) if (atEndOfLine())
moveLeft(); moveLeft();
} else if (key == 'I') { } else if (key == 'I') {
m_dotCommand = "I"; //QString("%1I").arg(count()); setDotCommand("I"); // setDotCommand("%1I", count());
enterInsertMode(); enterInsertMode();
if (m_gflag) if (m_gflag)
moveToStartOfLine(); moveToStartOfLine();
@@ -1256,7 +1279,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
search(lastSearchString(), !m_lastSearchForward); search(lastSearchString(), !m_lastSearchForward);
recordJump(); recordJump();
} else if (key == 'o' || key == 'O') { } else if (key == 'o' || key == 'O') {
m_dotCommand = QString("%1o").arg(count()); setDotCommand("%1o", count());
enterInsertMode(); enterInsertMode();
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
if (key == 'O') if (key == 'O')
@@ -1293,18 +1316,18 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveLeft(); moveLeft();
} }
} }
m_dotCommand = QString("%1p").arg(count()); setDotCommand("%1p", count());
finishMovement(); finishMovement();
} else if (key == 'r') { } else if (key == 'r') {
m_submode = ReplaceSubMode; m_submode = ReplaceSubMode;
m_dotCommand = "r"; setDotCommand("r");
} else if (key == 'R') { } else if (key == 'R') {
// FIXME: right now we repeat the insertion count() times, // FIXME: right now we repeat the insertion count() times,
// but not the deletion // but not the deletion
m_lastInsertion.clear(); m_lastInsertion.clear();
m_mode = InsertMode; m_mode = InsertMode;
m_submode = ReplaceSubMode; m_submode = ReplaceSubMode;
m_dotCommand = "R"; setDotCommand("R");
} else if (key == control('r')) { } else if (key == control('r')) {
redo(); redo();
} else if (key == 's') { } else if (key == 's') {
@@ -1313,7 +1336,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
setAnchor(); setAnchor();
moveRight(qMin(count(), rightDist())); moveRight(qMin(count(), rightDist()));
m_registers[m_register] = removeSelectedText(); m_registers[m_register] = removeSelectedText();
m_dotCommand = "s"; //QString("%1s").arg(count()); setDotCommand("s"); // setDotCommand("%1s", count());
m_opcount.clear(); m_opcount.clear();
m_mvcount.clear(); m_mvcount.clear();
enterInsertMode(); enterInsertMode();
@@ -1340,7 +1363,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
enterVisualMode(VisualLineMode); enterVisualMode(VisualLineMode);
} else if (key == control('v')) { } else if (key == control('v')) {
enterVisualMode(VisualBlockMode); enterVisualMode(VisualBlockMode);
} else if (key == 'w') { } else if (key == 'w') { // tested
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the // Special case: "cw" and "cW" work the same as "ce" and "cE" if the
// cursor is on a non-blank. // cursor is on a non-blank.
if (m_submode == ChangeSubMode) { if (m_submode == ChangeSubMode) {
@@ -1369,7 +1392,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
setAnchor(); setAnchor();
m_submode = DeleteSubMode; m_submode = DeleteSubMode;
moveRight(qMin(count(), rightDist())); moveRight(qMin(count(), rightDist()));
m_dotCommand = QString("%1x").arg(count()); setDotCommand("%1x", count());
finishMovement(); finishMovement();
} else if (key == 'X') { } else if (key == 'X') {
if (leftDist() > 0) { if (leftDist() > 0) {
@@ -1957,16 +1980,16 @@ void FakeVimHandler::Private::highlightMatches(const QString &needle0)
void FakeVimHandler::Private::moveToFirstNonBlankOnLine() void FakeVimHandler::Private::moveToFirstNonBlankOnLine()
{ {
QTextBlock block = m_tc.block();
QTextDocument *doc = m_tc.document(); QTextDocument *doc = m_tc.document();
m_tc.movePosition(StartOfLine, KeepAnchor); const QTextBlock &block = m_tc.block();
int firstPos = m_tc.position(); int firstPos = block.position();
for (int i = firstPos, n = firstPos + block.length(); i < n; ++i) { for (int i = firstPos, n = firstPos + block.length(); i < n; ++i) {
if (!doc->characterAt(i).isSpace()) { if (!doc->characterAt(i).isSpace()) {
m_tc.setPosition(i, KeepAnchor); setPosition(i);
return; return;
} }
} }
setPosition(block.position());
} }
void FakeVimHandler::Private::indentRegion(QChar typedChar) void FakeVimHandler::Private::indentRegion(QChar typedChar)
@@ -1978,7 +2001,7 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar)
qSwap(beginLine, endLine); qSwap(beginLine, endLine);
int amount = 0; int amount = 0;
emit q->indentRegion(&amount, beginLine, endLine, typedChar); emit q->indentRegion(&amount, beginLine, endLine, typedChar);
m_dotCommand = QString("%1==").arg(endLine - beginLine + 1); setDotCommand("%1==", endLine - beginLine + 1);
} }
void FakeVimHandler::Private::shiftRegionRight(int repeat) void FakeVimHandler::Private::shiftRegionRight(int repeat)
@@ -2000,7 +2023,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
setPosition(firstPos); setPosition(firstPos);
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
m_dotCommand = QString("%1>>").arg(endLine - beginLine + 1); setDotCommand("%1>>", endLine - beginLine + 1);
} }
void FakeVimHandler::Private::shiftRegionLeft(int repeat) void FakeVimHandler::Private::shiftRegionLeft(int repeat)
@@ -2037,17 +2060,20 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
setPosition(firstPos); setPosition(firstPos);
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
m_dotCommand = QString("%1<<").arg(endLine - beginLine + 1); setDotCommand("%1<<", endLine - beginLine + 1);
} }
void FakeVimHandler::Private::moveToTargetColumn() void FakeVimHandler::Private::moveToTargetColumn()
{ {
if (m_targetColumn == -1 || m_tc.block().length() <= m_targetColumn) { const QTextBlock &block = m_tc.block();
const QTextBlock &block = m_tc.block(); int col = m_tc.position() - m_tc.block().position();
if (col == m_targetColumn)
return;
//qDebug() << "CORRECTING COLUMN FROM: " << col << "TO" << m_targetColumn;
if (m_targetColumn == -1 || m_tc.block().length() <= m_targetColumn)
m_tc.setPosition(block.position() + block.length() - 1, KeepAnchor); m_tc.setPosition(block.position() + block.length() - 1, KeepAnchor);
} else { else
m_tc.setPosition(m_tc.block().position() + m_targetColumn, KeepAnchor); m_tc.setPosition(m_tc.block().position() + m_targetColumn, KeepAnchor);
}
} }
/* if simple is given: /* if simple is given:
@@ -2075,7 +2101,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
int lastClass = -1; int lastClass = -1;
while (true) { while (true) {
QChar c = doc->characterAt(m_tc.position() + (forward ? 1 : -1)); QChar c = doc->characterAt(m_tc.position() + (forward ? 1 : -1));
qDebug() << "EXAMINING: " << c << " AT " << position(); //qDebug() << "EXAMINING: " << c << " AT " << position();
int thisClass = charClass(c, simple); int thisClass = charClass(c, simple);
if (thisClass != lastClass && lastClass != 0) if (thisClass != lastClass && lastClass != 0)
--repeat; --repeat;
@@ -2319,6 +2345,7 @@ QString FakeVimHandler::Private::removeSelectedText()
m_tc.setPosition(pos, KeepAnchor); m_tc.setPosition(pos, KeepAnchor);
QString from = m_tc.selection().toPlainText(); QString from = m_tc.selection().toPlainText();
m_tc.removeSelectedText(); m_tc.removeSelectedText();
setAnchor();
return from; return from;
} }

View File

@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Debugging Helper Build Log</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>

View File

@@ -47,7 +47,11 @@
using namespace TextEditor; using namespace TextEditor;
#if defined (Q_OS_WIN)
QT_BEGIN_NAMESPACE
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
QT_END_NAMESPACE
#endif
#if defined (Q_OS_WIN) #if defined (Q_OS_WIN)
# define NATIVE_LINE_TERMINATOR CRLFLineTerminator # define NATIVE_LINE_TERMINATOR CRLFLineTerminator
@@ -145,14 +149,14 @@ bool BaseTextDocument::isReadOnly() const
const QFileInfo fi(m_fileName); const QFileInfo fi(m_fileName);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
// Check for permissions on NTFS file systems // Check for permissions on NTFS file systems
qt_ntfs_permission_lookup++; qt_ntfs_permission_lookup++;
#endif #endif
const bool ro = !fi.isWritable(); const bool ro = !fi.isWritable();
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
qt_ntfs_permission_lookup--; qt_ntfs_permission_lookup--;
#endif #endif
return ro; return ro;
@@ -171,10 +175,7 @@ bool BaseTextDocument::open(const QString &fileName)
m_fileName = fi.absoluteFilePath(); m_fileName = fi.absoluteFilePath();
QFile file(fileName); QFile file(fileName);
if (!file.exists()) if (!file.open(QIODevice::ReadOnly))
return false;
if (!file.open(QIODevice::ReadWrite) && !file.open(QIODevice::ReadOnly))
return false; return false;
title = fi.fileName(); title = fi.fileName();

View File

@@ -151,6 +151,8 @@ public:
QString m_pendingComment; QString m_pendingComment;
bool m_syntaxError; bool m_syntaxError;
bool m_contNextLine; bool m_contNextLine;
bool m_inQuote;
int m_parens;
/////////////// Evaluating pro file contents /////////////// Evaluating pro file contents
@@ -251,6 +253,8 @@ bool ProFileEvaluator::Private::read(ProFile *pro)
// Parser state // Parser state
m_block = 0; m_block = 0;
m_commentItem = 0; m_commentItem = 0;
m_inQuote = false;
m_parens = 0;
m_contNextLine = false; m_contNextLine = false;
m_syntaxError = false; m_syntaxError = false;
m_lineNo = 1; m_lineNo = 1;
@@ -274,71 +278,83 @@ bool ProFileEvaluator::Private::parseLine(const QString &line0)
if (m_blockstack.isEmpty()) if (m_blockstack.isEmpty())
return false; return false;
ushort quote = 0; int parens = m_parens;
int parens = 0; bool inQuote = m_inQuote;
bool contNextLine = false; bool escaped = false;
QString line = line0.simplified(); QString line = line0.simplified();
for (int i = 0; !m_syntaxError && i < line.length(); ++i) { for (int i = 0; !m_syntaxError && i < line.length(); ++i) {
ushort c = line.at(i).unicode(); ushort c = line.at(i).unicode();
if (quote && c == quote) if (c == '#') { // Yep - no escaping possible
quote = 0; insertComment(line.mid(i + 1));
else if (c == '(') escaped = m_contNextLine;
++parens; break;
else if (c == ')') }
--parens; if (!escaped) {
else if (c == '"' && (i == 0 || line.at(i - 1).unicode() != '\\')) if (c == '\\') {
quote = c; escaped = true;
else if (!parens && !quote) { m_proitem += c;
if (c == '#') { continue;
insertComment(line.mid(i + 1)); } else if (c == '"') {
contNextLine = m_contNextLine; inQuote = !inQuote;
break; m_proitem += c;
}
if (c == '\\' && i >= line.count() - 1) {
updateItem();
contNextLine = true;
continue; continue;
} }
if (m_block && (m_block->blockKind() & ProBlock::VariableKind)) { } else {
if (c == ' ') escaped = false;
updateItem(); }
else if (!inQuote) {
m_proitem += c; if (c == '(') {
continue; ++parens;
} } else if (c == ')') {
if (c == ':') { --parens;
enterScope(false); } else if (!parens) {
continue; if (m_block && (m_block->blockKind() & ProBlock::VariableKind)) {
} if (c == ' ')
if (c == '{') { updateItem();
enterScope(true); else
continue; m_proitem += c;
} continue;
if (c == '}') { }
leaveScope(); if (c == ':') {
continue; enterScope(false);
} continue;
if (c == '=') { }
insertVariable(line, &i); if (c == '{') {
continue; enterScope(true);
} continue;
if (c == '|' || c == '!') { }
insertOperator(c); if (c == '}') {
continue; leaveScope();
continue;
}
if (c == '=') {
insertVariable(line, &i);
continue;
}
if (c == '|' || c == '!') {
insertOperator(c);
continue;
}
} }
} }
m_proitem += c; m_proitem += c;
} }
m_contNextLine = contNextLine; m_inQuote = inQuote;
m_parens = parens;
if (!m_syntaxError) { m_contNextLine = escaped;
updateItem(); if (escaped) {
if (!m_contNextLine) m_proitem.chop(1);
finalizeBlock(); return true;
} else {
if (!m_syntaxError) {
updateItem();
if (!m_contNextLine)
finalizeBlock();
}
return !m_syntaxError;
} }
return !m_syntaxError;
} }
void ProFileEvaluator::Private::finalizeBlock() void ProFileEvaluator::Private::finalizeBlock()
@@ -357,6 +373,9 @@ void ProFileEvaluator::Private::insertVariable(const QString &line, int *i)
{ {
ProVariable::VariableOperator opkind; ProVariable::VariableOperator opkind;
if (m_proitem.isEmpty()) // Line starting with '=', like a conflict marker
return;
switch (m_proitem.at(m_proitem.length() - 1).unicode()) { switch (m_proitem.at(m_proitem.length() - 1).unicode()) {
case '+': case '+':
m_proitem.chop(1); m_proitem.chop(1);
@@ -636,11 +655,11 @@ bool ProFileEvaluator::Private::visitBeginProFile(ProFile * pro)
evaluateFile(mkspecDirectory + QLatin1String("/default/qmake.conf"), &ok); evaluateFile(mkspecDirectory + QLatin1String("/default/qmake.conf"), &ok);
evaluateFile(mkspecDirectory + QLatin1String("/features/default_pre.prf"), &ok); evaluateFile(mkspecDirectory + QLatin1String("/features/default_pre.prf"), &ok);
QStringList tmp = m_valuemap.value("CONFIG"); QStringList tmp = m_valuemap.value(QLatin1String("CONFIG"));
tmp.append(m_addUserConfigCmdArgs); tmp.append(m_addUserConfigCmdArgs);
foreach(const QString &remove, m_removeUserConfigCmdArgs) foreach(const QString &remove, m_removeUserConfigCmdArgs)
tmp.removeAll(remove); tmp.removeAll(remove);
m_valuemap.insert("CONFIG", tmp); m_valuemap.insert(QLatin1String("CONFIG"), tmp);
m_cumulative = cumulative; m_cumulative = cumulative;
} }
@@ -2021,7 +2040,13 @@ ProFile *ProFileEvaluator::parsedProFile(const QString &fileName)
{ {
QFileInfo fi(fileName); QFileInfo fi(fileName);
if (fi.exists()) { if (fi.exists()) {
ProFile *pro = new ProFile(fi.absoluteFilePath()); QString fn = QDir::cleanPath(fi.absoluteFilePath());
foreach (const ProFile *pf, d->m_profileStack)
if (pf->fileName() == fn) {
errorMessage(d->format("circular inclusion of %1").arg(fn));
return 0;
}
ProFile *pro = new ProFile(fn);
if (d->read(pro)) if (d->read(pro))
return pro; return pro;
delete pro; delete pro;

View File

@@ -235,26 +235,26 @@ examples/xml/xmlstreamlint/xmlstreamlint
examples/xmlpatterns/filetree/filetree examples/xmlpatterns/filetree/filetree
examples/xmlpatterns/qobjectxmlmodel/qobjectxmlmodel examples/xmlpatterns/qobjectxmlmodel/qobjectxmlmodel
examples/xmlpatterns/recipes/recipes examples/xmlpatterns/recipes/recipes
lib/libQt3Support.so.4.5.0 lib/libQt3Support.so.4.5.1
lib/libQtAssistantClient.so.4.5.0 lib/libQtAssistantClient.so.4.5.1
lib/libQtCLucene.so.4.5.0 lib/libQtCLucene.so.4.5.1
lib/libQtCore.so.4.5.0 lib/libQtCore.so.4.5.1
lib/libQtDBus.so.4.5.0 lib/libQtDBus.so.4.5.1
lib/libQtDesigner.so.4.5.0 lib/libQtDesigner.so.4.5.1
lib/libQtDesignerComponents.so.4.5.0 lib/libQtDesignerComponents.so.4.5.1
lib/libQtGui.so.4.5.0 lib/libQtGui.so.4.5.1
lib/libQtHelp.so.4.5.0 lib/libQtHelp.so.4.5.1
lib/libQtNetwork.so.4.5.0 lib/libQtNetwork.so.4.5.1
lib/libQtOpenGL.so.4.5.0 lib/libQtOpenGL.so.4.5.1
lib/libQtScript.so.4.5.0 lib/libQtScript.so.4.5.1
lib/libQtScriptTools.so.4.5.0 lib/libQtScriptTools.so.4.5.1
lib/libQtSql.so.4.5.0 lib/libQtSql.so.4.5.1
lib/libQtSvg.so.4.5.0 lib/libQtSvg.so.4.5.1
lib/libQtTest.so.4.5.0 lib/libQtTest.so.4.5.1
lib/libQtUiTools.a lib/libQtUiTools.a
lib/libQtWebKit.so.4.5.0 lib/libQtWebKit.so.4.5.1
lib/libQtXml.so.4.5.0 lib/libQtXml.so.4.5.1
lib/libQtXmlPatterns.so.4.5.0 lib/libQtXmlPatterns.so.4.5.1
plugins/accessible/libqtaccessiblecompatwidgets.so plugins/accessible/libqtaccessiblecompatwidgets.so
plugins/accessible/libqtaccessiblewidgets.so plugins/accessible/libqtaccessiblewidgets.so
plugins/codecs/libqcncodecs.so plugins/codecs/libqcncodecs.so

View File

@@ -79,6 +79,9 @@ private slots:
void mi10() { testMi(test10); } void mi10() { testMi(test10); }
void mi11() { testMi(test11); } void mi11() { testMi(test11); }
void mi12() { testMi(test12); } void mi12() { testMi(test12); }
void infoBreak();
void runQtc(); void runQtc();
public slots: public slots:
@@ -100,6 +103,41 @@ static QByteArray stripped(QByteArray ba)
return ba; return ba;
} }
void tst_Debugger::infoBreak()
{
// This tests the regular expression used in GdbEngine::extractDataFromInfoBreak
// to discover breakpoints in constructors.
// Copied from gdbengine.cpp:
QRegExp re("MULTIPLE.*(0x[0-9a-f]+) in (.*)\\s+at (.*):([\\d]+)([^\\d]|$)");
re.setMinimal(true);
QCOMPARE(re.indexIn(
"2 breakpoint keep y <MULTIPLE> 0x0040168e\n"
"2.1 y 0x0040168e "
"in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7\n"
"2.2 y 0x00401792 "
"in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7\n"), 33);
QCOMPARE(re.cap(1), QString("0x0040168e"));
QCOMPARE(re.cap(2).trimmed(), QString("MainWindow::MainWindow(QWidget*)"));
QCOMPARE(re.cap(3), QString("mainwindow.cpp"));
QCOMPARE(re.cap(4), QString("7"));
QCOMPARE(re.indexIn(
"Num Type Disp Enb Address What"
"4 breakpoint keep y <MULTIPLE> 0x00000000004066ad"
"4.1 y 0x00000000004066ad in CTorTester"
" at /main/tests/manual/gdbdebugger/simple/app.cpp:124"), 88);
QCOMPARE(re.cap(1), QString("0x00000000004066ad"));
QCOMPARE(re.cap(2).trimmed(), QString("CTorTester"));
QCOMPARE(re.cap(3), QString("/main/tests/manual/gdbdebugger/simple/app.cpp"));
QCOMPARE(re.cap(4), QString("124"));
}
void tst_Debugger::readStandardOutput() void tst_Debugger::readStandardOutput()
{ {
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput()); qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());

View File

@@ -55,13 +55,17 @@ public slots:
void changeExtraInformation(const QString &info) { m_infoMessage = info; } void changeExtraInformation(const QString &info) { m_infoMessage = info; }
private slots: private slots:
void commandDollar(); // command mode
void commandDown(); void command_cc();
void commandLeft(); void command_dd();
void commandRight(); void command_dollar();
void commandI(); void command_down();
void commandUp(); void command_e();
void commandW(); void command_i();
void command_left();
void command_right();
void command_up();
void command_w();
private: private:
void setup(); void setup();
@@ -73,6 +77,9 @@ private:
const char* file, int line); const char* file, int line);
QString insertCursor(const QString &needle0); QString insertCursor(const QString &needle0);
QString lmid(int i, int n = -1) const
{ return QStringList(l.mid(i, n)).join("\n"); }
QTextEdit *m_textedit; QTextEdit *m_textedit;
QPlainTextEdit *m_plaintextedit; QPlainTextEdit *m_plaintextedit;
FakeVimHandler *m_handler; FakeVimHandler *m_handler;
@@ -82,6 +89,8 @@ private:
QString m_statusData; QString m_statusData;
QString m_infoMessage; QString m_infoMessage;
// the individual lines
static const QStringList l; // identifier intentionally kept short
static const QString lines; static const QString lines;
static const QString escape; static const QString escape;
}; };
@@ -100,8 +109,11 @@ const QString tst_FakeVim::lines =
" return app.exec();\n" " return app.exec();\n"
"}\n"; "}\n";
const QStringList tst_FakeVim::l = tst_FakeVim::lines.split('\n');
const QString tst_FakeVim::escape = QChar(27); const QString tst_FakeVim::escape = QChar(27);
tst_FakeVim::tst_FakeVim(bool usePlainTextEdit) tst_FakeVim::tst_FakeVim(bool usePlainTextEdit)
{ {
if (usePlainTextEdit) { if (usePlainTextEdit) {
@@ -170,16 +182,16 @@ bool tst_FakeVim::checkContentsHelper(QString want, const char* file, int line)
QStringList wantlist = want.split('\n'); QStringList wantlist = want.split('\n');
QStringList gotlist = got.split('\n'); QStringList gotlist = got.split('\n');
if (!QTest::qCompare(gotlist.size(), wantlist.size(), "", "", file, line)) { if (!QTest::qCompare(gotlist.size(), wantlist.size(), "", "", file, line)) {
qDebug() << "WANT: " << want; qDebug() << "0 WANT: " << want;
qDebug() << "GOT: " << got; qDebug() << "0 GOT: " << got;
return false; return false;
} }
for (int i = 0; i < wantlist.size() && i < gotlist.size(); ++i) { for (int i = 0; i < wantlist.size() && i < gotlist.size(); ++i) {
QString g = QString("line %1: %2").arg(i + 1).arg(gotlist.at(i)); QString g = QString("line %1: %2").arg(i + 1).arg(gotlist.at(i));
QString w = QString("line %1: %2").arg(i + 1).arg(wantlist.at(i)); QString w = QString("line %1: %2").arg(i + 1).arg(wantlist.at(i));
if (!QTest::qCompare(g, w, "", "", file, line)) { if (!QTest::qCompare(g, w, "", "", file, line)) {
qDebug() << "WANT: " << want; qDebug() << "1 WANT: " << want;
qDebug() << "GOT: " << got; qDebug() << "1 GOT: " << got;
return false; return false;
} }
} }
@@ -222,11 +234,78 @@ QString tst_FakeVim::insertCursor(const QString &needle0)
needle.remove('@'); needle.remove('@');
QString lines0 = lines; QString lines0 = lines;
int pos = lines0.indexOf(needle); int pos = lines0.indexOf(needle);
if (pos == -1)
qDebug() << "Cannot find: \n----\n" + needle + "\n----\n";
lines0.replace(pos, needle.size(), needle0); lines0.replace(pos, needle.size(), needle0);
return lines0; return lines0;
} }
void tst_FakeVim::commandI()
//////////////////////////////////////////////////////////////////////////
//
// Command mode
//
//////////////////////////////////////////////////////////////////////////
void tst_FakeVim::command_cc()
{
setup();
move("j", "@" + l[1]);
check("ccabc" + escape, l[0] + "\nab@c\n" + lmid(2));
check("ccabc" + escape, l[0] + "\nab@c\n" + lmid(2));
check(".", l[0] + "\nab@c\n" + lmid(2));
check("j", l[0] + "\nabc\n#i@nclude <QtGui>\n" + lmid(3));
check("3ccxyz" + escape, l[0] + "\nabc\nxy@z\n" + lmid(5));
}
void tst_FakeVim::command_dd()
{
setup();
move("j", "@" + l[1]);
check("dd", l[0] + "\n@" + lmid(2));
check(".", l[0] + "\n@" + lmid(3));
check("3dd", l[0] + "\n@" + lmid(6));
}
void tst_FakeVim::command_dollar()
{
setup();
move("j$", "<QtCore>@");
move("j$", "<QtGui>@");
move("2j", ")@");
}
void tst_FakeVim::command_down()
{
setup();
move("j", "@" + l[1]);
move("3j", "@int main");
move("4j", "@ return app.exec()");
}
void tst_FakeVim::command_e()
{
setup();
move("e", "@#include <QtCore");
move("e", "#includ@e <QtCore");
move("e", "#include @<QtCore");
move("3e", "@#include <QtGui");
move("e", "#includ@e <QtGui");
move("e", "#include @<QtGui");
move("e", "#include <QtGu@i");
move("4e", "int main@(int argc, char *argv[])");
move("e", "int main(in@t argc, char *argv[])");
move("e", "int main(int arg@c, char *argv[])");
move("e", "int main(int argc@, char *argv[])");
move("e", "int main(int argc, cha@r *argv[])");
move("e", "int main(int argc, char @*argv[])");
move("e", "int main(int argc, char *arg@v[])");
move("e", "int main(int argc, char *argv[]@)");
move("e", "@{");
move("10k","@\n"); // home.
}
void tst_FakeVim::command_i()
{ {
setup(); setup();
@@ -255,40 +334,7 @@ return;
check("u", "@" + lines); check("u", "@" + lines);
} }
void tst_FakeVim::commandDollar() void tst_FakeVim::command_left()
{
setup();
move("j$", "<QtCore>@");
move("j$", "<QtGui>@");
move("2j", ")@");
}
void tst_FakeVim::commandDown()
{
setup();
move("j", "@#include <QtCore");
move("3j", "@int main");
move("4j", "@ return app.exec()");
}
void tst_FakeVim::commandUp()
{
setup();
move("j", "@#include <QtCore");
move("3j", "@int main");
move("4j", "@ return app.exec()");
}
void tst_FakeVim::commandRight()
{
setup();
move("4j", "@int main");
move("l", "i@nt main");
move("3l", "int @main");
move("50l", "argv[])@");
}
void tst_FakeVim::commandLeft()
{ {
setup(); setup();
move("4j", "@int main"); move("4j", "@int main");
@@ -299,15 +345,43 @@ void tst_FakeVim::commandLeft()
move("50h", "@int main"); move("50h", "@int main");
} }
void tst_FakeVim::commandW() void tst_FakeVim::command_right()
{ {
setup(); setup();
move("w", "@#include <QtCore"); move("4j", "@int main");
move("w", "#@include <QtCore"); move("l", "i@nt main");
move("w", "#include @<QtCore"); move("3l", "int @main");
move("3w", "@#include <QtGui"); move("50l", "argv[])@");
} }
void tst_FakeVim::command_up()
{
setup();
move("j", "@#include <QtCore");
move("3j", "@int main");
move("4j", "@ return app.exec()");
}
void tst_FakeVim::command_w()
{
setup();
move("w", "@#include <QtCore");
move("w", "#@include <QtCore");
move("w", "#include @<QtCore");
move("3w", "@#include <QtGui");
move("w", "#@include <QtGui");
move("w", "#include @<QtGui");
move("w", "#include <@QtGui");
move("4w", "int main@(int argc, char *argv[])");
move("w", "int main(@int argc, char *argv[])");
move("w", "int main(int @argc, char *argv[])");
move("w", "int main(int argc@, char *argv[])");
move("w", "int main(int argc, @char *argv[])");
move("w", "int main(int argc, char @*argv[])");
move("w", "int main(int argc, char *@argv[])");
move("w", "int main(int argc, char *argv@[])");
move("w", "@{");
}
/* /*
#include <QtCore> #include <QtCore>
@@ -321,6 +395,14 @@ int main(int argc, char *argv[])
} }
*/ */
//////////////////////////////////////////////////////////////////////////
//
// Main
//
//////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) \ int main(int argc, char *argv[]) \
{ {
int res = 0; int res = 0;

View File

@@ -87,6 +87,12 @@ public:
b = 2 + s + t; b = 2 + s + t;
a += 1; a += 1;
} }
~Foo()
{
a = 5;
}
void doit() void doit()
{ {
static QObject ob; static QObject ob;