diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index e37adfcfa..bc7b0d859 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -131,6 +131,9 @@ ShaderViewer::ShaderViewer(ICaptureContext &ctx, QWidget *parent) ui->docking->setToolWindowProperties( m_FindResults, ToolWindowManager::HideOnClose | ToolWindowManager::DisallowFloatWindow); + QObject::connect(m_FindResults, &ScintillaEdit::doubleClick, this, + &ShaderViewer::resultsDoubleClick); + { m_DisassemblyView = MakeEditor(lit("scintillaDisassem"), QString(), @@ -1202,6 +1205,15 @@ ScintillaEdit *ShaderViewer::MakeEditor(const QString &name, const QString &text ret->indicSetAlpha(INDICATOR_FINDRESULT, 50); ret->indicSetOutlineAlpha(INDICATOR_FINDRESULT, 80); + QColor highlightColor = palette().color(QPalette::Highlight).toRgb(); + + ret->indicSetFore( + INDICATOR_FINDALLHIGHLIGHT, + SCINTILLA_COLOUR(highlightColor.red(), highlightColor.green(), highlightColor.blue())); + ret->indicSetStyle(INDICATOR_FINDALLHIGHLIGHT, INDIC_FULLBOX); + ret->indicSetAlpha(INDICATOR_FINDALLHIGHLIGHT, 120); + ret->indicSetOutlineAlpha(INDICATOR_FINDALLHIGHLIGHT, 180); + ConfigureSyntax(ret, lang); ret->setTabWidth(4); @@ -5251,8 +5263,13 @@ void ShaderViewer::performFindAll() QList> resultList; + m_FindAllResults.clear(); + QByteArray findUtf8 = find.toUtf8(); + if(findUtf8.isEmpty()) + return; + for(ScintillaEdit *s : scintillas) { sptr_t start = 0; @@ -5261,9 +5278,6 @@ void ShaderViewer::performFindAll() s->setIndicatorCurrent(INDICATOR_FINDRESULT); s->indicatorClearRange(start, end); - if(findUtf8.isEmpty()) - continue; - QPair result; do @@ -5288,6 +5302,8 @@ void ShaderViewer::performFindAll() resultList.push_back( qMakePair(result.first - lineStart + startPos, result.second - lineStart + startPos)); + + m_FindAllResults.push_back({s, result.first}); } start = result.second; @@ -5295,14 +5311,14 @@ void ShaderViewer::performFindAll() } while(result.first >= 0); } - if(findUtf8.isEmpty()) - return; - results += tr("Matching lines: %1").arg(resultList.count()); m_FindResults->setReadOnly(false); m_FindResults->setText(results.toUtf8().data()); + m_FindResults->setIndicatorCurrent(INDICATOR_FINDALLHIGHLIGHT); + m_FindResults->indicatorClearRange(0, m_FindResults->length()); + m_FindResults->setIndicatorCurrent(INDICATOR_FINDRESULT); for(QPair r : resultList) @@ -5324,6 +5340,30 @@ void ShaderViewer::performFindAll() } } +void ShaderViewer::resultsDoubleClick(int position, int line) +{ + if(line >= 1 && line - 1 < m_FindAllResults.count()) + { + m_FindResults->setIndicatorCurrent(INDICATOR_FINDALLHIGHLIGHT); + m_FindResults->indicatorClearRange(0, m_FindResults->length()); + + sptr_t start = m_FindResults->positionFromLine(line); + sptr_t length = m_FindResults->lineLength(line); + m_FindResults->indicatorFillRange(start, length); + + m_FindResults->setSelection(position, position); + + ScintillaEdit *s = m_FindAllResults[line - 1].first; + int resultPos = m_FindAllResults[line - 1].second; + ToolWindowManager::raiseToolWindow(s); + s->activateWindow(); + s->QWidget::setFocus(); + s->clearSelections(); + s->setSelection(resultPos, resultPos); + s->scrollCaret(); + } +} + void ShaderViewer::performReplace() { ScintillaEdit *cur = currentScintilla(); diff --git a/qrenderdoc/Windows/ShaderViewer.h b/qrenderdoc/Windows/ShaderViewer.h index 2b56962b9..45536994a 100644 --- a/qrenderdoc/Windows/ShaderViewer.h +++ b/qrenderdoc/Windows/ShaderViewer.h @@ -160,6 +160,7 @@ private slots: void watch_keyPress(QKeyEvent *event); void performFind(); void performFindAll(); + void resultsDoubleClick(int position, int line); void performReplace(); void performReplaceAll(); @@ -290,6 +291,8 @@ private: rdcarray m_ReadWriteResources; QList m_Breakpoints; + QList> m_FindAllResults; + static const int CURRENT_MARKER = 0; static const int BREAKPOINT_MARKER = 2; static const int FINISHED_MARKER = 4; @@ -299,6 +302,7 @@ private: static const int INDICATOR_FINDRESULT = 0; static const int INDICATOR_REGHIGHLIGHT = 1; + static const int INDICATOR_FINDALLHIGHLIGHT = 2; QString targetName(const ShaderProcessingTool &disasm);