Fixes in Python debugger
This commit is contained in:
@@ -30,8 +30,10 @@
|
||||
#endif
|
||||
|
||||
#include "PythonEditor.h"
|
||||
#include "PythonDebugger.h"
|
||||
#include "Application.h"
|
||||
#include "BitmapFactory.h"
|
||||
#include "Macro.h"
|
||||
#include "FileDialog.h"
|
||||
#include "DlgEditorImp.h"
|
||||
|
||||
@@ -45,8 +47,19 @@ namespace Gui {
|
||||
struct PythonEditorP
|
||||
{
|
||||
QMap<QString, QColor> colormap; // Color map
|
||||
int debugLine;
|
||||
QRect debugRect;
|
||||
QPixmap breakpoint;
|
||||
QPixmap debugMarker;
|
||||
QString filename;
|
||||
PythonDebugger* debugger;
|
||||
PythonEditorP()
|
||||
: debugLine(-1),
|
||||
breakpoint(QLatin1String(":/icons/breakpoint.png")),
|
||||
debugMarker(QLatin1String(":/icons/debug-marker.png"))
|
||||
{
|
||||
debugger = Application::Instance->macroManager()->debugger();
|
||||
|
||||
colormap[QLatin1String("Text")] = Qt::black;
|
||||
colormap[QLatin1String("Bookmark")] = Qt::cyan;
|
||||
colormap[QLatin1String("Breakpoint")] = Qt::red;
|
||||
@@ -98,18 +111,61 @@ PythonEditor::~PythonEditor()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void PythonEditor::setFileName(const QString& fn)
|
||||
{
|
||||
d->filename = fn;
|
||||
}
|
||||
|
||||
void PythonEditor::startDebug()
|
||||
{
|
||||
if (d->debugger->start()) {
|
||||
d->debugger->runFile(d->filename);
|
||||
d->debugger->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void PythonEditor::toggleBreakpoint()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int line = cursor.blockNumber() + 1;
|
||||
d->debugger->toggleBreakpoint(line, d->filename);
|
||||
getMarker()->update();
|
||||
}
|
||||
|
||||
void PythonEditor::showDebugMarker(int line)
|
||||
{
|
||||
d->debugLine = line;
|
||||
getMarker()->update();
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.movePosition(QTextCursor::StartOfBlock);
|
||||
int cur = cursor.blockNumber() + 1;
|
||||
if (cur > line) {
|
||||
for (int i=line; i<cur; i++)
|
||||
cursor.movePosition(QTextCursor::Up);
|
||||
}
|
||||
else if (cur < line) {
|
||||
for (int i=cur; i<line; i++)
|
||||
cursor.movePosition(QTextCursor::Down);
|
||||
}
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void PythonEditor::hideDebugMarker()
|
||||
{
|
||||
d->debugLine = -1;
|
||||
getMarker()->update();
|
||||
}
|
||||
|
||||
void PythonEditor::drawMarker(int line, int x, int y, QPainter* p)
|
||||
{
|
||||
#if 0
|
||||
Breakpoint bp = _dbg->getBreakpoint(fileName());
|
||||
Breakpoint bp = d->debugger->getBreakpoint(d->filename);
|
||||
if (bp.checkLine(line)) {
|
||||
p->drawPixmap(x, y, breakpoint);
|
||||
p->drawPixmap(x, y, d->breakpoint);
|
||||
}
|
||||
if (m_debugLine == line) {
|
||||
p->drawPixmap(x, y+2, debugMarker);
|
||||
debugRect = QRect(x, y+2, debugMarker.width(), debugMarker.height());
|
||||
if (d->debugLine == line) {
|
||||
p->drawPixmap(x, y+2, d->debugMarker);
|
||||
d->debugRect = QRect(x, y+2, d->debugMarker.width(), d->debugMarker.height());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PythonEditor::contextMenuEvent ( QContextMenuEvent * e )
|
||||
|
||||
Reference in New Issue
Block a user