* work save: toggle breakpoint in editor

This commit is contained in:
royqh1979@gmail.com 2021-07-03 13:57:22 +08:00
parent 9492e9fdef
commit 84ba68f1b9
8 changed files with 61 additions and 190 deletions

Binary file not shown.

View File

@ -1351,7 +1351,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="colorscheme.cpp" line="523"/>
<source>Folding Line</source>
<source>Fold Line</source>
<translation>线</translation>
</message>
<message>

View File

@ -520,7 +520,7 @@ void ColorManager::initItemDefines()
true,true,false);
//Fold line
addDefine(COLOR_SCHEME_FOLD_LINE,
QObject::tr("Folding Line"),
QObject::tr("Fold Line"),
QObject::tr("Editor"),
true,false,false);

View File

@ -12,6 +12,5 @@
<file>colorschemes/Twilight.scheme</file>
<file>colorschemes/Visual_Studio.scheme</file>
<file>colorschemes/VS_Code.scheme</file>
<file>colorschemes/vs_code1.scheme</file>
</qresource>
</RCC>

View File

@ -1,184 +0,0 @@
{
"Assembler" : {
"foreground" : "#FF00FF",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Character" : {
"foreground" : "#D69D85",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Class" : {
"foreground" : "#4EC9B0",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Comment" : {
"foreground" : "#6A9955",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Float" : {
"foreground" : "#B5CEA8",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Function" : {
"foreground" : "#BFBFFF",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Global variable" : {
"foreground" : "#BFBFFF",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Hexadecimal" : {
"foreground" : "#B5CEA8",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Identifier" : {
"foreground" : "#DCDCAA",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Illegal Char" : {
"foreground" : "#FF3C3C",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Local Variable" : {
"foreground" : "#9CDCFE",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Number" : {
"foreground" : "#9CDCFE",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Octal" : {
"foreground" : "#B5CEA8",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Preprocessor" : {
"foreground" : "#C586C0",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Reserved Word" : {
"foreground" : "#569CD6",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Space" : {
"foreground" : "#505050",
"background" : "#1E1E1E",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"String" : {
"foreground" : "#D69D85",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Symbol" : {
"foreground" : "#D4D4D4",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Variable" : {
"foreground" : "#9CDCFE",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Escape sequences" : {
"foreground" : "#B5CEA8",
"bold" : false,
"italic" : false,
"underlined" : false,
"strikeout" : false
},
"Selected text" : {
"foreground" : "#000000",
"background" : "#808080"
},
"Gutter" : {
"foreground" : "#858585",
"background" : "#1E1E1E"
},
"Breakpoint": {
},
"Error" : {
"foreground" : "#C0C0C0"
},
"Active Breakpoint" : {
"foreground" : "#FFFFCE",
"background" : "#00376F"
},
"Fold Line" : {
"foreground" : "#C0C0C0"
},
"Active Line" : {
"background" : "#323232"
},
"Warning" : {
"foreground" : "#FF8040"
},
"Indent Guide Line" : {
"foreground" : "#C0C0C0"
},
"brace/parenthesis/bracket level 1" : {
"foreground" : "#D4D4D4"
},
"brace/parenthesis/bracket level 2" : {
"foreground" : "#9CDCFE"
},
"brace/parenthesis/bracket level 3" : {
"foreground" : "#FF00FF"
},
"brace/parenthesis/bracket level 4" : {
"foreground" : "#C586C0"
}
}

View File

@ -92,6 +92,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
applyColorScheme(pSettings->editor().colorScheme());
connect(this,&SynEdit::statusChanged,this,&Editor::onStatusChanged);
connect(this,&SynEdit::gutterClicked,this,&Editor::onGutterClicked);
}
Editor::~Editor() {
@ -369,6 +370,11 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
} else {
painter.drawPixmap(X,Y,*(pIconsManager->syntaxWarning()));
}
return;
}
if (hasBreakpoint(aLine)) {
painter.drawPixmap(X,Y,*(pIconsManager->breakpoint()));
}
// if fActiveLine = Line then begin // prefer active line over breakpoints
// dmMain.GutterImages.Draw(ACanvas, X, Y, 1);
@ -434,6 +440,11 @@ void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList)
}
}
bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor)
{
}
void Editor::copyToClipboard()
{
if (pSettings->editor().copySizeLimit()) {
@ -728,6 +739,14 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
}
void Editor::onGutterClicked(Qt::MouseButton button, int x, int y, int line)
{
if (button == Qt::LeftButton) {
toggleBreakpoint(line);
}
mGutterClickedLine = line;
}
QChar Editor::getCurrentChar()
{
if (lineText().length()<caretX())
@ -1151,6 +1170,32 @@ Editor::QuoteStatus Editor::getQuoteStatus()
return Result;
}
int Editor::gutterClickedLine() const
{
return mGutterClickedLine;
}
void Editor::toggleBreakpoint(int line)
{
if (hasBreakpoint(line)) {
mBreakpointLines.remove(line);
//todo
// MainForm.Debugger.RemoveBreakPoint(Line, self)
} else {
mBreakpointLines.insert(line);
//todo
// MainForm.Debugger.AddBreakPoint(Line, self);
}
invalidateGutterLine(line);
invalidateLine(line);
}
bool Editor::hasBreakpoint(int line)
{
return mBreakpointLines.contains(line);
}
void Editor::applySettings()
{
SynEditorOptions options = eoAltSetsColumnMode |

View File

@ -108,12 +108,17 @@ public:
bool hasNextSyntaxIssue() const;
PSyntaxIssueList getSyntaxIssuesAtLine(int line);
PSyntaxIssue getSyntaxIssueAtPosition(const BufferCoord& pos);
int gutterClickedLine() const;
void toggleBreakpoint(int line);
bool hasBreakpoint(int line);
signals:
protected slots:
void onModificationChanged(bool status) ;
void onStatusChanged(SynStatusChanges changes);
void onGutterClicked(Qt::MouseButton button, int x, int y, int line);
private:
QChar getCurrentChar();
@ -145,6 +150,8 @@ private:
QColor mSyntaxWaringColor;
int mSyntaxErrorLine;
int mLineCount;
int mGutterClickedLine;
QSet<int> mBreakpointLines;
// QWidget interface
protected:
@ -157,6 +164,10 @@ protected:
protected:
void onGutterPaint(QPainter &painter, int aLine, int X, int Y) override;
void onGetEditingAreas(int Line, SynEditingAreaList &areaList) override;
// SynEdit interface
protected:
bool onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor) override;
};
#endif // EDITOR_H

View File

@ -132,7 +132,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
//enable input method
setAttribute(Qt::WA_InputMethodEnabled);
setMouseTracking(true);
//setMouseTracking(true);
}
int SynEdit::displayLineCount() const
@ -5052,7 +5052,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
mBlockBegin = TmpBegin;
mBlockEnd = TmpEnd;
//setMouseTracking(true);
setMouseTracking(true);
//if mousedown occurred in selected block begin drag operation
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
@ -5092,7 +5092,7 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event)
mScrollTimer->stop();
// if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then
// exit;
//setMouseTracking(false);
setMouseTracking(false);
if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) &&
!mStateFlags.testFlag(SynStateFlag::sfDblClicked)) {