From 9571d4527a2a348d20ebbb948640000444696725 Mon Sep 17 00:00:00 2001 From: lsv Date: Wed, 4 Mar 2026 15:34:39 +0500 Subject: [PATCH] support single quote for PreviewHtml --- include/utils/popuphelp.h | 17 +++++++++++++++++ utils/PreviewHtml.cpp | 8 +++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/utils/popuphelp.h b/include/utils/popuphelp.h index 80d98bb..956458a 100644 --- a/include/utils/popuphelp.h +++ b/include/utils/popuphelp.h @@ -193,6 +193,23 @@ public: if (event.GetKeyCode() == WXK_HOME) htmlWindow->ScrollPages(-1000); if (event.GetKeyCode() == WXK_END) htmlWindow->ScrollPages(1000); //std::cout << "key code " << event.GetKeyCode() << " " << std::endl; + if (event.GetKeyCode() == 'C') { + + if (hist.size()>0 && wxTheClipboard->Open()) + { + wxString h=hist[hist.size()-1]; + // Добавляем данные (можно добавить несколько форматов, если нужно) + wxDataObjectComposite* dataobj = new wxDataObjectComposite(); + dataobj->Add(new wxHTMLDataObject(h)); + wxTheClipboard->SetData(dataobj); + wxTheClipboard->Close(); + } + else + { + wxLogError("No open clipboard."); + } + + } if (event.GetKeyCode() == 'S') { wxSize clientSize = this->GetClientSize(); // Создаём битмап того же размера diff --git a/utils/PreviewHtml.cpp b/utils/PreviewHtml.cpp index 4d32099..72b7c0c 100644 --- a/utils/PreviewHtml.cpp +++ b/utils/PreviewHtml.cpp @@ -117,7 +117,7 @@ wxString PreviewHtml::Preview(const wxString& txt, fmtpreview type) { int flag = 0; tokens.clear(); bool quote = false; - wxUniChar prevchar; + wxUniChar prevchar,quotechar; int startstr = -1; while (pos < len) { c = tmpstr[pos++]; @@ -130,18 +130,20 @@ wxString PreviewHtml::Preview(const wxString& txt, fmtpreview type) { html+=c; continue; } - bool isquote = c == '"'; + if (!quote && (c=='"' || c=='\'')) quotechar = c; + bool isquote = c == quotechar; if (quote) { if (prevchar == c && isquote) { // repeat quote prevchar = '\0'; continue; } - if (prevchar == '"' && !isquote) { + if (prevchar == quotechar && !isquote) { // end quote string wxString tmp = tmpstr.Mid(startstr, pos - startstr - 1); saveTokenIfNotEmpty(tmp, PREVIEW_QUOTE); quote = false; + quotechar='\0'; } else { prevchar = c;