MCPcopy Create free account
hub / github.com/baldurk/renderdoc / performReplace

Method performReplace

qrenderdoc/Windows/ShaderViewer.cpp:7001–7058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6999}
7000
7001void ShaderViewer::performReplace()
7002{
7003 ScintillaEdit *cur = currentScintilla();
7004
7005 if(!cur)
7006 return;
7007
7008 QString find = m_FindReplace->findText();
7009
7010 if(find.isEmpty())
7011 return;
7012
7013 sptr_t flags = 0;
7014
7015 if(m_FindReplace->matchCase())
7016 flags |= SCFIND_MATCHCASE;
7017 if(m_FindReplace->matchWord())
7018 flags |= SCFIND_WHOLEWORD;
7019 if(m_FindReplace->regexp())
7020 flags |= SCFIND_REGEXP | SCFIND_POSIX;
7021
7022 FindReplace::SearchContext context = m_FindReplace->context();
7023
7024 bool down = m_FindReplace->direction() == FindReplace::Down;
7025 QString findHash = QFormatStr("%1%2%3%4").arg(find).arg(flags).arg((int)context).arg(down);
7026
7027 // if we didn't have a valid previous find, just do a find and bail
7028 if(findHash != m_FindState.hash)
7029 {
7030 performFind();
7031 return;
7032 }
7033
7034 if(m_FindState.prevResult.first == -1)
7035 return;
7036
7037 cur->setTargetRange(m_FindState.prevResult.first, m_FindState.prevResult.second);
7038
7039 FindState save = m_FindState;
7040
7041 QString replaceText = m_FindReplace->replaceText();
7042
7043 // otherwise we have a valid previous find. Do the replace now
7044 // note this will invalidate the find state (as most user operations would), so we save/restore
7045 // the state
7046 if(m_FindReplace->regexp())
7047 cur->replaceTargetRE(-1, replaceText.toUtf8().data());
7048 else
7049 cur->replaceTarget(-1, replaceText.toUtf8().data());
7050
7051 m_FindState = save;
7052
7053 // adjust the offset if we replaced text and it went up or down in size
7054 m_FindState.offset += (replaceText.count() - find.count());
7055
7056 // move to the next result
7057 performFind();
7058}

Callers

nothing calls this directly

Calls 15

findTextMethod · 0.80
matchCaseMethod · 0.80
matchWordMethod · 0.80
regexpMethod · 0.80
contextMethod · 0.80
directionMethod · 0.80
setTargetRangeMethod · 0.80
replaceTextMethod · 0.80
replaceTargetREMethod · 0.80
toUtf8Method · 0.80
replaceTargetMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected