Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

# Conflicts:
#	NEWS.md
#	RedPandaIDE/version.h
This commit is contained in:
royqh1979@gmail.com 2021-11-27 14:25:03 +08:00
commit f8591c2138
53 changed files with 2575 additions and 1783 deletions

22
NEWS.md
View File

@ -1,5 +1,25 @@
Version 0.10.2 For Dev-C++ 7 Beta
- fix: select by mouse can't correctly set mouse's column position
- fix: dragging out of the editor and back will cause error
- fix: dragging text from lines in the front to lines back will cause error
- fix: dragging text onto itself should do nothing
- fixlicense info in the about dialog should be readonly
- enhancement: change project name in the project view
Version 0.10.1 For Dev-C++ 7 Beta
- fix: can't correctly expand watch expression that has spaces in it
- fix: can't correctly display stl containers in watch
- fix: the last line in the debug console is not correctly displayed
- enhancement: scroll while dragging text in the editor
- fix: dragging out of the editor shouldn't reset the caret back
Version 0.10.0 For Dev-C++ 7 Beta
- enhancement: use gdb/mi interface to communicate with gdb debug session
- enhancement: better display of watch vars
- fix: project's modified flag not cleared after saved
Version 0.9.4 For Dev-C++ 7 Beta Version 0.9.4 For Dev-C++ 7 Beta
- fix: code format indent settings not correctly saved - fix: code formatter's "indent type" option not correctly saved
Version 0.9.3 For Dev-C++ 7 Beta Version 0.9.3 For Dev-C++ 7 Beta
- fix: the count in the title of issues view isn't correct - fix: the count in the title of issues view isn't correct

View File

@ -25,6 +25,7 @@ SOURCES += \
compiler/ojproblemcasesrunner.cpp \ compiler/ojproblemcasesrunner.cpp \
compiler/projectcompiler.cpp \ compiler/projectcompiler.cpp \
compiler/runner.cpp \ compiler/runner.cpp \
gdbmiresultparser.cpp \
platform.cpp \ platform.cpp \
compiler/compiler.cpp \ compiler/compiler.cpp \
compiler/compilermanager.cpp \ compiler/compilermanager.cpp \
@ -134,7 +135,8 @@ SOURCES += \
widgets/qconsole.cpp \ widgets/qconsole.cpp \
widgets/qpatchedcombobox.cpp \ widgets/qpatchedcombobox.cpp \
widgets/searchdialog.cpp \ widgets/searchdialog.cpp \
widgets/searchresultview.cpp widgets/searchresultview.cpp \
widgets/signalmessagedialog.cpp
HEADERS += \ HEADERS += \
ConvertUTF.h \ ConvertUTF.h \
@ -154,6 +156,7 @@ HEADERS += \
compiler/runner.h \ compiler/runner.h \
compiler/stdincompiler.h \ compiler/stdincompiler.h \
cpprefacter.h \ cpprefacter.h \
gdbmiresultparser.h \
parser/cppparser.h \ parser/cppparser.h \
parser/cpppreprocessor.h \ parser/cpppreprocessor.h \
parser/cpptokenizer.h \ parser/cpptokenizer.h \
@ -258,7 +261,8 @@ HEADERS += \
widgets/qconsole.h \ widgets/qconsole.h \
widgets/qpatchedcombobox.h \ widgets/qpatchedcombobox.h \
widgets/searchdialog.h \ widgets/searchdialog.h \
widgets/searchresultview.h widgets/searchresultview.h \
widgets/signalmessagedialog.h
FORMS += \ FORMS += \
settingsdialog/compilerautolinkwidget.ui \ settingsdialog/compilerautolinkwidget.ui \
@ -303,7 +307,8 @@ FORMS += \
widgets/filepropertiesdialog.ui \ widgets/filepropertiesdialog.ui \
widgets/newprojectdialog.ui \ widgets/newprojectdialog.ui \
widgets/ojproblempropertywidget.ui \ widgets/ojproblempropertywidget.ui \
widgets/searchdialog.ui widgets/searchdialog.ui \
widgets/signalmessagedialog.ui
TRANSLATIONS += \ TRANSLATIONS += \
RedPandaIDE_zh_CN.ts RedPandaIDE_zh_CN.ts

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -49,8 +49,6 @@ public:
const QString &newFileTemplate() const; const QString &newFileTemplate() const;
void setNewFileTemplate(const QString &newNewFileTemplate); void setNewFileTemplate(const QString &newNewFileTemplate);
signals:
private: private:
void loadSnippets(); void loadSnippets();
void saveSnippets(); void saveSnippets();

View File

@ -93,7 +93,7 @@ void ExecutableRunner::run()
process.start(); process.start();
process.waitForStarted(5000); process.waitForStarted(5000);
if (process.state()==QProcess::Running && redirectInput()) { if (process.state()==QProcess::Running && redirectInput()) {
process.write(ReadFileToByteArray(redirectInputFilename())); process.write(readFileToByteArray(redirectInputFilename()));
process.closeWriteChannel(); process.closeWriteChannel();
} }
while (true) { while (true) {

View File

@ -19,7 +19,6 @@ public:
bool findOccurence(const QString& statementFullname, SearchFileScope scope); bool findOccurence(const QString& statementFullname, SearchFileScope scope);
void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& word, const QString& newWord); void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& word, const QString& newWord);
signals:
private: private:
void doFindOccurenceInEditor(PStatement statement, Editor* editor, const PCppParser& parser); void doFindOccurenceInEditor(PStatement statement, Editor* editor, const PCppParser& parser);
void doFindOccurenceInProject(PStatement statement, std::shared_ptr<Project> project, const PCppParser& parser); void doFindOccurenceInProject(PStatement statement, std::shared_ptr<Project> project, const PCppParser& parser);

File diff suppressed because it is too large Load Diff

View File

@ -13,37 +13,16 @@
#include <QSemaphore> #include <QSemaphore>
#include <QThread> #include <QThread>
#include <memory> #include <memory>
#include "gdbmiresultparser.h"
enum class DebugCommandSource { enum class DebugCommandSource {
Console, Console,
Other Other
}; };
enum class AnnotationType {
TPrePrompt, TPrompt, TPostPrompt,
TSource,
TDisplayBegin, TDisplayEnd,
TDisplayExpression,
TFrameSourceFile, TFrameSourceBegin, TFrameSourceLine, TFrameFunctionName, TFrameWhere,
TFrameArgs,
TFrameBegin, TFrameEnd,
TErrorBegin, TErrorEnd,
TArrayBegin, TArrayEnd,
TElt, TEltRep, TEltRepEnd,
TExit,
TSignal, TSignalName, TSignalNameEnd, TSignalString, TSignalStringEnd,
TValueHistoryValue, TValueHistoryBegin, TValueHistoryEnd,
TArgBegin, TArgEnd, TArgValue, TArgNameEnd,
TFieldBegin, TFieldEnd, TFieldValue, TFieldNameEnd,
TInfoReg, TInfoAsm,
TUnknown, TEOF,
TLocal, TParam, TMemory
};
struct DebugCommand{ struct DebugCommand{
QString command; QString command;
QString params; QString params;
bool updateWatch;
bool showInConsole;
DebugCommandSource source; DebugCommandSource source;
}; };
@ -52,14 +31,19 @@ struct WatchVar;
using PWatchVar = std::shared_ptr<WatchVar>; using PWatchVar = std::shared_ptr<WatchVar>;
struct WatchVar { struct WatchVar {
QString name; QString name;
QString expression;
bool hasMore;
QString value; QString value;
QString fullName; QString type;
int gdbIndex; int numChild;
QList<PWatchVar> children; QList<PWatchVar> children;
WatchVar * parent; //use raw point to prevent circular-reference WatchVar * parent; //use raw point to prevent circular-reference
}; };
struct Breakpoint { struct Breakpoint {
int number; // breakpoint number
QString type; // type of the breakpoint
QString catch_type;
int line; int line;
QString filename; QString filename;
QString condition; QString condition;
@ -71,19 +55,13 @@ using PBreakpoint = std::shared_ptr<Breakpoint>;
struct Trace { struct Trace {
QString funcname; QString funcname;
QString filename; QString filename;
QString address;
int line; int line;
int level;
}; };
using PTrace = std::shared_ptr<Trace>; using PTrace = std::shared_ptr<Trace>;
struct Register {
QString name;
QString hexValue;
QString decValue;
};
using PRegister = std::shared_ptr<Register>;
class RegisterModel: public QAbstractTableModel { class RegisterModel: public QAbstractTableModel {
Q_OBJECT Q_OBJECT
public: public:
@ -92,10 +70,12 @@ public:
int columnCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void update(const QList<PRegister>& regs); void updateNames(const QStringList& regNames);
void updateValues(const QHash<int,QString> registerValues);
void clear(); void clear();
private: private:
QList<PRegister> mRegisters; QStringList mRegisterNames;
QHash<int,QString> mRegisterValues;
}; };
class BreakpointModel: public QAbstractTableModel { class BreakpointModel: public QAbstractTableModel {
@ -116,6 +96,8 @@ public:
void save(const QString& filename); void save(const QString& filename);
void load(const QString& filename); void load(const QString& filename);
public slots: public slots:
void updateBreakpointNumber(const QString& filename, int line, int number);
void invalidateAllBreakpointNumbers(); // call this when gdb is stopped
void onFileDeleteLines(const QString& filename, int startLine, int count); void onFileDeleteLines(const QString& filename, int startLine, int count);
void onFileInsertLines(const QString& filename, int startLine, int count); void onFileInsertLines(const QString& filename, int startLine, int count);
private: private:
@ -149,29 +131,51 @@ public:
QModelIndex index(int row, int column, QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override; const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override; QModelIndex parent(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void fetchMore(const QModelIndex &parent) override;
bool canFetchMore(const QModelIndex &parent) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent) const override;
void addWatchVar(PWatchVar watchVar); void addWatchVar(PWatchVar watchVar);
void removeWatchVar(const QString& name); void removeWatchVar(const QString& expression);
void removeWatchVar(int gdbIndex);
void removeWatchVar(const QModelIndex& index); void removeWatchVar(const QModelIndex& index);
void clear(); void clear();
const QList<PWatchVar>& watchVars(); const QList<PWatchVar>& watchVars();
PWatchVar findWatchVar(const QString& name); PWatchVar findWatchVar(const QModelIndex& index);
PWatchVar findWatchVar(int gdbIndex); PWatchVar findWatchVar(const QString& expr);
void resetAllVarInfos();
void clearAllVarInfos();
void beginUpdate(); void beginUpdate();
void endUpdate(); void endUpdate();
void notifyUpdated(PWatchVar var); void notifyUpdated(PWatchVar var);
void save(const QString& filename); void save(const QString& filename);
void load(const QString& filename); void load(const QString& filename);
public slots:
void updateVarInfo(const QString& expression,
const QString& name,
int numChild,
const QString& value,
const QString& type,
bool hasMore);
void prepareVarChildren(const QString& parentName, int numChild, bool hasMore);
void addVarChild(const QString& parentName, const QString& name,
const QString& exp, int numChild,
const QString& value, const QString& type,
bool hasMore);
void updateVarValue(const QString& name, const QString& val,
const QString& inScope, bool typeChanged,
const QString& newType, int newNumChildren,
bool hasMore);
signals:
void fetchChildren(const QString& name);
private:
QModelIndex index(PWatchVar var) const;
QModelIndex index(WatchVar* pVar) const;
private: private:
QList<PWatchVar> mWatchVars; QList<PWatchVar> mWatchVars;
QHash<QString,PWatchVar> mVarIndex;
int mUpdateCount; int mUpdateCount;
// QAbstractItemModel interface
public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
}; };
@ -188,10 +192,9 @@ public:
// Play/pause // Play/pause
bool start(); bool start();
void sendCommand(const QString& command, const QString& params, void sendCommand(const QString& command, const QString& params,
bool updateWatch = true,
bool showInConsole = false,
DebugCommandSource source = DebugCommandSource::Other); DebugCommandSource source = DebugCommandSource::Other);
bool commandRunning(); bool commandRunning();
bool inferiorRunning();
//breakpoints //breakpoints
void addBreakpoint(int line, const Editor* editor); void addBreakpoint(int line, const Editor* editor);
@ -208,27 +211,14 @@ public:
void sendAllBreakpointsToDebugger(); void sendAllBreakpointsToDebugger();
//watch vars //watch vars
void addWatchVar(const QString& namein); void addWatchVar(const QString& expression);
// void removeWatchVar(nodein: TTreeNode); overload; void modifyWatchVarExpression(const QString& oldExpr, const QString& newExpr);
void renameWatchVar(const QString& oldname, const QString& newname);
void refreshWatchVars();
void removeWatchVars(bool deleteparent); void removeWatchVars(bool deleteparent);
void removeWatchVar(const QModelIndex& index); void removeWatchVar(const QModelIndex& index);
void invalidateAllVars(); void sendAllWatchVarsToDebugger();
void sendAllWatchvarsToDebugger(); PWatchVar findWatchVar(const QString& expression);
void invalidateWatchVar(const QString& name);
void invalidateWatchVar(PWatchVar var);
PWatchVar findWatchVar(const QString& name);
// void notifyWatchVarUpdated(PWatchVar var); // void notifyWatchVarUpdated(PWatchVar var);
void notifyBeforeProcessWatchVar();
void notifyAfterProcessWatchVar();
void updateDebugInfo();
bool useUTF8() const;
void setUseUTF8(bool useUTF8);
BacktraceModel* backtraceModel(); BacktraceModel* backtraceModel();
BreakpointModel* breakpointModel(); BreakpointModel* breakpointModel();
@ -257,14 +247,19 @@ private:
private slots: private slots:
void syncFinishedParsing(); void syncFinishedParsing();
void updateMemory(const QStringList& value);
void updateEval(const QString& value);
void updateDisassembly(const QString& file, const QString& func,const QStringList& value);
void onChangeDebugConsoleLastline(const QString& text); void onChangeDebugConsoleLastline(const QString& text);
void clearUpReader(); void clearUpReader();
void updateRegisterNames(const QStringList& registerNames);
void updateRegisterValues(const QHash<int,QString>& values);
void refreshWatchVars();
void fetchVarChildren(const QString& varName);
private: private:
bool mExecuting; bool mExecuting;
bool mCommandChanged; bool mCommandChanged;
BreakpointModel *mBreakpointModel; BreakpointModel *mBreakpointModel;
bool mUseUTF8;
BacktraceModel *mBacktraceModel; BacktraceModel *mBacktraceModel;
WatchModel *mWatchModel; WatchModel *mWatchModel;
RegisterModel *mRegisterModel; RegisterModel *mRegisterModel;
@ -277,102 +272,145 @@ class DebugReader : public QThread
Q_OBJECT Q_OBJECT
public: public:
explicit DebugReader(Debugger* debugger, QObject *parent = nullptr); explicit DebugReader(Debugger* debugger, QObject *parent = nullptr);
void postCommand(const QString &Command, const QString &Params, void postCommand(const QString &Command, const QString &Params, DebugCommandSource Source);
bool UpdateWatch, bool ShowInConsole, DebugCommandSource Source); void registerInferiorStoppedCommand(const QString &Command, const QString &Params);
QString debuggerPath() const; QString debuggerPath() const;
void setDebuggerPath(const QString &debuggerPath); void setDebuggerPath(const QString &debuggerPath);
void stopDebug(); void stopDebug();
bool commandRunning(); bool commandRunning();
void waitStart();
bool invalidateAllVars() const; bool inferiorPaused() const;
void setInvalidateAllVars(bool invalidateAllVars);
bool processExited() const;
bool signalReceived() const;
const QStringList &consoleOutput() const;
int breakPointLine() const;
const QString &breakPointFile() const;
const PDebugCommand &currentCmd() const;
bool updateCPUInfo() const;
bool updateLocals() const;
const QStringList &localsValue() const;
bool evalReady() const;
const QString &evalValue() const;
bool updateMemory() const;
const QStringList &memoryValue() const;
bool receivedSFWarning() const;
const QStringList &fullOutput() const;
bool inferiorRunning() const;
const QString &signalName() const;
const QString &signalMeaning() const;
signals: signals:
void parseStarted(); void parseStarted();
void invalidateAllVars(); void invalidateAllVars();
void parseFinished(); void parseFinished();
void writeToDebugFailed(); void writeToDebugFailed();
void pauseWatchUpdate();
void updateWatch();
void processError(QProcess::ProcessError error); void processError(QProcess::ProcessError error);
void changeDebugConsoleLastLine(const QString& text); void changeDebugConsoleLastLine(const QString& text);
void cmdStarted(); void cmdStarted();
void cmdFinished(); void cmdFinished();
void breakpointInfoGetted(const QString& filename, int line, int number);
void inferiorContinued();
void inferiorStopped(const QString& filename, int line, bool setFocus);
void localsUpdated(const QStringList& localsValue);
void evalUpdated(const QString& value);
void memoryUpdated(const QStringList& memoryValues);
void disassemblyUpdate(const QString& filename, const QString& funcName, const QStringList& result);
void registerNamesUpdated(const QStringList& registerNames);
void registerValuesUpdated(const QHash<int,QString>& values);
void varCreated(const QString& expression,
const QString& name,
int numChild,
const QString& value,
const QString& type,
bool hasMore);
void prepareVarChildren(const QString& parentName,int numChild, bool hasMore);
void addVarChild(const QString& parentName, const QString& name,
const QString& exp, int numChild,
const QString& value, const QString& type,
bool hasMore);
void varValueUpdated(const QString& name, const QString& val,
const QString& inScope, bool typeChanged,
const QString& newType, int newNumChildren,
bool hasMore);
private: private:
void clearCmdQueue(); void clearCmdQueue();
bool findAnnotation(AnnotationType annotation);
AnnotationType getAnnotation(const QString& s);
AnnotationType getLastAnnotation(const QByteArray& text);
AnnotationType getNextAnnotation();
QString getNextFilledLine();
QString getNextLine();
QString getNextWord();
QString getRemainingLine();
void handleDisassembly();
void handleDisplay();
void handleError();
void handleExit();
void handleFrames();
void handleLocalOutput();
void handleLocals();
void handleMemory();
void handleParams();
void handleRegisters();
void handleSignal();
void handleSource();
void handleValueHistoryValue();
AnnotationType peekNextAnnotation();
void processDebugOutput();
QString processEvalOutput();
void processWatchOutput(PWatchVar WatchVar);
void runNextCmd(); void runNextCmd();
void skipSpaces();
void skipToAnnotation();
QStringList tokenize(const QString& s); QStringList tokenize(const QString& s);
bool outputTerminated(const QByteArray& text);
void handleBreakpoint(const GDBMIResultParser::ParseObject& breakpoint);
void handleStack(const QList<GDBMIResultParser::ParseValue> & stack);
void handleLocalVariables(const QList<GDBMIResultParser::ParseValue> & variables);
void handleEvaluation(const QString& value);
void handleMemory(const QList<GDBMIResultParser::ParseValue> & rows);
void handleRegisterNames(const QList<GDBMIResultParser::ParseValue> & names);
void handleRegisterValue(const QList<GDBMIResultParser::ParseValue> & values);
void handleCreateVar(const GDBMIResultParser::ParseObject& multiVars);
void handleListVarChildren(const GDBMIResultParser::ParseObject& multiVars);
void handleUpdateVarValue(const QList<GDBMIResultParser::ParseValue> &changes);
void processConsoleOutput(const QByteArray& line);
void processResult(const QByteArray& result);
void processExecAsyncRecord(const QByteArray& line);
void processError(const QByteArray& errorLine);
void processResultRecord(const QByteArray& line);
void processDebugOutput(const QByteArray& debugOutput);
void runInferiorStoppedHook();
QByteArray removeToken(const QByteArray& line);
private: private:
Debugger *mDebugger; Debugger *mDebugger;
QString mDebuggerPath; QString mDebuggerPath;
QRecursiveMutex mCmdQueueMutex; QRecursiveMutex mCmdQueueMutex;
QSemaphore mStartSemaphore; QSemaphore mStartSemaphore;
QQueue<PDebugCommand> mCmdQueue; QQueue<PDebugCommand> mCmdQueue;
int mUpdateCount;
bool mInvalidateAllVars;
//fOnInvalidateAllVars: TInvalidateAllVarsEvent; //fOnInvalidateAllVars: TInvalidateAllVarsEvent;
bool mCmdRunning; bool mCmdRunning;
PDebugCommand mCurrentCmd; PDebugCommand mCurrentCmd;
QList<PRegister> mRegisters;
QStringList mDisassembly;
QProcess* mProcess; QProcess* mProcess;
//fWatchView: TTreeView; //fWatchView: TTreeView;
int mIndex;
int mBreakPointLine;
QString mBreakPointFile;
QString mOutput;
QString mEvalValue;
QStringList mMemoryValue;
QStringList mLocalsValue;
QString mSignal;
bool mUseUTF8;
// attempt to cut down on Synchronize calls QString mSignalName;
bool dobacktraceready; QString mSignalMeaning;
bool dodisassemblerready;
bool doregistersready;
bool doevalready;
bool doprocessexited;
bool doupdatecpuwindow;
bool doupdateexecution;
bool doreceivedsignal;
bool doreceivedsfwarning;
bool doupdatememoryview;
bool doupdatelocal;
//
QList<PDebugCommand> mInferiorStoppedHookCommands;
bool mInferiorRunning;
bool mProcessExited;
bool mSignalReceived;
bool mUpdateCPUInfo;
bool mReceivedSFWarning;
int mCurrentLine;
int mCurrentAddress;
QString mCurrentFunc;
QString mCurrentFile;
QStringList mConsoleOutput;
QStringList mFullOutput;
bool mStop; bool mStop;
friend class Debugger;
// QThread interface // QThread interface
protected: protected:
void run() override; void run() override;

View File

@ -604,12 +604,12 @@ void Editor::keyPressEvent(QKeyEvent *event)
insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS); insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS);
insertString.append(" */"); insertString.append(" */");
} }
insertCodeSnippet(LinesToText(insertString)); insertCodeSnippet(linesToText(insertString));
} else if (highlighter() } else if (highlighter()
&& caretY()>=2 && caretY()>=2
&& highlighter()->isLastLineCommentNotFinished( && highlighter()->isLastLineCommentNotFinished(
lines()->ranges(caretY()-2).state)) { lines()->ranges(caretY()-2).state)) {
s=TrimLeft(lineText()); s=trimLeft(lineText());
if (s.startsWith("* ")) { if (s.startsWith("* ")) {
handled = true; handled = true;
int right = lines()->getString(caretY()-1).length()-caretX(); int right = lines()->getString(caretY()-1).length()-caretX();
@ -1513,7 +1513,7 @@ void Editor::onGutterClicked(Qt::MouseButton button, int , int , int line)
mGutterClickedLine = line; mGutterClickedLine = line;
} }
void Editor::onTipEvalValueReady(const QString &value) void Editor::onTipEvalValueReady(const QString& value)
{ {
if (mCurrentWord == mCurrentDebugTipWord) { if (mCurrentWord == mCurrentDebugTipWord) {
QString newValue; QString newValue;
@ -2142,7 +2142,7 @@ void Editor::insertCodeSnippet(const QString &code)
auto action = finally([this]{ auto action = finally([this]{
endUpdate(); endUpdate();
}); });
QStringList sl = TextToLines(parseMacros(code)); QStringList sl = textToLines(parseMacros(code));
int lastI=0; int lastI=0;
int spaceCount = GetLeftSpacing( int spaceCount = GetLeftSpacing(
leftSpaces(lineText()),true).length(); leftSpaces(lineText()),true).length();
@ -2196,7 +2196,7 @@ void Editor::insertCodeSnippet(const QString &code)
} }
BufferCoord cursorPos = caretXY(); BufferCoord cursorPos = caretXY();
QString s = LinesToText(newSl); QString s = linesToText(newSl);
// if EndsStr(#13#10,s) then // if EndsStr(#13#10,s) then
// Delete(s,Length(s)-1,2) // Delete(s,Length(s)-1,2)
// else if EndsStr(#10, s) then // else if EndsStr(#10, s) then
@ -2826,7 +2826,7 @@ void Editor::showDebugHint(const QString &s, int line)
connect(pMainWindow->debugger(), &Debugger::evalValueReady, connect(pMainWindow->debugger(), &Debugger::evalValueReady,
this, &Editor::onTipEvalValueReady); this, &Editor::onTipEvalValueReady);
mCurrentDebugTipWord = s; mCurrentDebugTipWord = s;
pMainWindow->debugger()->sendCommand("print",s,false); pMainWindow->debugger()->sendCommand("-data-evaluate-expression",s);
} }
QString Editor::getErrorHint(const PSyntaxIssue& issue) QString Editor::getErrorHint(const PSyntaxIssue& issue)

View File

@ -0,0 +1,470 @@
#include "gdbmiresultparser.h"
#include <QFileInfo>
#include <QList>
#include <QDebug>
GDBMIResultParser::GDBMIResultParser()
{
mResultTypes.insert("-break-insert",GDBMIResultType::Breakpoint);
//mResultTypes.insert("BreakpointTable",GDBMIResultType::BreakpointTable);
mResultTypes.insert("-stack-list-frames",GDBMIResultType::FrameStack);
mResultTypes.insert("-stack-list-variables", GDBMIResultType::LocalVariables);
//mResultTypes.insert("frame",GDBMIResultType::Frame);
mResultTypes.insert("-data-disassemble",GDBMIResultType::Disassembly);
mResultTypes.insert("-data-evaluate-expression",GDBMIResultType::Evaluation);
// mResultTypes.insert("register-names",GDBMIResultType::RegisterNames);
// mResultTypes.insert("register-values",GDBMIResultType::RegisterValues);
mResultTypes.insert("-data-read-memory",GDBMIResultType::Memory);
mResultTypes.insert("-data-list-register-names",GDBMIResultType::RegisterNames);
mResultTypes.insert("-data-list-register-values",GDBMIResultType::RegisterValues);
mResultTypes.insert("-var-create",GDBMIResultType::CreateVar);
mResultTypes.insert("-var-list-children",GDBMIResultType::ListVarChildren);
mResultTypes.insert("-var-update",GDBMIResultType::UpdateVarValue);
}
bool GDBMIResultParser::parse(const QByteArray &record, const QString& command, GDBMIResultType &type, ParseObject& multiValues)
{
const char* p = record.data();
bool result = parseMultiValues(p,multiValues);
if (!result)
return false;
// if (*p!=0)
// return false;
if (!mResultTypes.contains(command))
return false;
type = mResultTypes[command];
return true;
}
bool GDBMIResultParser::parseAsyncResult(const QByteArray &record, QByteArray &result, ParseObject &multiValue)
{
const char* p =record.data();
if (*p!='*')
return false;
p++;
const char* start=p;
while (*p && *p!=',')
p++;
result = QByteArray(start,p-start);
if (*p==0)
return true;
p++;
return parseMultiValues(p,multiValue);
}
bool GDBMIResultParser::parseMultiValues(const char* p, ParseObject &multiValue)
{
while (*p) {
QByteArray propName;
ParseValue propValue;
bool result = parseNameAndValue(p,propName,propValue);
if (result) {
multiValue[propName]=propValue;
} else {
return false;
}
skipSpaces(p);
if (*p==0)
break;
if (*p!=',')
return false;
p++; //skip ','
skipSpaces(p);
}
return true;
}
bool GDBMIResultParser::parseNameAndValue(const char *&p, QByteArray &name, ParseValue &value)
{
skipSpaces(p);
const char* nameStart =p;
while (*p!=0 && isNameChar(*p)) {
p++;
}
if (*p==0)
return false;
name = QByteArray(nameStart,p-nameStart);
skipSpaces(p);
if (*p!='=')
return false;
p++;
return parseValue(p,value);
}
bool GDBMIResultParser::parseValue(const char *&p, ParseValue &value)
{
skipSpaces(p);
bool result;
switch (*p) {
case '{': {
ParseObject obj;
result = parseObject(p,obj);
value = obj;
break;
}
case '[': {
QList<ParseValue> array;
result = parseArray(p,array);
value = array;
break;
}
case '"': {
QByteArray s;
result = parseStringValue(p,s);
value = s;
break;
}
default:
return false;
}
if (!result)
return false;
skipSpaces(p);
return true;
}
bool GDBMIResultParser::parseStringValue(const char *&p, QByteArray& stringValue)
{
if (*p!='"')
return false;
p++;
stringValue.clear();
while (*p!=0) {
if (*p == '"') {
break;
} else if (*p=='\\' && *(p+1)!=0) {
p++;
switch (*p) {
case '\'':
stringValue+=0x27;
p++;
break;
case '"':
stringValue+=0x22;
p++;
break;
case '?':
stringValue+=0x3f;
p++;
break;
case '\\':
stringValue+=0x5c;
p++;
break;
case 'a':
stringValue+=0x07;
p++;
break;
case 'b':
stringValue+=0x08;
p++;
break;
case 'f':
stringValue+=0x0c;
p++;
break;
case 'n':
stringValue+=0x0a;
p++;
break;
case 'r':
stringValue+=0x0d;
p++;
break;
case 't':
stringValue+=0x09;
p++;
break;
case 'v':
stringValue+=0x0b;
p++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
int i=0;
for (i=0;i<3;i++) {
if (*(p+i)<'0' || *(p+i)>'7')
break;
}
QByteArray numStr(p,i);
bool ok;
unsigned char ch = numStr.toInt(&ok,8);
stringValue+=ch;
p+=i;
break;
}
}
} else {
stringValue+=*p;
p++;
}
}
if (*p=='"') {
p++; //skip '"'
return true;
}
return false;
}
bool GDBMIResultParser::parseObject(const char *&p, ParseObject &obj)
{
if (*p!='{')
return false;
p++;
if (*p!='}') {
while (*p!=0) {
QByteArray propName;
ParseValue propValue;
bool result = parseNameAndValue(p,propName,propValue);
if (result) {
obj[propName]=propValue;
} else {
return false;
}
skipSpaces(p);
if (*p=='}')
break;
if (*p!=',') {
return false;
}
p++; //skip ','
skipSpaces(p);
}
}
if (*p=='}') {
p++; //skip '}'
return true;
}
return false;
}
bool GDBMIResultParser::parseArray(const char *&p, QList<GDBMIResultParser::ParseValue> &array)
{
if (*p!='[')
return false;
p++;
if (*p!=']') {
while (*p!=0) {
skipSpaces(p);
if (*p=='{' || *p=='"' || *p=='[') {
ParseValue val;
bool result = parseValue(p,val);
if (result) {
array.append(val);
} else {
return false;
}
} else {
QByteArray name;
ParseValue val;
bool result = parseNameAndValue(p,name,val);
if (result) {
array.append(val);
} else {
return false;
}
}
skipSpaces(p);
if (*p==']')
break;
if (*p!=',')
return false;
p++; //skip ','
skipSpaces(p);
}
}
if (*p==']') {
p++; //skip ']'
return true;
}
return false;
}
bool GDBMIResultParser::isNameChar(char ch)
{
if (ch=='-')
return true;
if (ch=='_')
return true;
if (ch>='a' && ch<='z')
return true;
if (ch>='A' && ch<='Z')
return true;
return false;
}
bool GDBMIResultParser::isSpaceChar(char ch)
{
switch(ch) {
case ' ':
case '\t':
return true;
}
return false;
}
void GDBMIResultParser::skipSpaces(const char *&p)
{
while (*p!=0 && isSpaceChar(*p))
p++;
}
const QByteArray &GDBMIResultParser::ParseValue::value() const
{
return mValue;
}
const QList<::GDBMIResultParser::ParseValue> &GDBMIResultParser::ParseValue::array() const
{
return mArray;
}
const GDBMIResultParser::ParseObject &GDBMIResultParser::ParseValue::object() const
{
return mObject;
}
int GDBMIResultParser::ParseValue::intValue(int defaultValue) const
{
Q_ASSERT(mType == ParseValueType::Value);
bool ok;
int value = QString(mValue).toInt(&ok);
if (ok)
return value;
else
return defaultValue;
}
int GDBMIResultParser::ParseValue::hexValue(int defaultValue) const
{
Q_ASSERT(mType == ParseValueType::Value);
bool ok;
int value = QString(mValue).toInt(&ok,16);
if (ok)
return value;
else
return defaultValue;
}
QString GDBMIResultParser::ParseValue::pathValue() const
{
Q_ASSERT(mType == ParseValueType::Value);
return QFileInfo(QString::fromLocal8Bit(mValue)).absoluteFilePath();
}
GDBMIResultParser::ParseValueType GDBMIResultParser::ParseValue::type() const
{
return mType;
}
bool GDBMIResultParser::ParseValue::isValid() const
{
return mType!=ParseValueType::NotAssigned;
}
GDBMIResultParser::ParseValue::ParseValue():
mType(ParseValueType::NotAssigned) {
}
GDBMIResultParser::ParseValue::ParseValue(const QByteArray &value):
mValue(value),
mType(ParseValueType::Value)
{
}
GDBMIResultParser::ParseValue::ParseValue(const ParseObject &object):
mObject(object),
mType(ParseValueType::Object)
{
}
GDBMIResultParser::ParseValue::ParseValue(const QList<ParseValue> &array):
mArray(array),
mType(ParseValueType::Array)
{
}
GDBMIResultParser::ParseValue::ParseValue(const ParseValue &value):
mValue(value.mValue),
mArray(value.mArray),
mObject(value.mObject),
mType(value.mType)
{
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const GDBMIResultParser::ParseValue &value)
{
mType = value.mType;
mValue = value.mValue;
mArray = value.mArray;
mObject = value.mObject;
return *this;
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QByteArray &value)
{
Q_ASSERT(mType == ParseValueType::NotAssigned);
mType = ParseValueType::Value;
mValue = value;
return *this;
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const ParseObject& object)
{
Q_ASSERT(mType == ParseValueType::NotAssigned);
mType = ParseValueType::Object;
mObject = object;
return *this;
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QList<ParseValue>& array)
{
Q_ASSERT(mType == ParseValueType::NotAssigned);
mType = ParseValueType::Array;
mArray = array;
return *this;
}
GDBMIResultParser::ParseObject::ParseObject()
{
}
GDBMIResultParser::ParseObject::ParseObject(const ParseObject &object):
mProps(object.mProps)
{
}
GDBMIResultParser::ParseValue GDBMIResultParser::ParseObject::operator[](const QByteArray &name) const
{
if (mProps.contains(name)) {
ParseValue value(mProps[name]);
return value;
}
return ParseValue();
}
GDBMIResultParser::ParseObject &GDBMIResultParser::ParseObject::operator=(const ParseObject &object)
{
mProps = object.mProps;
return *this;
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseObject::operator[](const QByteArray &name) {
if (!mProps.contains(name))
mProps[name]=ParseValue();
return mProps[name];
}

View File

@ -0,0 +1,98 @@
#ifndef GDBMIRESULTPARSER_H
#define GDBMIRESULTPARSER_H
#include <QByteArray>
#include <QHash>
#include <QList>
#include <memory>
enum class GDBMIResultType {
Breakpoint,
BreakpointTable,
FrameStack,
LocalVariables,
Locals,
Frame,
Disassembly,
Evaluation,
RegisterNames,
RegisterValues,
Memory,
CreateVar,
ListVarChildren,
UpdateVarValue
};
class GDBMIResultParser
{
public:
enum class ParseValueType {
Value,
Object,
Array,
NotAssigned
};
class ParseValue;
class ParseObject {
public:
explicit ParseObject();
ParseObject(const ParseObject& object);
ParseValue operator[](const QByteArray& name) const;
ParseValue& operator[](const QByteArray& name);
ParseObject& operator=(const ParseObject& object);
private:
QHash<QByteArray, ParseValue> mProps;
};
class ParseValue {
public:
explicit ParseValue();
explicit ParseValue(const QByteArray& value);
explicit ParseValue(const ParseObject &object);
explicit ParseValue(const QList<ParseValue>& array);
ParseValue(const ParseValue& value);
const QByteArray &value() const;
const QList<ParseValue> &array() const;
const ParseObject &object() const;
int intValue(int defaultValue=-1) const;
int hexValue(int defaultValue=-1) const;
QString pathValue() const;
ParseValueType type() const;
bool isValid() const;
ParseValue& operator=(const QByteArray& value);
ParseValue& operator=(const ParseObject& object);
ParseValue& operator=(const QList<ParseValue>& array);
ParseValue& operator=(const ParseValue& value);
private:
QByteArray mValue;
QList<ParseValue> mArray;
ParseObject mObject;
ParseValueType mType;
};
using PParseValue = std::shared_ptr<ParseValue>;
public:
GDBMIResultParser();
bool parse(const QByteArray& record, const QString& command, GDBMIResultType& type, ParseObject& multiValues);
bool parseAsyncResult(const QByteArray& record, QByteArray& result, ParseObject& multiValue);
private:
bool parseMultiValues(const char*p, ParseObject& multiValue);
bool parseNameAndValue(const char *&p,QByteArray& name, ParseValue& value);
bool parseValue(const char* &p, ParseValue& value);
bool parseStringValue(const char*&p, QByteArray& stringValue);
bool parseObject(const char*&p, ParseObject& obj);
bool parseArray(const char*&p, QList<ParseValue>& array);
void skipSpaces(const char* &p);
bool isNameChar(char ch);
bool isSpaceChar(char ch);
private:
QHash<QString, GDBMIResultType> mResultTypes;
};
#endif // GDBMIRESULTPARSER_H

View File

@ -489,5 +489,6 @@
<file>images/editor/bookmark.png</file> <file>images/editor/bookmark.png</file>
<file>images/newlook24/091-openproblemanswer.png</file> <file>images/newlook24/091-openproblemanswer.png</file>
<file>images/newlook24/092-runallproblemcases.png</file> <file>images/newlook24/092-runallproblemcases.png</file>
<file>images/newlook24/093-pause.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -23,7 +23,6 @@ public:
const PIcon &bookmark() const; const PIcon &bookmark() const;
const PIcon &folder() const; const PIcon &folder() const;
signals:
private: private:
PIcon mSyntaxError; PIcon mSyntaxError;
PIcon mSyntaxWarning; PIcon mSyntaxWarning;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -103,6 +103,7 @@ int main(int argc, char *argv[])
qRegisterMetaType<PCompileIssue>("PCompileIssue"); qRegisterMetaType<PCompileIssue>("PCompileIssue");
qRegisterMetaType<PCompileIssue>("PCompileIssue&"); qRegisterMetaType<PCompileIssue>("PCompileIssue&");
qRegisterMetaType<QVector<int>>("QVector<int>"); qRegisterMetaType<QVector<int>>("QVector<int>");
qRegisterMetaType<QHash<int,QString>>("QHash<int,QString>");
initParser(); initParser();

View File

@ -49,6 +49,14 @@
#include <widgets/searchdialog.h> #include <widgets/searchdialog.h>
static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
for (int i=0;i<tabWidget->count();i++) {
if (w==tabWidget->widget(i))
return i;
}
return -1;
}
MainWindow* pMainWindow; MainWindow* pMainWindow;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
@ -733,6 +741,8 @@ void MainWindow::updateAppTitle()
void MainWindow::addDebugOutput(const QString &text) void MainWindow::addDebugOutput(const QString &text)
{ {
if (!pSettings->debugger().enableDebugConsole())
return;
if (text.isEmpty()) { if (text.isEmpty()) {
ui->debugConsole->addLine(""); ui->debugConsole->addLine("");
} else { } else {
@ -1056,6 +1066,18 @@ void MainWindow::updateDebuggerSettings()
ui->debugConsole->setFont(font); ui->debugConsole->setFont(font);
ui->txtMemoryView->setFont(font); ui->txtMemoryView->setFont(font);
ui->txtLocals->setFont(font); ui->txtLocals->setFont(font);
int idx = findTabIndex(ui->debugViews,ui->tabDebugConsole);
if (idx>=0) {
if (!pSettings->debugger().enableDebugConsole()) {
ui->debugViews->removeTab(idx);
}
} else {
if (pSettings->debugger().enableDebugConsole()) {
ui->debugViews->insertTab(0, ui->tabDebugConsole, tr("Debug Console"));
}
}
} }
void MainWindow::checkSyntaxInBack(Editor *e) void MainWindow::checkSyntaxInBack(Editor *e)
@ -1323,12 +1345,12 @@ void MainWindow::debug()
if (!mDebugger->start()) if (!mDebugger->start())
return; return;
filePath.replace('\\','/'); filePath.replace('\\','/');
mDebugger->sendCommand("file", '"' + filePath + '"'); mDebugger->sendCommand("-file-exec-and-symbols", '"' + filePath + '"');
if (mProject->options().type == ProjectType::DynamicLib) { if (mProject->options().type == ProjectType::DynamicLib) {
QString host =mProject->options().hostApplication; QString host =mProject->options().hostApplication;
host.replace('\\','/'); host.replace('\\','/');
mDebugger->sendCommand("exec-file", '"' + host + '"'); mDebugger->sendCommand("-file-exec-file", '"' + host + '"');
} }
includeOrSkipDirs(mProject->options().includes, includeOrSkipDirs(mProject->options().includes,
@ -1398,10 +1420,9 @@ void MainWindow::debug()
prepareDebugger(); prepareDebugger();
mDebugger->setUseUTF8(e->fileEncoding() == ENCODING_UTF8 || e->fileEncoding() == ENCODING_UTF8_BOM);
if (!mDebugger->start()) if (!mDebugger->start())
return; return;
mDebugger->sendCommand("file", QString("\"%1\"").arg(debugFile.filePath().replace('\\','/'))); mDebugger->sendCommand("-file-exec-and-symbols", QString("\"%1\"").arg(debugFile.filePath().replace('\\','/')));
} }
} }
break; break;
@ -1425,48 +1446,39 @@ void MainWindow::debug()
includeOrSkipDirs(compilerSet->defaultCppIncludeDirs(),true); includeOrSkipDirs(compilerSet->defaultCppIncludeDirs(),true);
} }
// Add breakpoints and watch vars
// for i := 0 to fDebugger.WatchVarList.Count - 1 do
// fDebugger.AddWatchVar(i);
mDebugger->sendAllWatchvarsToDebugger();
mDebugger->sendAllBreakpointsToDebugger(); mDebugger->sendAllBreakpointsToDebugger();
// Run the debugger // Run the debugger
mDebugger->sendCommand("set", "width 0"); // don't wrap output, very annoying mDebugger->sendCommand("-enable-pretty-printing","");
mDebugger->sendCommand("set", "new-console on"); mDebugger->sendCommand("-data-list-register-names","");
mDebugger->sendCommand("set", "confirm off"); mDebugger->sendCommand("-gdb-set", "width 0"); // don't wrap output, very annoying
mDebugger->sendCommand("set", "print repeats 0"); // don't repeat elements mDebugger->sendCommand("-gdb-set", "new-console on");
mDebugger->sendCommand("set", "print elements 0"); // don't limit elements mDebugger->sendCommand("-gdb-set", "confirm off");
mDebugger->sendCommand("cd", excludeTrailingPathDelimiter(debugFile.path())); // restore working directory mDebugger->sendCommand("-gdb-set", "print repeats 0"); // don't repeat elements
mDebugger->sendCommand("-gdb-set", "print elements 0"); // don't limit elements
mDebugger->sendCommand("-environment-cd", excludeTrailingPathDelimiter(debugFile.path())); // restore working directory
if (!debugInferiorhasBreakpoint()) { if (!debugInferiorhasBreakpoint()) {
QString params;
switch(getCompileTarget()) { switch(getCompileTarget()) {
case CompileTarget::None: case CompileTarget::None:
return; return;
case CompileTarget::File: case CompileTarget::File:
mDebugger->sendCommand("start",params); mDebugger->sendCommand("-exec-run", "--start");
mDebugger->updateDebugInfo();
break; break;
case CompileTarget::Project: case CompileTarget::Project:
params = ""; mDebugger->sendCommand("-exec-run", "--start");
mDebugger->sendCommand("start",params);
mDebugger->updateDebugInfo();
break; break;
default: default:
break; break;
} }
} else { } else {
QString params;
switch(getCompileTarget()) { switch(getCompileTarget()) {
case CompileTarget::None: case CompileTarget::None:
return; return;
case CompileTarget::File: case CompileTarget::File:
mDebugger->sendCommand("run",params); mDebugger->sendCommand("-exec-run","");
mDebugger->updateDebugInfo();
break; break;
case CompileTarget::Project: case CompileTarget::Project:
mDebugger->sendCommand("run",params); mDebugger->sendCommand("-exec-run","");
mDebugger->updateDebugInfo();
break; break;
default: default:
break; break;
@ -1481,6 +1493,15 @@ void MainWindow::showSearchPanel(bool showReplace)
ui->tabMessages->setCurrentWidget(ui->tabSearch); ui->tabMessages->setCurrentWidget(ui->tabSearch);
} }
void MainWindow::showCPUInfoDialog()
{
if (mCPUDialog==nullptr) {
mCPUDialog = new CPUDialog(this);
connect(mCPUDialog, &CPUDialog::closed, this, &MainWindow::cleanUpCPUDialog);
}
mCPUDialog->show();
}
void MainWindow::openCloseBottomPanel(bool open) void MainWindow::openCloseBottomPanel(bool open)
{ {
// if Assigned(fReportToolWindow) then // if Assigned(fReportToolWindow) then
@ -1553,7 +1574,7 @@ void MainWindow::prepareDebugger()
// Clear logs // Clear logs
ui->debugConsole->clear(); ui->debugConsole->clear();
if (!pSettings->debugger().showCommandLog()) { if (pSettings->debugger().enableDebugConsole()) {
ui->debugConsole->addLine("(gdb) "); ui->debugConsole->addLine("(gdb) ");
} }
ui->txtEvalOutput->clear(); ui->txtEvalOutput->clear();
@ -1661,7 +1682,7 @@ void MainWindow::includeOrSkipDirs(const QStringList &dirs, bool skip)
.arg(dirName,"*.*")); .arg(dirName,"*.*"));
} else { } else {
mDebugger->sendCommand( mDebugger->sendCommand(
"dir", "-environment-directory",
QString("\"%1\"").arg(dirName)); QString("\"%1\"").arg(dirName));
} }
} }
@ -1924,13 +1945,13 @@ void MainWindow::buildContextMenus()
ui->debugConsole->setContextMenuPolicy(Qt::CustomContextMenu); ui->debugConsole->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->debugConsole,&QWidget::customContextMenuRequested, connect(ui->debugConsole,&QWidget::customContextMenuRequested,
this, &MainWindow::onDebugConsoleContextMenu); this, &MainWindow::onDebugConsoleContextMenu);
mDebugConsole_ShowCommandLog = createActionFor( mDebugConsole_ShowDetailLog = createActionFor(
tr("Show debug logs in the debug console"), tr("Show detail debug logs"),
ui->debugConsole); ui->debugConsole);
mDebugConsole_ShowCommandLog->setCheckable(true); mDebugConsole_ShowDetailLog->setCheckable(true);
connect(mDebugConsole_ShowCommandLog, &QAction::toggled, connect(mDebugConsole_ShowDetailLog, &QAction::toggled,
[this]() { [this]() {
pSettings->debugger().setShowCommandLog(mDebugConsole_ShowCommandLog->isChecked()); pSettings->debugger().setShowDetailLog(mDebugConsole_ShowDetailLog->isChecked());
pSettings->debugger().save(); pSettings->debugger().save();
}); });
mDebugConsole_Copy=createActionFor( mDebugConsole_Copy=createActionFor(
@ -2612,16 +2633,16 @@ void MainWindow::onDebugConsoleContextMenu(const QPoint &pos)
{ {
QMenu menu(this); QMenu menu(this);
bool oldBlock = mDebugConsole_ShowCommandLog->blockSignals(true); bool oldBlock = mDebugConsole_ShowDetailLog->blockSignals(true);
mDebugConsole_ShowCommandLog->setChecked(pSettings->debugger().showCommandLog()); mDebugConsole_ShowDetailLog->setChecked(pSettings->debugger().showDetailLog());
mDebugConsole_ShowCommandLog->blockSignals(oldBlock); mDebugConsole_ShowDetailLog->blockSignals(oldBlock);
menu.addAction(mDebugConsole_Copy); menu.addAction(mDebugConsole_Copy);
menu.addAction(mDebugConsole_Paste); menu.addAction(mDebugConsole_Paste);
menu.addAction(mDebugConsole_SelectAll); menu.addAction(mDebugConsole_SelectAll);
menu.addAction(mDebugConsole_Clear); menu.addAction(mDebugConsole_Clear);
menu.addSeparator(); menu.addSeparator();
menu.addAction(mDebugConsole_ShowCommandLog); menu.addAction(mDebugConsole_ShowDetailLog);
menu.exec(ui->debugConsole->mapToGlobal(pos)); menu.exec(ui->debugConsole->mapToGlobal(pos));
} }
@ -2898,7 +2919,7 @@ void MainWindow::onShowInsertCodeSnippetMenu()
} }
void MainWindow::onEditorContextMenu(const QPoint &pos) void MainWindow::onEditorContextMenu(const QPoint& pos)
{ {
Editor * editor = mEditorList->getEditor(); Editor * editor = mEditorList->getEditor();
if (!editor) if (!editor)
@ -2967,12 +2988,12 @@ void MainWindow::onEditorContextMenu(const QPoint &pos)
menu.exec(editor->viewport()->mapToGlobal(pos)); menu.exec(editor->viewport()->mapToGlobal(pos));
} }
void MainWindow::onEditorRightTabContextMenu(const QPoint &pos) void MainWindow::onEditorRightTabContextMenu(const QPoint& pos)
{ {
onEditorTabContextMenu(ui->EditorTabsRight,pos); onEditorTabContextMenu(ui->EditorTabsRight,pos);
} }
void MainWindow::onEditorLeftTabContextMenu(const QPoint &pos) void MainWindow::onEditorLeftTabContextMenu(const QPoint& pos)
{ {
onEditorTabContextMenu(ui->EditorTabsLeft,pos); onEditorTabContextMenu(ui->EditorTabsLeft,pos);
} }
@ -3020,13 +3041,13 @@ void MainWindow::disableDebugActions()
void MainWindow::enableDebugActions() void MainWindow::enableDebugActions()
{ {
ui->actionStep_Into->setEnabled(true); ui->actionStep_Into->setEnabled(!mDebugger->inferiorRunning());
ui->actionStep_Over->setEnabled(true); ui->actionStep_Over->setEnabled(!mDebugger->inferiorRunning());
ui->actionStep_Out->setEnabled(true); ui->actionStep_Out->setEnabled(!mDebugger->inferiorRunning());
ui->actionRun_To_Cursor->setEnabled(true); ui->actionRun_To_Cursor->setEnabled(!mDebugger->inferiorRunning());
ui->actionContinue->setEnabled(true); ui->actionContinue->setEnabled(!mDebugger->inferiorRunning());
ui->cbEvaluate->setEnabled(true); ui->cbEvaluate->setEnabled(!mDebugger->inferiorRunning());
ui->cbMemoryAddress->setEnabled(true); ui->cbMemoryAddress->setEnabled(!mDebugger->inferiorRunning());
} }
void MainWindow::onTodoParseStarted(const QString&) void MainWindow::onTodoParseStarted(const QString&)
@ -3034,7 +3055,7 @@ void MainWindow::onTodoParseStarted(const QString&)
mTodoModel.clear(); mTodoModel.clear();
} }
void MainWindow::onTodoParsing(const QString &filename, int lineNo, int ch, const QString &line) void MainWindow::onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line)
{ {
mTodoModel.addItem(filename,lineNo,ch,line); mTodoModel.addItem(filename,lineNo,ch,line);
} }
@ -3488,7 +3509,7 @@ void MainWindow::onCompilerSetChanged(int index)
pSettings->compilerSets().saveDefaultIndex(); pSettings->compilerSets().saveDefaultIndex();
} }
void MainWindow::onCompileLog(const QString &msg) void MainWindow::onCompileLog(const QString& msg)
{ {
ui->txtCompilerOutput->appendPlainText(msg); ui->txtCompilerOutput->appendPlainText(msg);
ui->txtCompilerOutput->moveCursor(QTextCursor::End); ui->txtCompilerOutput->moveCursor(QTextCursor::End);
@ -3629,12 +3650,12 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
updateAppTitle(); updateAppTitle();
} }
void MainWindow::onCompileErrorOccured(const QString &reason) void MainWindow::onCompileErrorOccured(const QString& reason)
{ {
QMessageBox::critical(this,tr("Compile Failed"),reason); QMessageBox::critical(this,tr("Compile Failed"),reason);
} }
void MainWindow::onRunErrorOccured(const QString &reason) void MainWindow::onRunErrorOccured(const QString& reason)
{ {
mCompilerManager->stopRun(); mCompilerManager->stopRun();
QMessageBox::critical(this,tr("Run Failed"),reason); QMessageBox::critical(this,tr("Run Failed"),reason);
@ -3669,7 +3690,7 @@ void MainWindow::onOJProblemCaseStarted(const QString& id,int current, int total
} }
} }
void MainWindow::onOJProblemCaseFinished(const QString &id, int current, int total) void MainWindow::onOJProblemCaseFinished(const QString& id, int current, int total)
{ {
int row = mOJProblemModel.getCaseIndexById(id); int row = mOJProblemModel.getCaseIndexById(id);
if (row>=0) { if (row>=0) {
@ -3698,10 +3719,10 @@ void MainWindow::cleanUpCPUDialog()
ptr->deleteLater(); ptr->deleteLater();
} }
void MainWindow::onDebugCommandInput(const QString &command) void MainWindow::onDebugCommandInput(const QString& command)
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
mDebugger->sendCommand(command,"",true,true); mDebugger->sendCommand(command,"", DebugCommandSource::Console);
} }
} }
@ -3979,10 +4000,7 @@ void MainWindow::on_actionStep_Over_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-next", "");
mDebugger->sendCommand("next", "");
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -3990,10 +4008,7 @@ void MainWindow::on_actionStep_Into_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-step", "");
mDebugger->sendCommand("step", "");
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -4002,10 +4017,7 @@ void MainWindow::on_actionStep_Out_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-finish", "");
mDebugger->sendCommand("finish", "");
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -4016,11 +4028,9 @@ void MainWindow::on_actionRun_To_Cursor_triggered()
Editor *e=mEditorList->getEditor(); Editor *e=mEditorList->getEditor();
if (e!=nullptr) { if (e!=nullptr) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-until", QString("\"%1\":%2")
mDebugger->sendCommand("tbreak", QString(" %1").arg(e->caretY())); .arg(e->filename())
mDebugger->sendCommand("continue", ""); .arg(e->caretY()));
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -4030,10 +4040,7 @@ void MainWindow::on_actionContinue_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-continue", "");
mDebugger->sendCommand("continue", "");
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -4064,11 +4071,7 @@ void MainWindow::on_actionAdd_Watch_triggered()
void MainWindow::on_actionView_CPU_Window_triggered() void MainWindow::on_actionView_CPU_Window_triggered()
{ {
if (mCPUDialog==nullptr) { showCPUInfoDialog();
mCPUDialog = new CPUDialog(this);
connect(mCPUDialog, &CPUDialog::closed, this, &MainWindow::cleanUpCPUDialog);
}
mCPUDialog->show();
} }
void MainWindow::on_actionExit_triggered() void MainWindow::on_actionExit_triggered()
@ -4082,7 +4085,7 @@ void MainWindow::onDebugEvaluateInput()
if (!s.isEmpty()) { if (!s.isEmpty()) {
connect(mDebugger, &Debugger::evalValueReady, connect(mDebugger, &Debugger::evalValueReady,
this, &MainWindow::onEvalValueReady); this, &MainWindow::onEvalValueReady);
mDebugger->sendCommand("print",s,false); mDebugger->sendCommand("-data-evaluate-expression",s);
} }
} }
@ -4092,7 +4095,7 @@ void MainWindow::onDebugMemoryAddressInput()
if (!s.isEmpty()) { if (!s.isEmpty()) {
connect(mDebugger, &Debugger::memoryExamineReady, connect(mDebugger, &Debugger::memoryExamineReady,
this, &MainWindow::onMemoryExamineReady); this, &MainWindow::onMemoryExamineReady);
mDebugger->sendCommand("x/64bx",s,false); mDebugger->sendCommand("-data-read-memory",QString("%1 x 1 8 8 ").arg(s));
} }
} }
@ -4140,14 +4143,14 @@ void MainWindow::onEndParsing(int total, int)
} }
} }
void MainWindow::onEvalValueReady(const QString &value) void MainWindow::onEvalValueReady(const QString& value)
{ {
updateDebugEval(value); updateDebugEval(value);
disconnect(mDebugger, &Debugger::evalValueReady, disconnect(mDebugger, &Debugger::evalValueReady,
this, &MainWindow::onEvalValueReady); this, &MainWindow::onEvalValueReady);
} }
void MainWindow::onMemoryExamineReady(const QStringList &value) void MainWindow::onMemoryExamineReady(const QStringList& value)
{ {
ui->txtMemoryView->clear(); ui->txtMemoryView->clear();
foreach (QString s, value) { foreach (QString s, value) {
@ -4159,7 +4162,7 @@ void MainWindow::onMemoryExamineReady(const QStringList &value)
this, &MainWindow::onMemoryExamineReady); this, &MainWindow::onMemoryExamineReady);
} }
void MainWindow::onLocalsReady(const QStringList &value) void MainWindow::onLocalsReady(const QStringList& value)
{ {
ui->txtLocals->clear(); ui->txtLocals->clear();
foreach (QString s, value) { foreach (QString s, value) {
@ -4864,14 +4867,6 @@ void MainWindow::updateEditorHideTime(QTabWidget* tabWidget) {
} }
} }
static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
for (int i=0;i<tabWidget->count();i++) {
if (w==tabWidget->widget(i))
return i;
}
return -1;
}
void MainWindow::showHideInfosTab(QWidget *widget, bool show) void MainWindow::showHideInfosTab(QWidget *widget, bool show)
{ {
int idx = findTabIndex(ui->tabInfos,widget); int idx = findTabIndex(ui->tabInfos,widget);
@ -5166,8 +5161,8 @@ void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
ui->txtProblemCaseOutput->clear(); ui->txtProblemCaseOutput->clear();
ui->txtProblemCaseOutput->setText(problemCase->output); ui->txtProblemCaseOutput->setText(problemCase->output);
if (problemCase->testState == ProblemCaseTestState::Failed) { if (problemCase->testState == ProblemCaseTestState::Failed) {
QStringList output = TextToLines(problemCase->output); QStringList output = textToLines(problemCase->output);
QStringList expected = TextToLines(problemCase->expected); QStringList expected = textToLines(problemCase->expected);
for (int i=0;i<output.count();i++) { for (int i=0;i<output.count();i++) {
if (i>=expected.count() || output[i]!=expected[i]) { if (i>=expected.count() || output[i]!=expected[i]) {
QTextBlock block = ui->txtProblemCaseOutput->document()->findBlockByLineNumber(i); QTextBlock block = ui->txtProblemCaseOutput->document()->findBlockByLineNumber(i);
@ -5747,7 +5742,6 @@ void MainWindow::on_actionDelete_to_EOL_triggered()
} }
} }
void MainWindow::on_actionDelete_to_BOL_triggered() void MainWindow::on_actionDelete_to_BOL_triggered()
{ {
Editor *e=mEditorList->getEditor(); Editor *e=mEditorList->getEditor();
@ -5755,4 +5749,3 @@ void MainWindow::on_actionDelete_to_BOL_triggered()
e->deleteToBOL(); e->deleteToBOL();
} }
} }

View File

@ -95,13 +95,13 @@ public:
void runExecutable(RunType runType = RunType::Normal); void runExecutable(RunType runType = RunType::Normal);
void debug(); void debug();
void showSearchPanel(bool showReplace = false); void showSearchPanel(bool showReplace = false);
void showCPUInfoDialog();
void applySettings(); void applySettings();
void applyUISettings(); void applyUISettings();
QFileSystemWatcher* fileSystemWatcher(); QFileSystemWatcher* fileSystemWatcher();
void removeActiveBreakpoints(); void removeActiveBreakpoints();
void setActiveBreakpoint(QString FileName, int Line, bool setFocus=true);
void updateAppTitle(); void updateAppTitle();
void addDebugOutput(const QString& text); void addDebugOutput(const QString& text);
void changeDebugOutputLastline(const QString& text); void changeDebugOutputLastline(const QString& text);
@ -193,6 +193,7 @@ public slots:
void onTodoParseStarted(const QString& filename); void onTodoParseStarted(const QString& filename);
void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line); void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line);
void onTodoParseFinished(); void onTodoParseFinished();
void setActiveBreakpoint(QString FileName, int Line, bool setFocus);
private: private:
void prepareProjectForCompile(); void prepareProjectForCompile();
@ -632,7 +633,7 @@ private:
QWidget * mFilesViewToolbar; QWidget * mFilesViewToolbar;
//action for debug console //action for debug console
QAction * mDebugConsole_ShowCommandLog; QAction * mDebugConsole_ShowDetailLog;
QAction * mDebugConsole_Clear; QAction * mDebugConsole_Clear;
QAction * mDebugConsole_Copy; QAction * mDebugConsole_Copy;
QAction * mDebugConsole_Paste; QAction * mDebugConsole_Paste;

View File

@ -85,7 +85,7 @@
<enum>QTabWidget::West</enum> <enum>QTabWidget::West</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>1</number>
</property> </property>
<property name="usesScrollButtons"> <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>
@ -174,7 +174,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<attribute name="headerDefaultSectionSize"> <attribute name="headerDefaultSectionSize">
<number>50</number> <number>100</number>
</attribute> </attribute>
</widget> </widget>
</item> </item>
@ -506,7 +506,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View File

@ -680,7 +680,7 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT
if (!bufferedText.isEmpty()) { if (!bufferedText.isEmpty()) {
parsedFile->buffer = bufferedText; parsedFile->buffer = bufferedText;
} else { } else {
parsedFile->buffer = ReadFileToLines(fileName); parsedFile->buffer = readFileToLines(fileName);
} }
} }
} else { } else {

View File

@ -74,9 +74,6 @@ public:
const QList<QString> &includePathList() const; const QList<QString> &includePathList() const;
const QList<QString> &projectIncludePathList() const; const QList<QString> &projectIncludePathList() const;
signals:
private: private:
void preprocessBuffer(); void preprocessBuffer();
void skipToEndOfPreprocessor(); void skipToEndOfPreprocessor();

View File

@ -21,7 +21,6 @@ public:
const TokenList& tokens(); const TokenList& tokens();
PToken operator[](int i); PToken operator[](int i);
int tokenCount(); int tokenCount();
signals:
private: private:
void addToken(const QString& sText, int iLine); void addToken(const QString& sText, int iLine);
void advance(); void advance();

View File

@ -22,8 +22,6 @@ public:
#ifdef QT_DEBUG #ifdef QT_DEBUG
void dumpAll(const QString& logFile); void dumpAll(const QString& logFile);
#endif #endif
signals:
private: private:
void addMember(StatementMap& map, const PStatement& statement); void addMember(StatementMap& map, const PStatement& statement);
int deleteMember(StatementMap& map, const PStatement& statement); int deleteMember(StatementMap& map, const PStatement& statement);

View File

@ -10,8 +10,8 @@ bool ProblemCaseValidator::validate(POJProblemCase problemCase)
{ {
if (!problemCase) if (!problemCase)
return false; return false;
QStringList output = TextToLines(problemCase->output); QStringList output = textToLines(problemCase->output);
QStringList expected = TextToLines(problemCase->expected); QStringList expected = textToLines(problemCase->expected);
if (output.count()!=expected.count()) if (output.count()!=expected.count())
return false; return false;
for (int i=0;i<output.count();i++) { for (int i=0;i<output.count();i++) {

View File

@ -107,9 +107,10 @@ bool Project::modified() const
// Otherwise, check all units // Otherwise, check all units
foreach (const PProjectUnit& unit, mUnits){ foreach (const PProjectUnit& unit, mUnits){
if (unit->modified()) if (unit->modified()) {
return true; return true;
} }
}
return false; return false;
} }
@ -184,10 +185,7 @@ void Project::setFileName(QString value)
void Project::setModified(bool value) void Project::setModified(bool value)
{ {
QFile file(mFilename); if (mModified!=value) {
// only mark modified if *not* read-only
if (!file.exists()
|| (file.exists() && file.isWritable())) {
mModified=value; mModified=value;
emit modifyChanged(mModified); emit modifyChanged(mModified);
} }
@ -1032,7 +1030,7 @@ void Project::buildPrivateResource(bool forceSave)
rcFile = QDir(directory()).absoluteFilePath(rcFile); rcFile = QDir(directory()).absoluteFilePath(rcFile);
if (contents.count() > 3) { if (contents.count() > 3) {
StringsToFile(contents,rcFile); stringsToFile(contents,rcFile);
mOptions.privateResource = extractRelativePath(directory(), rcFile); mOptions.privateResource = extractRelativePath(directory(), rcFile);
} else { } else {
if (fileExists(rcFile)) if (fileExists(rcFile))
@ -1073,7 +1071,7 @@ void Project::buildPrivateResource(bool forceSave)
content.append(" </dependentAssembly>"); content.append(" </dependentAssembly>");
content.append("</dependency>"); content.append("</dependency>");
content.append("</assembly>"); content.append("</assembly>");
StringsToFile(content,executable() + ".Manifest"); stringsToFile(content,executable() + ".Manifest");
} else if (fileExists(executable() + ".Manifest")) } else if (fileExists(executable() + ".Manifest"))
QFile::remove(executable() + ".Manifest"); QFile::remove(executable() + ".Manifest");
@ -1119,7 +1117,7 @@ void Project::buildPrivateResource(bool forceSave)
.arg(mOptions.versionInfo.productVersion)); .arg(mOptions.versionInfo.productVersion));
contents.append(""); contents.append("");
contents.append("#endif /*" + def + "*/"); contents.append("#endif /*" + def + "*/");
StringsToFile(contents,hFile); stringsToFile(contents,hFile);
} }
void Project::checkProjectFileForUpdate(SimpleIni &ini) void Project::checkProjectFileForUpdate(SimpleIni &ini)
@ -1599,6 +1597,7 @@ void Project::setName(const QString &newName)
if (newName != mName) { if (newName != mName) {
mName = newName; mName = newName;
mNode->text = newName; mNode->text = newName;
setModified(true);
} }
} }
@ -1772,7 +1771,7 @@ bool ProjectUnit::save()
if (!mEditor && !fileExists(mFileName)) { if (!mEditor && !fileExists(mFileName)) {
// file is neither open, nor saved // file is neither open, nor saved
QStringList temp; QStringList temp;
StringsToFile(temp,mFileName); stringsToFile(temp,mFileName);
} else if (mEditor && mEditor->modified()) { } else if (mEditor && mEditor->modified()) {
result = mEditor->save(); result = mEditor->save();
} }
@ -1885,7 +1884,7 @@ Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const
if (!p) if (!p)
return Qt::NoItemFlags; return Qt::NoItemFlags;
if (p==mProject->node().get()) if (p==mProject->node().get())
return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
if (p->unitIndex<0) { if (p->unitIndex<0) {
flags.setFlag(Qt::ItemIsDropEnabled); flags.setFlag(Qt::ItemIsDropEnabled);
@ -1903,8 +1902,13 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
if (!node) if (!node)
return false; return false;
if (role == Qt::EditRole) { if (role == Qt::EditRole) {
if (node == mProject->node()) if (node == mProject->node()) {
QString newName = value.toString().trimmed();
if (newName.isEmpty())
return false; return false;
mProject->setName(newName);
return true;
}
int idx = node->unitIndex; int idx = node->unitIndex;
if (idx >= 0) { if (idx >= 0) {
//change unit name //change unit name

View File

@ -2,8 +2,6 @@
#define PROJECT_H #define PROJECT_H
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QObject>
#include <QSettings>
#include <memory> #include <memory>
#include "projectoptions.h" #include "projectoptions.h"
#include "utils.h" #include "utils.h"

View File

@ -54,8 +54,6 @@ private:
QString mIcon; // icon in project form QString mIcon; // icon in project form
PSimpleIni mIni; PSimpleIni mIni;
int mVersion; int mVersion;
signals:
}; };
using PProjectTemplate = std::shared_ptr<ProjectTemplate>; using PProjectTemplate = std::shared_ptr<ProjectTemplate>;

View File

@ -123,7 +123,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
| eoHideShowScrollbars ; | eoHideShowScrollbars ;
mScrollTimer = new QTimer(this); mScrollTimer = new QTimer(this);
mScrollTimer->setInterval(100); //mScrollTimer->setInterval(100);
connect(mScrollTimer, &QTimer::timeout,this, &SynEdit::onScrollTimeout); connect(mScrollTimer, &QTimer::timeout,this, &SynEdit::onScrollTimeout);
mScrollHintColor = QColorConstants::Yellow; mScrollHintColor = QColorConstants::Yellow;
@ -666,9 +666,9 @@ DisplayCoord SynEdit::pixelsToNearestRowColumn(int aX, int aY) const
// don't return a partially visible last line // don't return a partially visible last line
if (aY >= mLinesInWindow * mTextHeight) { if (aY >= mLinesInWindow * mTextHeight) {
aY = mLinesInWindow * mTextHeight - 1; aY = mLinesInWindow * mTextHeight - 1;
}
if (aY < 0) if (aY < 0)
aY = 0; aY = 0;
}
return { return {
std::max(1, (int)(leftChar() + round(f))), std::max(1, (int)(leftChar() + round(f))),
std::max(1, mTopLine + (aY / mTextHeight)) std::max(1, mTopLine + (aY / mTextHeight))
@ -1763,6 +1763,52 @@ void SynEdit::doToggleComment()
doComment(); doComment();
} }
void SynEdit::doMouseScroll(bool isDragging)
{
QPoint iMousePos;
DisplayCoord C;
int X, Y;
iMousePos = QCursor::pos();
iMousePos = mapFromGlobal(iMousePos);
C = pixelsToRowColumn(iMousePos.x(), iMousePos.y());
C.Row = minMax(C.Row, 1, displayLineCount());
if (mScrollDeltaX != 0) {
setLeftChar(leftChar() + mScrollDeltaX);
X = leftChar();
if (mScrollDeltaX > 0) // scrolling right?
X+=charsInWindow();
C.Column = X;
}
if (mScrollDeltaY != 0) {
if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
setTopLine(mTopLine + mScrollDeltaY * mLinesInWindow);
else
setTopLine(mTopLine + mScrollDeltaY);
Y = mTopLine;
if (mScrollDeltaY > 0) // scrolling down?
Y+=mLinesInWindow - 1;
C.Row = minMax(Y, 1, displayLineCount());
}
BufferCoord vCaret = displayToBufferPos(C);
if ((caretX() != vCaret.Char) || (caretY() != vCaret.Line)) {
// changes to line / column in one go
incPaintLock();
auto action = finally([this]{
decPaintLock();
});
internalSetCaretXY(vCaret);
// if MouseCapture is True we're changing selection. otherwise we're dragging
if (isDragging) {
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
} else
setBlockEnd(caretXY());
}
computeScroll(iMousePos.x(), iMousePos.y(),isDragging);
}
void SynEdit::doDeleteLastChar() void SynEdit::doDeleteLastChar()
{ {
if (mReadOnly) if (mReadOnly)
@ -1819,7 +1865,7 @@ void SynEdit::doDeleteLastChar()
mLines->deleteAt(mCaretY); mLines->deleteAt(mCaretY);
doLinesDeleted(mCaretY+1, 1); doLinesDeleted(mCaretY+1, 1);
if (mOptions.testFlag(eoTrimTrailingSpaces)) if (mOptions.testFlag(eoTrimTrailingSpaces))
Temp = TrimRight(Temp); Temp = trimRight(Temp);
setLineText(lineText() + Temp); setLineText(lineText() + Temp);
helper = lineBreak(); //"/r/n" helper = lineBreak(); //"/r/n"
} }
@ -2153,7 +2199,7 @@ void SynEdit::insertLine(bool moveCaret)
rightLineText,mOptions.testFlag(eoAutoIndent) rightLineText,mOptions.testFlag(eoAutoIndent)
&& notInComment); && notInComment);
if (mOptions.testFlag(eoAutoIndent)) { if (mOptions.testFlag(eoAutoIndent)) {
rightLineText=TrimLeft(rightLineText); rightLineText=trimLeft(rightLineText);
} }
QString indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true); QString indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true);
mLines->insert(mCaretY, indentSpacesForRightLineText+rightLineText); mLines->insert(mCaretY, indentSpacesForRightLineText+rightLineText);
@ -2480,17 +2526,25 @@ void SynEdit::computeCaret(int X, int Y)
setInternalDisplayXY(vCaretNearestPos); setInternalDisplayXY(vCaretNearestPos);
} }
void SynEdit::computeScroll(int X, int Y) void SynEdit::computeScroll(int X, int Y, bool isDragging)
{ {
if (!isDragging) {
Qt::MouseButtons buttons = qApp->mouseButtons();
if (!buttons.testFlag(Qt::LeftButton))
return;
}
QRect iScrollBounds; // relative to the client area QRect iScrollBounds; // relative to the client area
// don't scroll if dragging text from other control int dispX=2,dispY = 2;
// if (not MouseCapture) and (not Dragging) then begin if (isDragging) {
// fScrollTimer.Enabled := False; dispX = mCharWidth / 2 -1;
// Exit; dispY = mTextHeight/ 2 -1;
// end; }
int left = mGutterWidth+frameWidth()+dispX;
iScrollBounds = QRect(mGutterWidth+this->frameWidth(), this->frameWidth(), mCharsInWindow * mCharWidth, int top = frameWidth()+dispY;
mLinesInWindow * mTextHeight); iScrollBounds = QRect(left,
top,
clientWidth()-left-dispX,
clientHeight()-top-dispY);
if (X < iScrollBounds.left()) if (X < iScrollBounds.left())
mScrollDeltaX = (X - iScrollBounds.left()) / mCharWidth - 1; mScrollDeltaX = (X - iScrollBounds.left()) / mCharWidth - 1;
@ -2499,6 +2553,10 @@ void SynEdit::computeScroll(int X, int Y)
else else
mScrollDeltaX = 0; mScrollDeltaX = 0;
if (isDragging && (X<0 || X>clientRect().width())) {
mScrollDeltaX = 0;
}
if (Y < iScrollBounds.top()) if (Y < iScrollBounds.top())
mScrollDeltaY = (Y - iScrollBounds.top()) / mTextHeight - 1; mScrollDeltaY = (Y - iScrollBounds.top()) / mTextHeight - 1;
else if (Y >= iScrollBounds.bottom()) else if (Y >= iScrollBounds.bottom())
@ -2506,8 +2564,17 @@ void SynEdit::computeScroll(int X, int Y)
else else
mScrollDeltaY = 0; mScrollDeltaY = 0;
if (mScrollDeltaX!=0 || mScrollDeltaY!=0) if (isDragging && (Y<0 || Y>clientRect().height())) {
mScrollTimer->start(); mScrollDeltaY = 0;
}
if (mScrollDeltaX!=0 || mScrollDeltaY!=0) {
if (isDragging) {
mScrollTimer->singleShot(100,this,&SynEdit::onDraggingScrollTimeout);
} else {
mScrollTimer->singleShot(100,this,&SynEdit::onScrollTimeout);
}
}
} }
void SynEdit::doBlockIndent() void SynEdit::doBlockIndent()
@ -2670,7 +2737,7 @@ void SynEdit::doAddChar(QChar AChar)
if (line.length() < oldCaretX) { if (line.length() < oldCaretX) {
int indentSpaces = calcIndentSpaces(oldCaretY,line+":", true); int indentSpaces = calcIndentSpaces(oldCaretY,line+":", true);
if (indentSpaces != leftSpaces(line)) { if (indentSpaces != leftSpaces(line)) {
QString newLine = GetLeftSpacing(indentSpaces,true) + TrimLeft(line); QString newLine = GetLeftSpacing(indentSpaces,true) + trimLeft(line);
int i = newLine.length(); int i = newLine.length();
mLines->putString(oldCaretY-1,newLine); mLines->putString(oldCaretY-1,newLine);
internalSetCaretXY(BufferCoord{i+1,oldCaretY}); internalSetCaretXY(BufferCoord{i+1,oldCaretY});
@ -2841,11 +2908,6 @@ void SynEdit::decPaintLock()
} }
} }
bool SynEdit::mouseCapture()
{
return hasMouseTracking();
}
int SynEdit::clientWidth() int SynEdit::clientWidth()
{ {
return viewport()->size().width(); return viewport()->size().width();
@ -4965,7 +5027,7 @@ void SynEdit::doLinesInserted(int firstLine, int count)
void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify) void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify)
{ {
if (mOptions.testFlag(eoTrimTrailingSpaces)) { if (mOptions.testFlag(eoTrimTrailingSpaces)) {
mLines->putString(ALine,TrimRight(ALineText),notify); mLines->putString(ALine,trimRight(ALineText),notify);
} else { } else {
mLines->putString(ALine,ALineText,notify); mLines->putString(ALine,ALineText,notify);
} }
@ -5077,7 +5139,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
int startLine = mCaretY; int startLine = mCaretY;
sLeftSide = lineText().mid(0, mCaretX - 1); sLeftSide = lineText().mid(0, mCaretX - 1);
if (mCaretX - 1 > sLeftSide.length()) { if (mCaretX - 1 > sLeftSide.length()) {
if (StringIsBlank(sLeftSide)) if (stringIsBlank(sLeftSide))
sLeftSide = GetLeftSpacing(displayX() - 1, true); sLeftSide = GetLeftSpacing(displayX() - 1, true);
else else
sLeftSide += QString(mCaretX - 1 - sLeftSide.length(),' '); sLeftSide += QString(mCaretX - 1 - sLeftSide.length(),' ');
@ -5093,7 +5155,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = 0; Start = 0;
P = GetEOL(Value,Start); P = GetEOL(Value,Start);
if (P<Value.length()) { if (P<Value.length()) {
QString s = TrimLeft(Value.mid(0, P - Start)); QString s = trimLeft(Value.mid(0, P - Start));
if (sLeftSide.isEmpty()) { if (sLeftSide.isEmpty()) {
sLeftSide = GetLeftSpacing(calcIndentSpaces(caretY,s,true),true); sLeftSide = GetLeftSpacing(calcIndentSpaces(caretY,s,true),true);
} }
@ -5126,7 +5188,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Str += sRightSide; Str += sRightSide;
if (mOptions.testFlag(eoAutoIndent)) { if (mOptions.testFlag(eoAutoIndent)) {
int indentSpaces = calcIndentSpaces(caretY,Str,true); int indentSpaces = calcIndentSpaces(caretY,Str,true);
Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str); Str = GetLeftSpacing(indentSpaces,true)+trimLeft(Str);
} }
} }
properSetLine(caretY - 1, Str,false); properSetLine(caretY - 1, Str,false);
@ -5948,7 +6010,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
// setBlockBegin(TmpBegin); // setBlockBegin(TmpBegin);
// setBlockEnd(TmpEnd); // setBlockEnd(TmpEnd);
setMouseTracking(true); //setMouseTracking(true);
//if mousedown occurred in selected block begin drag operation //if mousedown occurred in selected block begin drag operation
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2) if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
@ -5985,10 +6047,10 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event)
processGutterClick(event); processGutterClick(event);
} }
mScrollTimer->stop(); //mScrollTimer->stop();
// if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then // if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then
// exit; // exit;
setMouseTracking(false); //setMouseTracking(false);
if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) && if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) &&
!mStateFlags.testFlag(SynStateFlag::sfDblClicked)) { !mStateFlags.testFlag(SynStateFlag::sfDblClicked)) {
@ -6008,9 +6070,6 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
Qt::MouseButtons buttons = event->buttons(); Qt::MouseButtons buttons = event->buttons();
int X=event->pos().x(); int X=event->pos().x();
int Y=event->pos().y(); int Y=event->pos().y();
// if (!hasMouseTracking())
// return;
if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) {
if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
@ -6024,10 +6083,9 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
//drag->setPixmap(iconPixmap); //drag->setPixmap(iconPixmap);
//BeginDrag(false); //BeginDrag(false);
} }
// } else if ((buttons == Qt::LeftButton) && (X > mGutterWidth)) {
} else if ((buttons == Qt::LeftButton)) { } else if ((buttons == Qt::LeftButton)) {
// should we begin scrolling? // should we begin scrolling?
computeScroll(X, Y); computeScroll(X, Y,false);
DisplayCoord P = pixelsToNearestRowColumn(X, Y); DisplayCoord P = pixelsToNearestRowColumn(X, Y);
P.Row = minMax(P.Row, 1, displayLineCount()); P.Row = minMax(P.Row, 1, displayLineCount());
if (mScrollDeltaX != 0) if (mScrollDeltaX != 0)
@ -6144,20 +6202,61 @@ void SynEdit::dragEnterEvent(QDragEnterEvent *event)
void SynEdit::dropEvent(QDropEvent *event) void SynEdit::dropEvent(QDropEvent *event)
{ {
mUndoList->BeginBlock(); //mScrollTimer->stop();
auto action = finally([this] {
mUndoList->EndBlock();
});
if (event->proposedAction() == Qt::DropAction::MoveAction) {
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
setSelText("");
}
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(), BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
event->pos().y())); event->pos().y()));
setCaretXY(coord); setCaretXY(coord);
if (coord>=mDragSelBeginSave && coord<=mDragSelEndSave) {
//do nothing if drag onto itself
} else if (event->proposedAction() == Qt::DropAction::CopyAction) {
//just copy it
setSelText(event->mimeData()->text()); setSelText(event->mimeData()->text());
} else if (event->proposedAction() == Qt::DropAction::MoveAction) {
int topLine = mTopLine;
int leftChar = mLeftChar;
mUndoList->BeginBlock();
if (coord < mDragSelBeginSave ) {
//delete old
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
setSelText("");
//paste to new position
setTopLine(topLine);
setLeftChar(leftChar);
setCaretXY(coord);
setSelText(event->mimeData()->text());
} else {
//paste to new position
setTopLine(topLine);
setLeftChar(leftChar);
setCaretXY(coord);
setSelText(event->mimeData()->text());
//delete old
setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave);
setSelText("");
//set caret to right pos
if (mDragSelBeginSave.Line == mDragSelEndSave.Line) {
if (coord.Line == mDragSelEndSave.Line) {
coord.Char -= mDragSelEndSave.Char-mDragSelBeginSave.Char;
}
} else {
if (coord.Line == mDragSelEndSave.Line) {
coord.Char -= mDragSelEndSave.Char-1;
} else {
coord.Line -= mDragSelEndSave.Line-mDragSelBeginSave.Line;
topLine -= mDragSelEndSave.Line-mDragSelBeginSave.Line;
}
}
setTopLine(topLine);
setLeftChar(leftChar);
setCaretXY(coord);
}
mUndoList->EndBlock();
}
event->acceptProposedAction(); event->acceptProposedAction();
} }
void SynEdit::dragMoveEvent(QDragMoveEvent *event) void SynEdit::dragMoveEvent(QDragMoveEvent *event)
@ -6167,9 +6266,13 @@ void SynEdit::dragMoveEvent(QDragMoveEvent *event)
} else { } else {
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
} }
// should we begin scrolling?
computeScroll(event->pos().x(),
event->pos().y(),true);
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(), BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
event->pos().y())); event->pos().y()));
setCaretXY(coord); internalSetCaretXY(coord);
setBlockBegin(mDragSelBeginSave); setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave); setBlockEnd(mDragSelEndSave);
showCaret(); showCaret();
@ -6177,10 +6280,10 @@ void SynEdit::dragMoveEvent(QDragMoveEvent *event)
void SynEdit::dragLeaveEvent(QDragLeaveEvent *) void SynEdit::dragLeaveEvent(QDragLeaveEvent *)
{ {
setCaretXY(mDragCaretSave); // setCaretXY(mDragCaretSave);
setBlockBegin(mDragSelBeginSave); // setBlockBegin(mDragSelBeginSave);
setBlockEnd(mDragSelEndSave); // setBlockEnd(mDragSelEndSave);
showCaret(); // showCaret();
} }
int SynEdit::maxScrollHeight() const int SynEdit::maxScrollHeight() const
@ -6556,43 +6659,10 @@ void SynEdit::onGutterChanged()
void SynEdit::onScrollTimeout() void SynEdit::onScrollTimeout()
{ {
QPoint iMousePos; doMouseScroll(false);
DisplayCoord C; }
int X, Y;
void SynEdit::onDraggingScrollTimeout()
iMousePos = QCursor::pos(); {
iMousePos = mapFromGlobal(iMousePos); doMouseScroll(true);
C = pixelsToRowColumn(iMousePos.x(), iMousePos.y());
C.Row = minMax(C.Row, 1, displayLineCount());
if (mScrollDeltaX != 0) {
setLeftChar(leftChar() + mScrollDeltaX);
X = leftChar();
if (mScrollDeltaX > 0) // scrolling right?
X+=charsInWindow();
C.Column = X;
}
if (mScrollDeltaY != 0) {
if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
setTopLine(mTopLine + mScrollDeltaY * mLinesInWindow);
else
setTopLine(mTopLine + mScrollDeltaY);
Y = mTopLine;
if (mScrollDeltaY > 0) // scrolling down?
Y+=mLinesInWindow - 1;
C.Row = minMax(Y, 1, displayLineCount());
}
BufferCoord vCaret = displayToBufferPos(C);
if ((caretX() != vCaret.Char) || (caretY() != vCaret.Line)) {
// changes to line / column in one go
incPaintLock();
auto action = finally([this]{
decPaintLock();
});
internalSetCaretXY(vCaret);
// if MouseCapture is True we're changing selection. otherwise we're dragging
// if (mouseCapture())
setBlockEnd(caretXY());
}
computeScroll(iMousePos.x(), iMousePos.y());
} }

View File

@ -432,11 +432,10 @@ protected:
private: private:
void clearAreaList(SynEditingAreaList areaList); void clearAreaList(SynEditingAreaList areaList);
void computeCaret(int X, int Y); void computeCaret(int X, int Y);
void computeScroll(int X, int Y); void computeScroll(int X, int Y, bool isDragging);
void incPaintLock(); void incPaintLock();
void decPaintLock(); void decPaintLock();
bool mouseCapture();
int clientWidth(); int clientWidth();
int clientHeight(); int clientHeight();
int clientTop(); int clientTop();
@ -562,6 +561,7 @@ private:
void doComment(); void doComment();
void doUncomment(); void doUncomment();
void doToggleComment(); void doToggleComment();
void doMouseScroll(bool isDragging);
private slots: private slots:
@ -575,6 +575,7 @@ private slots:
void onLinesPutted(int index, int count); void onLinesPutted(int index, int count);
void onRedoAdded(); void onRedoAdded();
void onScrollTimeout(); void onScrollTimeout();
void onDraggingScrollTimeout();
void onUndoAdded(); void onUndoAdded();
void onSizeOrFontChanged(bool bFont); void onSizeOrFontChanged(bool bFont);
void onChanged(); void onChanged();
@ -701,6 +702,7 @@ private:
BufferCoord mDragCaretSave; BufferCoord mDragCaretSave;
BufferCoord mDragSelBeginSave; BufferCoord mDragSelBeginSave;
BufferCoord mDragSelEndSave; BufferCoord mDragSelEndSave;
bool mDragging;
friend class SynEditTextPainter; friend class SynEditTextPainter;

View File

@ -493,7 +493,7 @@ void SynEditStringList::insertText(int Index, const QString &NewText)
} }
if (NewText.isEmpty()) if (NewText.isEmpty())
return; return;
QStringList lines = TextToLines(NewText); QStringList lines = textToLines(NewText);
insertStrings(Index,lines); insertStrings(Index,lines);
} }
@ -540,14 +540,14 @@ void SynEditStringList::loadFromFile(const QString& filename, const QByteArray&
allAscii = isTextAllAscii(line); allAscii = isTextAllAscii(line);
} }
if (allAscii) { if (allAscii) {
addItem(TrimRight(QString::fromLatin1(line))); addItem(trimRight(QString::fromLatin1(line)));
} else { } else {
QString newLine = codec->toUnicode(line.constData(),line.length(),&state); QString newLine = codec->toUnicode(line.constData(),line.length(),&state);
if (state.invalidChars>0) { if (state.invalidChars>0) {
needReread = true; needReread = true;
break; break;
} }
addItem(TrimRight(newLine)); addItem(trimRight(newLine));
} }
if (file.atEnd()){ if (file.atEnd()){
break; break;
@ -580,7 +580,7 @@ void SynEditStringList::loadFromFile(const QString& filename, const QByteArray&
QString line; QString line;
internalClear(); internalClear();
while (textStream.readLineInto(&line)) { while (textStream.readLineInto(&line)) {
addItem(TrimRight(line)); addItem(trimRight(line));
} }
emit inserted(0,mList.count()); emit inserted(0,mList.count());
} }

View File

@ -239,3 +239,32 @@ bool BufferCoord::operator==(const BufferCoord &coord)
{ {
return coord.Char == Char && coord.Line == Line; return coord.Char == Char && coord.Line == Line;
} }
bool BufferCoord::operator>=(const BufferCoord &coord)
{
return (Line > coord.Line)
|| (Line == coord.Line && Char >= coord.Char);
}
bool BufferCoord::operator>(const BufferCoord &coord)
{
return (Line > coord.Line)
|| (Line == coord.Line && Char > coord.Char);
}
bool BufferCoord::operator<(const BufferCoord &coord)
{
return (Line < coord.Line)
|| (Line == coord.Line && Char < coord.Char);
}
bool BufferCoord::operator<=(const BufferCoord &coord)
{
return (Line < coord.Line)
|| (Line == coord.Line && Char <= coord.Char);
}
bool BufferCoord::operator!=(const BufferCoord &coord)
{
return coord.Char != Char || coord.Line != Line;
}

View File

@ -11,6 +11,11 @@ struct BufferCoord {
int Char; int Char;
int Line; int Line;
bool operator==(const BufferCoord& coord); bool operator==(const BufferCoord& coord);
bool operator>=(const BufferCoord& coord);
bool operator>(const BufferCoord& coord);
bool operator<(const BufferCoord& coord);
bool operator<=(const BufferCoord& coord);
bool operator!=(const BufferCoord& coord);
}; };
class SynEdit; class SynEdit;

View File

@ -2924,24 +2924,24 @@ Settings::Debugger::Debugger(Settings *settings):_Base(settings, SETTING_DEBUGGE
} }
bool Settings::Debugger::showCommandLog() const bool Settings::Debugger::enableDebugConsole() const
{ {
return mShowCommandLog; return mEnableDebugConsole;
} }
void Settings::Debugger::setShowCommandLog(bool showCommandLog) void Settings::Debugger::setEnableDebugConsole(bool showCommandLog)
{ {
mShowCommandLog = showCommandLog; mEnableDebugConsole = showCommandLog;
} }
bool Settings::Debugger::showAnnotations() const bool Settings::Debugger::showDetailLog() const
{ {
return mShowAnnotations; return mShowDetailLog;
} }
void Settings::Debugger::setShowAnnotations(bool showAnnotations) void Settings::Debugger::setShowDetailLog(bool showAnnotations)
{ {
mShowAnnotations = showAnnotations; mShowDetailLog = showAnnotations;
} }
QString Settings::Debugger::fontName() const QString Settings::Debugger::fontName() const
@ -3004,6 +3004,16 @@ void Settings::Debugger::setAutosaveWatches(bool newAutosaveWatches)
mAutosaveWatches = newAutosaveWatches; mAutosaveWatches = newAutosaveWatches;
} }
bool Settings::Debugger::openCPUInfoWhenSignaled() const
{
return mOpenCPUInfoWhenSignaled;
}
void Settings::Debugger::setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled)
{
mOpenCPUInfoWhenSignaled = newOpenCPUInfoWhenSignaled;
}
bool Settings::Debugger::autosaveBreakpoints() const bool Settings::Debugger::autosaveBreakpoints() const
{ {
return mAutosaveBreakpoints; return mAutosaveBreakpoints;
@ -3046,8 +3056,8 @@ void Settings::Debugger::setOnlyShowMono(bool onlyShowMono)
void Settings::Debugger::doSave() void Settings::Debugger::doSave()
{ {
saveValue("show_command_log", mShowCommandLog); saveValue("enable_debug_console", mEnableDebugConsole);
saveValue("show_annotations", mShowAnnotations); saveValue("show_detail_log", mShowDetailLog);
saveValue("font_name",mFontName); saveValue("font_name",mFontName);
saveValue("only_show_mono",mOnlyShowMono); saveValue("only_show_mono",mOnlyShowMono);
saveValue("font_size",mFontSize); saveValue("font_size",mFontSize);
@ -3058,13 +3068,14 @@ void Settings::Debugger::doSave()
saveValue("skip_custom_lib", mSkipCustomLibraries); saveValue("skip_custom_lib", mSkipCustomLibraries);
saveValue("autosave_breakpoints",mAutosaveBreakpoints); saveValue("autosave_breakpoints",mAutosaveBreakpoints);
saveValue("autosave_watches",mAutosaveWatches); saveValue("autosave_watches",mAutosaveWatches);
saveValue("open_cpu_info_when_signaled",mOpenCPUInfoWhenSignaled);
} }
void Settings::Debugger::doLoad() void Settings::Debugger::doLoad()
{ {
mShowCommandLog = boolValue("show_command_log",true); mEnableDebugConsole = boolValue("enable_debug_console",true);
mShowAnnotations = boolValue("show_annotations",false); mShowDetailLog = boolValue("show_detail_log",false);
mFontName = stringValue("font_name","Consolas"); mFontName = stringValue("font_name","Consolas");
mOnlyShowMono = boolValue("only_show_mono",true); mOnlyShowMono = boolValue("only_show_mono",true);
mFontSize = intValue("font_size",12); mFontSize = intValue("font_size",12);
@ -3075,6 +3086,7 @@ void Settings::Debugger::doLoad()
mSkipCustomLibraries = boolValue("skip_custom_lib",false); mSkipCustomLibraries = boolValue("skip_custom_lib",false);
mAutosaveBreakpoints = boolValue("autosave_breakpoints",true); mAutosaveBreakpoints = boolValue("autosave_breakpoints",true);
mAutosaveWatches = boolValue("autosave_watches",true); mAutosaveWatches = boolValue("autosave_watches",true);
mOpenCPUInfoWhenSignaled = boolValue("open_cpu_info_when_signaled",true);
} }
Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY) Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)

View File

@ -930,11 +930,11 @@ public:
class Debugger: public _Base { class Debugger: public _Base {
public: public:
explicit Debugger(Settings* settings); explicit Debugger(Settings* settings);
bool showCommandLog() const; bool enableDebugConsole() const;
void setShowCommandLog(bool showCommandLog); void setEnableDebugConsole(bool showCommandLog);
bool showAnnotations() const; bool showDetailLog() const;
void setShowAnnotations(bool showAnnotations); void setShowDetailLog(bool showAnnotations);
bool onlyShowMono() const; bool onlyShowMono() const;
void setOnlyShowMono(bool onlyShowMono); void setOnlyShowMono(bool onlyShowMono);
@ -964,9 +964,12 @@ public:
bool autosaveWatches() const; bool autosaveWatches() const;
void setAutosaveWatches(bool newAutosaveWatches); void setAutosaveWatches(bool newAutosaveWatches);
bool openCPUInfoWhenSignaled() const;
void setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled);
private: private:
bool mShowCommandLog; bool mEnableDebugConsole;
bool mShowAnnotations; bool mShowDetailLog;
QString mFontName; QString mFontName;
bool mOnlyShowMono; bool mOnlyShowMono;
int mFontSize; int mFontSize;
@ -977,6 +980,7 @@ public:
bool mSkipCustomLibraries; bool mSkipCustomLibraries;
bool mAutosaveBreakpoints; bool mAutosaveBreakpoints;
bool mAutosaveWatches; bool mAutosaveWatches;
bool mOpenCPUInfoWhenSignaled;
// _Base interface // _Base interface
protected: protected:

View File

@ -20,13 +20,14 @@ void DebugGeneralWidget::doLoad()
ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono()); ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono());
ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName())); ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName()));
ui->sbFontSize->setValue(pSettings->debugger().fontSize()); ui->sbFontSize->setValue(pSettings->debugger().fontSize());
ui->chkShowLog->setChecked(pSettings->debugger().showCommandLog()); ui->grpEnableDebugConsole->setChecked(pSettings->debugger().enableDebugConsole());
ui->chkShowFullAnnotation->setChecked(pSettings->debugger().showAnnotations()); ui->chkShowDetailLog->setChecked(pSettings->debugger().showDetailLog());
if (pSettings->debugger().useIntelStyle()) { if (pSettings->debugger().useIntelStyle()) {
ui->rbIntel->setChecked(true); ui->rbIntel->setChecked(true);
} else { } else {
ui->rbATT->setChecked(true); ui->rbATT->setChecked(true);
} }
ui->chkShowCPUWhenSignaled->setChecked(pSettings->debugger().openCPUInfoWhenSignaled());
ui->chkBlendMode->setChecked(pSettings->debugger().blendMode()); ui->chkBlendMode->setChecked(pSettings->debugger().blendMode());
ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries()); ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries());
ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries()); ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries());
@ -40,8 +41,9 @@ void DebugGeneralWidget::doSave()
pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked()); pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked());
pSettings->debugger().setFontName(ui->cbFont->currentFont().family()); pSettings->debugger().setFontName(ui->cbFont->currentFont().family());
pSettings->debugger().setFontSize(ui->sbFontSize->value()); pSettings->debugger().setFontSize(ui->sbFontSize->value());
pSettings->debugger().setShowCommandLog(ui->chkShowLog->isChecked()); pSettings->debugger().setEnableDebugConsole(ui->grpEnableDebugConsole->isChecked());
pSettings->debugger().setShowAnnotations(ui->chkShowFullAnnotation->isChecked()); pSettings->debugger().setShowDetailLog(ui->chkShowDetailLog->isChecked());
pSettings->debugger().setOpenCPUInfoWhenSignaled(ui->chkShowCPUWhenSignaled);
pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked()); pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked());
pSettings->debugger().setBlendMode(ui->chkBlendMode->isChecked()); pSettings->debugger().setBlendMode(ui->chkBlendMode->isChecked());
pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked()); pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked());

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>677</width> <width>704</width>
<height>563</height> <height>563</height>
</rect> </rect>
</property> </property>
@ -36,7 +36,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="grpEnableDebugConsole">
<property name="title"> <property name="title">
<string>Debug Console</string> <string>Debug Console</string>
</property> </property>
@ -143,16 +143,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="chkShowLog"> <widget class="QCheckBox" name="chkShowDetailLog">
<property name="text"> <property name="text">
<string>Show debug logs in the debug console</string> <string>Show detail debug logs</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowFullAnnotation">
<property name="text">
<string>Show full gdb annotations</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -182,6 +175,13 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="chkShowCPUWhenSignaled">
<property name="text">
<string>Show CPU Window when signal received</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">

View File

@ -4,7 +4,6 @@
#include "../settings.h" #include "../settings.h"
#include <QMessageBox> #include <QMessageBox>
#include <QSettings>
#include <windows.h> #include <windows.h>
EnvironmentFileAssociationWidget::EnvironmentFileAssociationWidget(const QString& name, const QString& group, QWidget *parent) : EnvironmentFileAssociationWidget::EnvironmentFileAssociationWidget(const QString& name, const QString& group, QWidget *parent) :

View File

@ -26,8 +26,6 @@ public:
void setShortcuts(QList<PEnvironmentShortcut> shortcuts); void setShortcuts(QList<PEnvironmentShortcut> shortcuts);
void applyTo(QList<QAction*> actions); void applyTo(QList<QAction*> actions);
void applyTo(QAction* action); void applyTo(QAction* action);
signals:
private:
private: private:
QMap<QString,PEnvironmentShortcut> mShortcuts; QMap<QString,PEnvironmentShortcut> mShortcuts;

View File

@ -22,7 +22,6 @@ public:
void reset(); void reset();
PSymbolUsage findUsage(const QString& fullName) const; PSymbolUsage findUsage(const QString& fullName) const;
void updateUsage(const QString& symbol, int count); void updateUsage(const QString& symbol, int count);
signals:
private: private:
QHash<QString, PSymbolUsage> mUsages; QHash<QString, PSymbolUsage> mUsages;
}; };

View File

@ -86,7 +86,6 @@ class ThemeManager : public QObject
public: public:
explicit ThemeManager(QObject *parent = nullptr); explicit ThemeManager(QObject *parent = nullptr);
PAppTheme theme(const QString& themeName); PAppTheme theme(const QString& themeName);
signals:
}; };
#endif // THEMEMANAGER_H #endif // THEMEMANAGER_H

View File

@ -64,7 +64,6 @@ public:
void parseFile(const QString& filename); void parseFile(const QString& filename);
bool parsing() const; bool parsing() const;
signals:
private: private:
TodoThread* mThread; TodoThread* mThread;
QRecursiveMutex mMutex; QRecursiveMutex mMutex;

View File

@ -24,8 +24,6 @@ public:
const QList<PToolItem> &tools() const; const QList<PToolItem> &tools() const;
PToolItem findTool(const QString& title); PToolItem findTool(const QString& title);
void setTools(const QList<PToolItem> &newTools); void setTools(const QList<PToolItem> &newTools);
signals:
private: private:
QList<PToolItem> mTools; QList<PToolItem> mTools;
}; };

View File

@ -7,7 +7,6 @@
#include <QFileInfo> #include <QFileInfo>
#include <QProcess> #include <QProcess>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QSettings>
#include <QString> #include <QString>
#include <QTextCodec> #include <QTextCodec>
#include <QtGlobal> #include <QtGlobal>
@ -292,25 +291,25 @@ QString toLocalPath(const QString &filename)
return newPath; return newPath;
} }
QStringList TextToLines(const QString &text) QStringList textToLines(const QString &text)
{ {
QTextStream stream(&((QString&)text),QIODevice::ReadOnly); QTextStream stream(&((QString&)text),QIODevice::ReadOnly);
return ReadStreamToLines(&stream); return readStreamToLines(&stream);
} }
QStringList ReadFileToLines(const QString& fileName, QTextCodec* codec) QStringList readFileToLines(const QString& fileName, QTextCodec* codec)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QFile::ReadOnly)) { if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file); QTextStream stream(&file);
stream.setCodec(codec); stream.setCodec(codec);
stream.setAutoDetectUnicode(false); stream.setAutoDetectUnicode(false);
return ReadStreamToLines(&stream); return readStreamToLines(&stream);
} }
return QStringList(); return QStringList();
} }
QStringList ReadStreamToLines(QTextStream *stream) QStringList readStreamToLines(QTextStream *stream)
{ {
QStringList list; QStringList list;
QString s; QString s;
@ -320,7 +319,7 @@ QStringList ReadStreamToLines(QTextStream *stream)
return list; return list;
} }
void ReadStreamToLines(QTextStream *stream, void readStreamToLines(QTextStream *stream,
LineProcessFunc lineFunc) LineProcessFunc lineFunc)
{ {
QString s; QString s;
@ -329,20 +328,20 @@ void ReadStreamToLines(QTextStream *stream,
} }
} }
void TextToLines(const QString &text, LineProcessFunc lineFunc) void textToLines(const QString &text, LineProcessFunc lineFunc)
{ {
QTextStream stream(&((QString&)text),QIODevice::ReadOnly); QTextStream stream(&((QString&)text),QIODevice::ReadOnly);
ReadStreamToLines(&stream,lineFunc); readStreamToLines(&stream,lineFunc);
} }
void ReadFileToLines(const QString &fileName, QTextCodec *codec, LineProcessFunc lineFunc) void readFileToLines(const QString &fileName, QTextCodec *codec, LineProcessFunc lineFunc)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QFile::ReadOnly)) { if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file); QTextStream stream(&file);
stream.setCodec(codec); stream.setCodec(codec);
stream.setAutoDetectUnicode(false); stream.setAutoDetectUnicode(false);
ReadStreamToLines(&stream, lineFunc); readStreamToLines(&stream, lineFunc);
} }
} }
@ -402,7 +401,7 @@ void inflateRect(QRect &rect, int dx, int dy)
rect.setBottom(rect.bottom()+dy); rect.setBottom(rect.bottom()+dy);
} }
QString TrimRight(const QString &s) QString trimRight(const QString &s)
{ {
if (s.isEmpty()) if (s.isEmpty())
return s; return s;
@ -418,7 +417,7 @@ QString TrimRight(const QString &s)
} }
} }
bool StringIsBlank(const QString &s) bool stringIsBlank(const QString &s)
{ {
for (QChar ch:s) { for (QChar ch:s) {
if (ch != ' ' && ch != '\t') if (ch != ' ' && ch != '\t')
@ -427,7 +426,7 @@ bool StringIsBlank(const QString &s)
return true; return true;
} }
QString TrimLeft(const QString &s) QString trimLeft(const QString &s)
{ {
if (s.isEmpty()) if (s.isEmpty())
return s; return s;
@ -503,7 +502,7 @@ QString changeFileExt(const QString& filename, QString ext)
} }
} }
QStringList ReadFileToLines(const QString &fileName) QStringList readFileToLines(const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (file.size()<=0) if (file.size()<=0)
@ -540,7 +539,7 @@ QStringList ReadFileToLines(const QString &fileName)
return result; return result;
} }
void StringsToFile(const QStringList &list, const QString &fileName) void stringsToFile(const QStringList &list, const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
@ -749,7 +748,7 @@ QString fromByteArray(const QByteArray &s)
return QString::fromLocal8Bit(s); return QString::fromLocal8Bit(s);
} }
QString LinesToText(const QStringList &lines) QString linesToText(const QStringList &lines)
{ {
return lines.join("\n"); return lines.join("\n");
} }
@ -832,7 +831,7 @@ void executeFile(const QString &fileName, const QString &params, const QString &
); );
} }
void StringToFile(const QString &str, const QString &fileName) void stringToFile(const QString &str, const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
@ -847,7 +846,7 @@ bool removeFile(const QString &filename)
return file.remove(); return file.remove();
} }
QByteArray ReadFileToByteArray(const QString &fileName) QByteArray readFileToByteArray(const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QFile::ReadOnly)) { if (file.open(QFile::ReadOnly)) {
@ -894,3 +893,40 @@ bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QSt
delete [] buffer; delete [] buffer;
return true; return true;
} }
QList<QByteArray> splitByteArrayToLines(const QByteArray &content)
{
QList<QByteArray> lines;
const char* p =content.constData();
const char* end = p+content.length();
const char* lineStart = p;
QByteArray line;
while (p<=end) {
char ch=*p;
switch(ch) {
case '\r':
line = QByteArray(lineStart, p-lineStart);
lines.append(line);
p++;
if (*p=='\n')
p++;
lineStart = p;
break;
case '\n':
line = QByteArray(lineStart, p-lineStart);
lines.append(line);
p++;
lineStart = p;
break;
default:
p++;
}
}
if (lineStart>end) {
lines.append("");
} else {
line = QByteArray(lineStart, end-lineStart+1);
lines.append(line);
}
return lines;
}

View File

@ -143,28 +143,30 @@ bool programHasConsole(const QString& filename);
QString toLocalPath(const QString& filename); QString toLocalPath(const QString& filename);
using LineProcessFunc = std::function<void(const QString&)>; using LineProcessFunc = std::function<void(const QString&)>;
QStringList ReadStreamToLines(QTextStream* stream); QStringList readStreamToLines(QTextStream* stream);
void ReadStreamToLines(QTextStream* stream, LineProcessFunc lineFunc); void readStreamToLines(QTextStream* stream, LineProcessFunc lineFunc);
QStringList TextToLines(const QString& text); QStringList textToLines(const QString& text);
void TextToLines(const QString& text, LineProcessFunc lineFunc); void textToLines(const QString& text, LineProcessFunc lineFunc);
QString LinesToText(const QStringList& lines); QString linesToText(const QStringList& lines);
QList<QByteArray> splitByteArrayToLines(const QByteArray& content);
QString parseMacros(const QString& s); QString parseMacros(const QString& s);
QStringList ReadFileToLines(const QString& fileName, QTextCodec* codec); QStringList readFileToLines(const QString& fileName, QTextCodec* codec);
QStringList ReadFileToLines(const QString& fileName); QStringList readFileToLines(const QString& fileName);
QByteArray ReadFileToByteArray(const QString& fileName); QByteArray readFileToByteArray(const QString& fileName);
void ReadFileToLines(const QString& fileName, QTextCodec* codec, LineProcessFunc lineFunc); void readFileToLines(const QString& fileName, QTextCodec* codec, LineProcessFunc lineFunc);
void StringsToFile(const QStringList& list, const QString& fileName); void stringsToFile(const QStringList& list, const QString& fileName);
void StringToFile(const QString& str, const QString& fileName); void stringToFile(const QString& str, const QString& fileName);
void decodeKey(int combinedKey, int& key, Qt::KeyboardModifiers& modifiers); void decodeKey(int combinedKey, int& key, Qt::KeyboardModifiers& modifiers);
void inflateRect(QRect& rect, int delta); void inflateRect(QRect& rect, int delta);
void inflateRect(QRect& rect, int dx, int dy); void inflateRect(QRect& rect, int dx, int dy);
QString TrimRight(const QString& s); QString trimRight(const QString& s);
QString TrimLeft(const QString& s); QString trimLeft(const QString& s);
bool StringIsBlank(const QString& s); bool stringIsBlank(const QString& s);
int compareFileModifiedTime(const QString& filename1, const QString& filename2); int compareFileModifiedTime(const QString& filename1, const QString& filename2);
QByteArray getHTTPBody(const QByteArray& content); QByteArray getHTTPBody(const QByteArray& content);
bool haveGoodContrast(const QColor& c1, const QColor &c2); bool haveGoodContrast(const QColor& c1, const QColor &c2);

View File

@ -2,6 +2,6 @@
#define VERSION_H #define VERSION_H
#include <QObject> #include <QObject>
#define DEVCPP_VERSION "beta.0.9.4" #define DEVCPP_VERSION "beta.0.10.2"
#endif // VERSION_H #endif // VERSION_H

View File

@ -54,6 +54,9 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEdit"> <widget class="QPlainTextEdit" name="plainTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText"> <property name="plainText">
<string> This program is free software: you can redistribute it and/or modify <string> This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -57,7 +57,7 @@ void CPUDialog::updateInfo()
if (pMainWindow->debugger()->executing()) { if (pMainWindow->debugger()->executing()) {
// Load the registers.. // Load the registers..
sendSyntaxCommand(); sendSyntaxCommand();
pMainWindow->debugger()->sendCommand("info", "registers"); pMainWindow->debugger()->sendCommand("-data-list-register-values", "N");
if (ui->chkBlendMode->isChecked()) if (ui->chkBlendMode->isChecked())
pMainWindow->debugger()->sendCommand("disas", "/s"); pMainWindow->debugger()->sendCommand("disas", "/s");
else else
@ -65,14 +65,12 @@ void CPUDialog::updateInfo()
} }
} }
void CPUDialog::setDisassembly(const QStringList &lines) void CPUDialog::setDisassembly(const QString& file, const QString& funcName,const QStringList& lines)
{ {
if (lines.size()>0) { ui->txtFunctionName->setText(QString("%1:%2").arg(file, funcName));
ui->txtFunctionName->setText(lines[0]);
}
int activeLine = -1; int activeLine = -1;
ui->txtCode->lines()->clear(); ui->txtCode->lines()->clear();
for (int i=1;i<lines.size();i++) { for (int i=0;i<lines.size();i++) {
QString line = lines[i]; QString line = lines[i];
if (line.startsWith("=>")) { if (line.startsWith("=>")) {
activeLine = i; activeLine = i;
@ -80,16 +78,16 @@ void CPUDialog::setDisassembly(const QStringList &lines)
ui->txtCode->lines()->add(line); ui->txtCode->lines()->add(line);
} }
if (activeLine!=-1) if (activeLine!=-1)
ui->txtCode->setCaretXY(BufferCoord{1,activeLine}); ui->txtCode->setCaretXYCentered(true,BufferCoord{1,activeLine});
} }
void CPUDialog::sendSyntaxCommand() void CPUDialog::sendSyntaxCommand()
{ {
// Set disassembly flavor // Set disassembly flavor
if (ui->rdIntel->isChecked()) { if (ui->rdIntel->isChecked()) {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "intel"); pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor intel");
} else { } else {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "att"); pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor att");
} }
} }

View File

@ -15,7 +15,8 @@ public:
explicit CPUDialog(QWidget *parent = nullptr); explicit CPUDialog(QWidget *parent = nullptr);
~CPUDialog(); ~CPUDialog();
void updateInfo(); void updateInfo();
void setDisassembly(const QStringList& lines); public slots:
void setDisassembly(const QString& file, const QString& funcName,const QStringList& lines);
signals: signals:
void closed(); void closed();
private: private:

View File

@ -37,7 +37,6 @@ public:
const QString &functionFullName() const; const QString &functionFullName() const;
void setFunctioFullName(const QString &newFunctioFullName); void setFunctioFullName(const QString &newFunctioFullName);
signals:
private: private:
QStringList splitArgs(QString args); QStringList splitArgs(QString args);
private: private:

View File

@ -43,7 +43,7 @@ QConsole::QConsole(QWidget *parent):
mBlinkStatus = 0; mBlinkStatus = 0;
//enable input method //enable input method
setAttribute(Qt::WA_InputMethodEnabled); setAttribute(Qt::WA_InputMethodEnabled);
setMouseTracking(false); // setMouseTracking(false);
recalcCharExtent(); recalcCharExtent();
mScrollTimer = new QTimer(this); mScrollTimer = new QTimer(this);
mScrollTimer->setInterval(100); mScrollTimer->setInterval(100);
@ -147,7 +147,7 @@ void QConsole::addLine(const QString &line)
void QConsole::addText(const QString &text) void QConsole::addText(const QString &text)
{ {
QStringList lst = TextToLines(text); QStringList lst = textToLines(text);
for (const QString& line:lst) { for (const QString& line:lst) {
addLine(line); addLine(line);
} }
@ -276,7 +276,7 @@ void QConsole::setTopRow(int value)
int QConsole::maxScrollHeight() int QConsole::maxScrollHeight()
{ {
return std::max(mContents.rows()-mRowsInWindow,1); return std::max(mContents.rows()-mRowsInWindow+1,1);
} }
void QConsole::updateScrollbars() void QConsole::updateScrollbars()
@ -504,7 +504,7 @@ void QConsole::mousePressEvent(QMouseEvent *event)
//fKbdHandler.ExecuteMouseDown(Self, Button, Shift, X, Y); //fKbdHandler.ExecuteMouseDown(Self, Button, Shift, X, Y);
if (button == Qt::LeftButton) { if (button == Qt::LeftButton) {
setMouseTracking(true); // setMouseTracking(true);
RowColumn mousePosRC = pixelsToNearestRowColumn(X,Y); RowColumn mousePosRC = pixelsToNearestRowColumn(X,Y);
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC); LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
//I couldn't track down why, but sometimes (and definitely not all the time) //I couldn't track down why, but sometimes (and definitely not all the time)
@ -522,7 +522,7 @@ void QConsole::mouseReleaseEvent(QMouseEvent *event)
{ {
QAbstractScrollArea::mouseReleaseEvent(event); QAbstractScrollArea::mouseReleaseEvent(event);
mScrollTimer->stop(); mScrollTimer->stop();
setMouseTracking(false); // setMouseTracking(false);
} }

View File

@ -0,0 +1,29 @@
#include "signalmessagedialog.h"
#include "ui_signalmessagedialog.h"
SignalMessageDialog::SignalMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SignalMessageDialog)
{
ui->setupUi(this);
}
SignalMessageDialog::~SignalMessageDialog()
{
delete ui;
}
void SignalMessageDialog::setMessage(const QString &message)
{
ui->lblMessage->setText(message);
}
bool SignalMessageDialog::openCPUInfo()
{
return ui->chkOpenCPUInfo->isChecked();
}
void SignalMessageDialog::setOpenCPUInfo(bool value)
{
ui->chkOpenCPUInfo->setChecked(value);
}

View File

@ -0,0 +1,25 @@
#ifndef SIGNALMESSAGEDIALOG_H
#define SIGNALMESSAGEDIALOG_H
#include <QDialog>
namespace Ui {
class SignalMessageDialog;
}
class SignalMessageDialog : public QDialog
{
Q_OBJECT
public:
explicit SignalMessageDialog(QWidget *parent = nullptr);
~SignalMessageDialog();
void setMessage(const QString& message);
bool openCPUInfo();
void setOpenCPUInfo(bool value);
private:
Ui::SignalMessageDialog *ui;
};
#endif // SIGNALMESSAGEDIALOG_H

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SignalMessageDialog</class>
<widget class="QDialog" name="SignalMessageDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>240</height>
</rect>
</property>
<property name="windowTitle">
<string>Signal Received</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lblMessage">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkOpenCPUInfo">
<property name="text">
<string>Open CPU Info Dialog</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SignalMessageDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SignalMessageDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>