| 414 | } |
| 415 | |
| 416 | MainWindow::debug_basic_status_t MainWindow::debugBasicUpdate(bool force) { |
| 417 | int index = 0; |
| 418 | debug_basic_status_t status = debugBasicPrgmLookup(force, &index); |
| 419 | if (status == DBG_BASIC_NO_EXECUTING_PRGM) { |
| 420 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 421 | } |
| 422 | |
| 423 | const uint32_t begPC = mem_peek_long(DBG_BASIC_BEGPC); |
| 424 | const uint32_t curPC = mem_peek_long(DBG_BASIC_CURPC); |
| 425 | const uint32_t endPC = mem_peek_long(DBG_BASIC_ENDPC); |
| 426 | bool validPC = curPC >= begPC && curPC <= endPC; |
| 427 | |
| 428 | if (force || m_basicShowLiveExecution) { |
| 429 | // show variables only if this is a live update, they get shown already for normal debug stop |
| 430 | if (!force && guiReceive) { |
| 431 | varShow(); |
| 432 | } |
| 433 | |
| 434 | if (status == DBG_BASIC_NEED_REFRESH && index != 0) { |
| 435 | ui->basicEdit->document()->setPlainText(m_basicPrgmsOriginalCode[index]); |
| 436 | m_basicCodeIndex = index; |
| 437 | } |
| 438 | if (m_basicTempParserNeedsRefresh) { |
| 439 | ui->basicTempEdit->document()->setPlainText(m_basicPrgmsOriginalCode[0]); |
| 440 | m_basicTempParserNeedsRefresh = false; |
| 441 | } |
| 442 | |
| 443 | if (validPC) { |
| 444 | // quick lookup using lists rather than map/hash |
| 445 | const token_highlight_t posinfo = m_basicPrgmsTokensMap[index][curPC - begPC]; |
| 446 | |
| 447 | BasicEditor *thisEditor = ui->basicEdit, *otherEditor = ui->basicTempEdit; |
| 448 | if (index == 0) { |
| 449 | std::swap(thisEditor, otherEditor); |
| 450 | } |
| 451 | m_basicCurrToken.cursor = QTextCursor(thisEditor->document()); |
| 452 | m_basicCurrToken.cursor.setPosition(posinfo.offset); |
| 453 | m_basicCurrLine.cursor = m_basicCurrToken.cursor; |
| 454 | m_basicCurrToken.cursor.movePosition(QTextCursor::MoveOperation::Right, QTextCursor::MoveMode::KeepAnchor, posinfo.len); |
| 455 | |
| 456 | thisEditor->setTextCursor(m_basicCurrLine.cursor); |
| 457 | thisEditor->setExtraSelections({ m_basicCurrLine, m_basicCurrToken }); |
| 458 | otherEditor->setExtraSelections({}); |
| 459 | } else { |
| 460 | debugBasicClearHighlights(); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | return validPC ? DBG_BASIC_SUCCESS : DBG_BASIC_NO_EXECUTING_PRGM; |
| 465 | } |
| 466 | |
| 467 | void MainWindow::debugBasicToggleHighlight(bool enabled) { |
| 468 | m_basicShowHighlighted = enabled; |
nothing calls this directly
no test coverage detected