From 5eb5e7766886b69d89ffad3d7ead0223c315ad85 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Fri, 15 Nov 2019 15:29:10 -0500 Subject: [PATCH] Fixed #71: newline supported in 2.0 messages --- jsc.h | 4 ++-- jsc_list.cpp | 9 +++++---- jsc_map.cpp | 4 ++-- mainwindow.cpp | 6 +++--- varicode.cpp | 18 +++++++++++++++++- varicode.h | 3 +++ 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/jsc.h b/jsc.h index b4054d4..dbb89fc 100644 --- a/jsc.h +++ b/jsc.h @@ -40,8 +40,8 @@ public: static const Tuple map[262144]; static const Tuple list[262144]; - static const quint32 prefixSize = 69; - static const Tuple prefix[69]; + static const quint32 prefixSize = 70; + static const Tuple prefix[70]; }; #endif // JSC_H diff --git a/jsc_list.cpp b/jsc_list.cpp index a596455..4516f26 100644 --- a/jsc_list.cpp +++ b/jsc_list.cpp @@ -180080,8 +180080,8 @@ const Tuple JSC::list[262144] = { {"FTAD", 4, 112460}, {"FTAC", 4, 68872}, {"FTAB", 4, 72752}, - {"\\", 1, 69}, - {"FT8", 3, 68}, + {"\n", 1, 69}, // FYI: this used to be "\" in JS8 1.0 + {"\\", 1, 68}, // FYI: this used to be FT8 in JS8 1.0 {"FSYW", 4, 155790}, {"FSYT", 4, 186523}, {"FSYS", 4, 69541}, @@ -262167,7 +262167,7 @@ const Tuple JSC::list[262144] = { {"!", 1, 28}, }; -const Tuple JSC::prefix[69] = { +const Tuple JSC::prefix[70] = { {"!", 1, 262143}, {"\"", 1, 262142}, {"#", 1, 262141}, @@ -262205,7 +262205,8 @@ const Tuple JSC::prefix[69] = { {"C", 17608, 216261}, {"D", 13749, 202512}, {"E", 12403, 190109}, - {"\\", 1, 180059}, + {"\\", 1, 180060}, + {"\n", 1, 180059}, {"F", 11252, 178857}, {"G", 10672, 168185}, {"H", 9060, 159125}, diff --git a/jsc_map.cpp b/jsc_map.cpp index 8738309..6c0dc70 100644 --- a/jsc_map.cpp +++ b/jsc_map.cpp @@ -89,8 +89,8 @@ const Tuple JSC::map[262144] = { {"`", 1, 65}, {"~", 1, 66}, {" ", 1, 67}, - {"FT8", 3, 68}, - {"\\", 1, 69}, + {"\\", 1, 68}, // FYI: this used to be FT8 in JS8 1.0 + {"\n", 1, 69}, // FYI: this used to be "\" in JS8 1.0 {"JS8", 3, 70}, {"JS8CALL", 7, 71}, {"JSQSO", 5, 72}, diff --git a/mainwindow.cpp b/mainwindow.cpp index 16f7341..cd319f1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -980,8 +980,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, auto enterFilter = new EnterKeyPressEater(); connect(enterFilter, &EnterKeyPressEater::enterKeyPressed, this, [this](QObject *, QKeyEvent *, bool *pProcessed){ if(QApplication::keyboardModifiers() & Qt::ShiftModifier){ - // do not allow shift+enter - if(pProcessed) *pProcessed = true; + if(pProcessed) *pProcessed = false; return; } if(ui->extFreeTextMsgEdit->isReadOnly()){ @@ -6411,7 +6410,7 @@ void MainWindow::displayTextForFreq(QString text, int freq, QDateTime date, bool block = -1; } - block = writeMessageTextToUI(date, text.replace("\\n", "\n"), freq, isTx, block); + block = writeMessageTextToUI(date, text, freq, isTx, block); // never cache tx or last lines if(/*isTx || */isLast) { @@ -6483,6 +6482,7 @@ int MainWindow::writeMessageTextToUI(QDateTime date, QString text, int freq, boo c.insertText(text); } else { text = text.toHtmlEscaped(); + text = text.replace("\n", "
"); text = text.replace(" ", "  "); c.insertBlock(); c.insertHtml(QString("%1 - (%2) - %3").arg(date.time().toString()).arg(freq).arg(text)); diff --git a/varicode.cpp b/varicode.cpp index 8db2a45..abf0645 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -327,6 +327,16 @@ int dbmTomwatts(int dbm){ return iter.value(); } +QString Varicode::escape(const QString &text){ + // // TODO: support different escapes? + return text; +} + +QString Varicode::unescape(const QString &text){ + // // TODO: support different escapes? + return text; +} + QString Varicode::rstrip(const QString& str) { int n = str.size() - 1; for (; n >= 0; --n) { @@ -1844,7 +1854,13 @@ QList> Varicode::buildMessageFrames(QString const& mycall, QList> allFrames; - foreach(QString line, text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts)){ +#if JS8_NO_MULTILINE + // auto lines = text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts); +#else + QStringList lines = { text }; +#endif + + foreach(QString line, lines){ QList> lineFrames; // once we find a directed call, data encode the rest of the line. diff --git a/varicode.h b/varicode.h index 6e8c71b..d9dedcd 100644 --- a/varicode.h +++ b/varicode.h @@ -78,6 +78,9 @@ public: //Varicode(); + static QString escape(const QString &text); + static QString unescape(const QString &text); + static QString rstrip(const QString& str); static QString lstrip(const QString& str);