forked from Public-Mirror/Textractor
temporary remove regex replacement
This commit is contained in:
parent
a03c939043
commit
fcd735283d
@ -24,7 +24,6 @@ public:
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.regexEdit, &QLineEdit::textEdited, this, &Window::SetRegex);
|
||||
connect(ui.replaceEdit, &QLineEdit::textEdited, this, &Window::SetReplace);
|
||||
connect(ui.saveButton, &QPushButton::clicked, this, &Window::Save);
|
||||
|
||||
setWindowTitle(REGEX_FILTER);
|
||||
@ -41,21 +40,13 @@ public:
|
||||
ui.output->setText(QString(CURRENT_FILTER).arg(regex));
|
||||
}
|
||||
|
||||
void SetReplace(QString replace)
|
||||
{
|
||||
ui.replaceEdit->setText(replace);
|
||||
std::scoped_lock lock(m);
|
||||
::replace = S(replace);
|
||||
}
|
||||
|
||||
private:
|
||||
void Save()
|
||||
{
|
||||
auto formatted = FormatString(
|
||||
L"\xfeff|PROCESS|%s|FILTER|%s|REPLACE|%s|END|\r\n",
|
||||
L"\xfeff|PROCESS|%s|FILTER|%s|END|\r\n",
|
||||
GetModuleFilename(GetSelectedProcessId()).value_or(FormatString(L"Error getting name of process 0x%X", GetSelectedProcessId())),
|
||||
S(ui.regexEdit->text()),
|
||||
S(ui.replaceEdit->text())
|
||||
S(ui.regexEdit->text())
|
||||
);
|
||||
std::ofstream(REGEX_SAVE_FILE, std::ios::binary | std::ios::app).write((const char*)formatted.c_str(), formatted.size() * sizeof(wchar_t));
|
||||
}
|
||||
@ -70,16 +61,12 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
if (sentenceInfo["current select"] && !regex) if (auto processName = GetModuleFilename(sentenceInfo["process id"]))
|
||||
{
|
||||
std::ifstream stream(REGEX_SAVE_FILE, std::ios::binary);
|
||||
BlockMarkupIterator savedFilters(stream, Array<std::wstring_view>{ L"|PROCESS|", L"|FILTER|", L"|REPLACE|" });
|
||||
std::vector<std::array<std::wstring, 3>> regexes;
|
||||
while (auto read = savedFilters.Next()) if (read->at(0) == processName) regexes.push_back(std::move(read.value()));
|
||||
if (!regexes.empty()) QMetaObject::invokeMethod(&window, [regex = S(regexes.back()[1]), replace = S(regexes.back()[2])]
|
||||
{
|
||||
window.SetRegex(regex);
|
||||
window.SetReplace(replace);
|
||||
}, Qt::BlockingQueuedConnection);
|
||||
BlockMarkupIterator savedFilters(stream, Array<std::wstring_view>{ L"|PROCESS|", L"|FILTER|" });
|
||||
std::vector<std::wstring> regexes;
|
||||
while (auto read = savedFilters.Next()) if (read->at(0) == processName) regexes.push_back(std::move(read->at(1)));
|
||||
if (!regexes.empty()) QMetaObject::invokeMethod(&window, std::bind(&Window::SetRegex, &window, S(regexes.back())), Qt::BlockingQueuedConnection);
|
||||
}
|
||||
std::shared_lock l(m);
|
||||
std::shared_lock lock(m);
|
||||
if (regex) sentence = std::regex_replace(sentence, regex.value(), replace);
|
||||
return true;
|
||||
}
|
||||
|
@ -16,16 +16,6 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="regexEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>=></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="replaceEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -121,7 +121,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo)
|
||||
{
|
||||
UpdateReplacements();
|
||||
|
||||
std::shared_lock l(m);
|
||||
std::shared_lock lock(m);
|
||||
sentence = trie.Replace(sentence);
|
||||
return true;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
std::shared_lock l(m);
|
||||
std::shared_lock lock(m);
|
||||
int64_t textHandle = sentenceInfo["text number"];
|
||||
|
||||
for (auto linkedHandle : linkedTextHandles[textHandle])
|
||||
|
Loading…
x
Reference in New Issue
Block a user