MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / debugBasicContextMenu

Method debugBasicContextMenu

gui/qt/basicdebugger.cpp:316–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void MainWindow::debugBasicContextMenu(const QPoint &pos) {
317 BasicEditor *editor = static_cast<BasicEditor*>(sender());
318 bool valid = guiDebug && guiDebugBasic;
319 int index = 0;
320 if (editor == ui->basicEdit) {
321 index = m_basicCodeIndex;
322 valid &= (index != 0);
323 } else if (editor == ui->basicTempEdit) {
324 valid &= m_basicShowTempParser;
325 } else {
326 valid = false;
327 }
328
329 QMenu *menu = editor->createStandardContextMenu(pos);
330 menu->addSeparator();
331 QAction *runUntil = menu->addAction(ACTION_RUN_UNTIL);
332 runUntil->setEnabled(false);
333 uint32_t runUntilRange = 0;
334
335 int actualIndex = 0;
336 if (valid && debugBasicPrgmLookup(false, &actualIndex) != DBG_BASIC_NO_EXECUTING_PRGM && index == actualIndex) {
337 const auto &tokensMap = m_basicPrgmsTokensMap[index];
338 const int cursorOffset = editor->cursorForPosition(pos).position();
339 const auto last = std::make_reverse_iterator(
340 std::upper_bound(tokensMap.constBegin(), tokensMap.constEnd(), cursorOffset,
341 [](int offset, const token_highlight_t &posInfo) { return offset < posInfo.offset; }));
342 if (last != tokensMap.crend()) {
343 const auto stepField = m_basicShowFetches ? &token_highlight_t::offset : &token_highlight_t::line;
344 const int currField = (*last).*stepField;
345 const auto first = std::find_if(last + 1, tokensMap.crend(), [=](const token_highlight_t &posInfo) { return posInfo.*stepField != currField; });
346 const uint16_t firstOffset = first.base() - tokensMap.constBegin();
347 const uint16_t lastOffset = last.base() - tokensMap.constBegin() - 1;
348 runUntilRange = firstOffset | (static_cast<uint32_t>(lastOffset) << 16);
349 runUntil->setEnabled(true);
350 }
351 }
352 QAction *action = menu->exec(editor->mapToGlobal(pos));
353 if (action == runUntil && guiDebug && guiDebugBasic &&
354 debugBasicPrgmLookup(false, &actualIndex) != DBG_BASIC_NO_EXECUTING_PRGM && index == actualIndex) {
355 debugSync();
356 debug_step(DBG_BASIC_STEP_NEXT, runUntilRange);
357 emu.resume();
358 }
359}
360
361void MainWindow::debugBasicStep() {
362 debugBasicStepInternal(false);

Callers

nothing calls this directly

Calls 2

debug_stepFunction · 0.85
resumeMethod · 0.80

Tested by

no test coverage detected