From 0571ac694a3411f218b80ea4f77451dab3f78cf3 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Tue, 28 May 2024 16:09:24 +0200
Subject: [PATCH 1/8] Update ms maximum
---
include/courtroom.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/courtroom.h b/include/courtroom.h
index a8942efe2..ae19423d5 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -561,7 +561,7 @@ class Courtroom : public QMainWindow {
// Minumum and maximum number of parameters in the MS packet
static const int MS_MINIMUM = 15;
- static const int MS_MAXIMUM = 35;
+ static const int MS_MAXIMUM = 40;
QString m_chatmessage[MS_MAXIMUM];
QString previous_ic_message = "";
From d083e647eff8b8b8b0cf45fd600d827f04a39fd6 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Sun, 9 Jun 2024 10:26:53 +0200
Subject: [PATCH 2/8] Update courtroom.h
---
include/courtroom.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/courtroom.h b/include/courtroom.h
index ae19423d5..a8942efe2 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -561,7 +561,7 @@ class Courtroom : public QMainWindow {
// Minumum and maximum number of parameters in the MS packet
static const int MS_MINIMUM = 15;
- static const int MS_MAXIMUM = 40;
+ static const int MS_MAXIMUM = 35;
QString m_chatmessage[MS_MAXIMUM];
QString previous_ic_message = "";
From 4a62d7b9670637ad7c30addb8333a71f8e2ac797 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Mon, 10 Jun 2024 11:31:34 +0200
Subject: [PATCH 3/8] remove html filter
---
src/aotextarea.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index a42590391..3470f77a6 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -32,9 +32,7 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message,
p_message += " ";
}
- QString result = p_message.toHtmlEscaped()
- .replace("\n", "
")
- .replace(url_parser_regex, "\\1");
+ QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1");
if (!p_color.isEmpty()) {
result = "" + result + "";
From 2c8917065aa65841316ce34523c0ab0820df30f5 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Tue, 23 Jul 2024 13:55:43 +0200
Subject: [PATCH 4/8] add close tags function
---
src/aotextarea.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index 3470f77a6..26fef08cb 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -32,7 +32,8 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message,
p_message += " ";
}
- QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1");
+ QString result = QString::fromStdString(this->closetags(p_message.replace("\n", "
").toStdString()));
+ result = result.replace(url_parser_regex, "\\1");
if (!p_color.isEmpty()) {
result = "" + result + "";
@@ -79,3 +80,44 @@ void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value,
this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
}
}
+
+std::string AOTextArea::closetags(std::string html)
+{
+ std::regex opened_regex(R"(<([a-z]+)(?: .*)?(?)",
+ std::regex_constants::icase);
+ std::regex closed_regex(R"(([a-z]+)>)", std::regex_constants::icase);
+
+ std::vector openedtags;
+ std::vector closedtags;
+ std::smatch match;
+
+ std::string::const_iterator search_start(html.cbegin());
+ while (std::regex_search(search_start, html.cend(), match, opened_regex)) {
+ openedtags.push_back(match[1]);
+ search_start = match.suffix().first;
+ }
+
+ search_start = html.cbegin();
+ while (std::regex_search(search_start, html.cend(), match, closed_regex)) {
+ closedtags.push_back(match[1]);
+ search_start = match.suffix().first;
+ }
+
+ size_t len_opened = openedtags.size();
+
+ if (closedtags.size() == len_opened) {
+ return html;
+ }
+
+ std::reverse(openedtags.begin(), openedtags.end());
+ for (size_t i = 0; i < len_opened; i++) {
+ auto it = std::find(closedtags.begin(), closedtags.end(), openedtags[i]);
+ if (it == closedtags.end()) {
+ html += "" + openedtags[i] + ">";
+ }
+ else {
+ closedtags.erase(it);
+ }
+ }
+ return html;
+}
From 8330e021e1f3ab0139a7c2911e6bc5fe21c97b90 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Tue, 23 Jul 2024 13:57:36 +0200
Subject: [PATCH 5/8] add close tags function
---
include/aotextarea.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/aotextarea.h b/include/aotextarea.h
index 405f4eb40..2d466a294 100644
--- a/include/aotextarea.h
+++ b/include/aotextarea.h
@@ -6,6 +6,11 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
class AOTextArea : public QTextBrowser {
public:
@@ -15,6 +20,7 @@ class AOTextArea : public QTextBrowser {
void append_chatmessage(QString p_name, QString p_message,
QString p_name_colour, QString p_color = QString());
void append_error(QString p_message);
+ std::string closetags(std::string html);
private:
const QRegularExpression url_parser_regex = QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b");
From ce33572168f68cd65a17cc820b48e4baf4f0d4dc Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Wed, 31 Jul 2024 09:59:38 +0200
Subject: [PATCH 6/8] from std::string to QString
---
include/aotextarea.h | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/include/aotextarea.h b/include/aotextarea.h
index 2d466a294..0dc622201 100644
--- a/include/aotextarea.h
+++ b/include/aotextarea.h
@@ -6,11 +6,6 @@
#include
#include
#include
-#include
-#include
-#include
-#include
-#include
class AOTextArea : public QTextBrowser {
public:
@@ -20,7 +15,7 @@ class AOTextArea : public QTextBrowser {
void append_chatmessage(QString p_name, QString p_message,
QString p_name_colour, QString p_color = QString());
void append_error(QString p_message);
- std::string closetags(std::string html);
+ QString closetags(QString html);
private:
const QRegularExpression url_parser_regex = QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b");
From 9609f2fcf0e0419fe379188756ae3b3d7868aba1 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Wed, 31 Jul 2024 10:02:09 +0200
Subject: [PATCH 7/8] from std::string to QString
---
src/aotextarea.cpp | 59 +++++++++++++++++-----------------------------
1 file changed, 22 insertions(+), 37 deletions(-)
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index 26fef08cb..104956d25 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -32,8 +32,8 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message,
p_message += " ";
}
- QString result = QString::fromStdString(this->closetags(p_message.replace("\n", "
").toStdString()));
- result = result.replace(url_parser_regex, "\\1");
+ QString result = this->closetags(p_message);
+ result = result.replace("\n", "
").replace(url_parser_regex, "\\1");
if (!p_color.isEmpty()) {
result = "" + result + "";
@@ -81,43 +81,28 @@ void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value,
}
}
-std::string AOTextArea::closetags(std::string html)
+QString AOTextArea::closetags(QString html)
{
- std::regex opened_regex(R"(<([a-z]+)(?: .*)?(?)",
- std::regex_constants::icase);
- std::regex closed_regex(R"(([a-z]+)>)", std::regex_constants::icase);
-
- std::vector openedtags;
- std::vector closedtags;
- std::smatch match;
-
- std::string::const_iterator search_start(html.cbegin());
- while (std::regex_search(search_start, html.cend(), match, opened_regex)) {
- openedtags.push_back(match[1]);
- search_start = match.suffix().first;
- }
-
- search_start = html.cbegin();
- while (std::regex_search(search_start, html.cend(), match, closed_regex)) {
- closedtags.push_back(match[1]);
- search_start = match.suffix().first;
- }
-
- size_t len_opened = openedtags.size();
-
- if (closedtags.size() == len_opened) {
- return html;
- }
-
- std::reverse(openedtags.begin(), openedtags.end());
- for (size_t i = 0; i < len_opened; i++) {
- auto it = std::find(closedtags.begin(), closedtags.end(), openedtags[i]);
- if (it == closedtags.end()) {
- html += "" + openedtags[i] + ">";
- }
- else {
- closedtags.erase(it);
+ QRegExp opened_regex("(<([a-z]+)(?: .*)?(?)");
+ QRegExp closed_regex("(([a-z]+)>)");
+
+ int pos1 = opened_regex.indexIn(html);
+ int pos2 = closed_regex.indexIn(html);
+ QStringList opentags = opened_regex.capturedTexts();
+ QStringList closetags = closed_regex.capturedTexts();
+
+ int i = 1;
+ int size_opentags = opentags.count();
+ for (QString tag:closetags) {
+ if (i <= size_opentags) {
+ QString expected_opentag = tag.replace("", "<").replace(">", "");
+ if (!opentags.at(size_opentags - i).startsWith(expected_opentag)) {
+ QString expected_closetag = opentags.at(size_opentags - i);
+ expected_closetag = expected_closetag.replace("<", "");
+ html = html + expected_closetag;
+ }
}
+ i++;
}
return html;
}
From 35e69d6031795b9551d8a03e7f638f5d8bfe4685 Mon Sep 17 00:00:00 2001
From: Dev <90421310+EstatoDeviato@users.noreply.github.com>
Date: Wed, 31 Jul 2024 10:20:07 +0200
Subject: [PATCH 8/8] Update aotextarea.cpp
---
src/aotextarea.cpp | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index 104956d25..4c3c2986a 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -86,23 +86,27 @@ QString AOTextArea::closetags(QString html)
QRegExp opened_regex("(<([a-z]+)(?: .*)?(?)");
QRegExp closed_regex("(([a-z]+)>)");
- int pos1 = opened_regex.indexIn(html);
- int pos2 = closed_regex.indexIn(html);
+ opened_regex.indexIn(html);
+ closed_regex.indexIn(html);
QStringList opentags = opened_regex.capturedTexts();
QStringList closetags = closed_regex.capturedTexts();
- int i = 1;
int size_opentags = opentags.count();
- for (QString tag:closetags) {
- if (i <= size_opentags) {
- QString expected_opentag = tag.replace("", "<").replace(">", "");
- if (!opentags.at(size_opentags - i).startsWith(expected_opentag)) {
+ for (int i = 1; i <= size_opentags; i++) {
+ if (i <= closetags.count()) {
+ QString expected_opentag = closetags.at(i - 1);
+ expected_opentag = expected_opentag.replace("", "<").replace(">", "");
+ if (!opentags.at(size_opentags - i).startsWith(expected_opentag)) {
QString expected_closetag = opentags.at(size_opentags - i);
expected_closetag = expected_closetag.replace("<", "");
html = html + expected_closetag;
- }
+ }
+ }
+ else {
+ QString expected_closetag = opentags.at(size_opentags - i);
+ expected_closetag = expected_closetag.replace("<", "");
+ html = html + expected_closetag;
}
- i++;
}
return html;
}