| 7058 | } |
| 7059 | |
| 7060 | void ShaderViewer::performReplaceAll() |
| 7061 | { |
| 7062 | ScintillaEdit *cur = currentScintilla(); |
| 7063 | |
| 7064 | if(!cur) |
| 7065 | return; |
| 7066 | |
| 7067 | QString find = m_FindReplace->findText(); |
| 7068 | QString replace = m_FindReplace->replaceText(); |
| 7069 | |
| 7070 | if(find.isEmpty()) |
| 7071 | return; |
| 7072 | |
| 7073 | sptr_t flags = 0; |
| 7074 | |
| 7075 | if(m_FindReplace->matchCase()) |
| 7076 | flags |= SCFIND_MATCHCASE; |
| 7077 | if(m_FindReplace->matchWord()) |
| 7078 | flags |= SCFIND_WHOLEWORD; |
| 7079 | if(m_FindReplace->regexp()) |
| 7080 | flags |= SCFIND_REGEXP | SCFIND_POSIX; |
| 7081 | |
| 7082 | FindReplace::SearchContext context = m_FindReplace->context(); |
| 7083 | |
| 7084 | (void)context; |
| 7085 | |
| 7086 | // trash the find state for any incremental finds |
| 7087 | m_FindState = FindState(); |
| 7088 | |
| 7089 | QList<ScintillaEdit *> scintillas = m_Scintillas; |
| 7090 | |
| 7091 | if(context == FindReplace::File) |
| 7092 | scintillas = {cur}; |
| 7093 | |
| 7094 | int numReplacements = 0; |
| 7095 | |
| 7096 | for(ScintillaEdit *s : scintillas) |
| 7097 | { |
| 7098 | sptr_t start = 0; |
| 7099 | sptr_t end = s->length(); |
| 7100 | |
| 7101 | QPair<int, int> result; |
| 7102 | |
| 7103 | QByteArray findUtf8 = find.toUtf8(); |
| 7104 | QByteArray replaceUtf8 = replace.toUtf8(); |
| 7105 | |
| 7106 | do |
| 7107 | { |
| 7108 | result = s->findText(flags, findUtf8.data(), start, end); |
| 7109 | |
| 7110 | if(result.first >= 0) |
| 7111 | { |
| 7112 | s->setTargetRange(result.first, result.second); |
| 7113 | |
| 7114 | if(m_FindReplace->regexp()) |
| 7115 | s->replaceTargetRE(-1, replaceUtf8.data()); |
| 7116 | else |
| 7117 | s->replaceTarget(-1, replaceUtf8.data()); |
nothing calls this directly
no test coverage detected