Make breakpoints persist in codeeditor, when editing input code
MODIFY
src/codeeditor.cpp
src/codeeditor.cpp
@@ -131,6 +131,15 @@ void CodeEditor::updateTooltip(int line, QString tip) {
}
}
+void CodeEditor::updateBreakpoints() {
+ // called after disassembler text has been set
+
+ // Remove breakpoints if a breakpoint line has been removed
+ while (!m_breakpoints.empty() && *(m_breakpoints.rbegin()) > (blockCount() - 1)) {
+ m_breakpoints.erase(std::prev(m_breakpoints.end()));
+ }
+}
+
bool CodeEditor::event(QEvent* event) {
// Override event handler for receiving tool tips
if (event->type() == QEvent::ToolTip) {
@@ -166,11 +175,6 @@ void CodeEditor::updateSidebar(const QRect& rect, int dy) {
if (rect.contains(viewport()->rect()))
updateSidebarWidth(0);
-
- // Remove breakpoints if a breakpoint line has been removed
- while (!m_breakpoints.empty() && *(m_breakpoints.rbegin()) > (blockCount() - 1)) {
- m_breakpoints.erase(std::prev(m_breakpoints.end()));
- }
}
void CodeEditor::resizeEvent(QResizeEvent* e) {

MODIFY
src/codeeditor.h
src/codeeditor.h
@@ -26,6 +26,7 @@ public:
void breakpointAreaPaintEvent(QPaintEvent* event);
void breakpointClick(QMouseEvent* event, int forceState = 0);
void clearBreakpoints() { m_breakpoints.clear(); }
+ void updateBreakpoints();
int lineNumberAreaWidth();
void setupSyntaxHighlighter();
void setupAssembler();

MODIFY
src/parser.cpp
src/parser.cpp
@@ -98,6 +98,9 @@ const QString& Parser::loadFromByteArray(QByteArray arr, bool disassembled, uint
output.append(genStringRepr(instr));
output.append("\n");
}
+ // Remove trailing \n character
+ output.truncate(output.lastIndexOf('\n'));
+
// Update the pipeline
Pipeline::getPipeline()->update();
if (baseAddress == 0)

MODIFY
src/programfiletab.cpp
src/programfiletab.cpp
@@ -56,10 +56,10 @@ void ProgramfileTab::setAssemblyText(const QString& text) {
}
void ProgramfileTab::setDisassemblerText() {
- m_ui->binaryedit->clearBreakpoints();
const QString& text = m_ui->disassembledViewButton->isChecked() ? Parser::getParser()->getDisassembledRepr()
: Parser::getParser()->getBinaryRepr();
m_ui->binaryedit->setPlainText(text);
+ m_ui->binaryedit->updateBreakpoints();
}
void ProgramfileTab::assemblingComplete(const QByteArray& arr, bool clear, uint32_t baseAddress) {

Make breakpoints persist in codeeditor, when editing input code