Skip to content

Commit f74334d

Browse files
committed
Version 0.16, made the following changes:
- Fixed issue with partial UTF-8 receive showing as unicode replacement character - Fixed issue with large speed test data not sending any data - Reduced duplicate buffer data in scroll edit
1 parent 5d6bcab commit f74334d

5 files changed

Lines changed: 47 additions & 34 deletions

File tree

AuTerm/AutScrollEdit.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
**
2323
*******************************************************************************/
2424

25-
/******************************************************************************/
26-
// Defines
27-
/******************************************************************************/
28-
//Minimum number of characters present in the buffer before text sections are
29-
//appended instead of replacing the whole field
30-
#define TERM_SIZE_MIN_APPEND_TEXT 6
31-
3225
/******************************************************************************/
3326
// Include Files
3427
/******************************************************************************/
@@ -37,6 +30,11 @@
3730
#include <QRegularExpression>
3831
#include <QDebug>
3932

33+
/******************************************************************************/
34+
// Constants
35+
/******************************************************************************/
36+
const QChar unicode_replacement_char = QChar(0xfffd);
37+
4038
/******************************************************************************/
4139
// Local Functions or Private Members
4240
/******************************************************************************/
@@ -59,7 +57,6 @@ AutScrollEdit::AutScrollEdit(QWidget *parent) : QPlainTextEdit(parent)
5957
nItemArraySize = 0;
6058
mbSliderShown = false;
6159
dat_out_updated = false;
62-
dat_in_prev_check_len = 0;
6360
dat_in_new_len = 0;
6461

6562
mstrDatIn.reserve(32768);
@@ -883,7 +880,6 @@ void AutScrollEdit::clear_dat_in()
883880
//Clears the DatIn buffer
884881
mstrDatIn.clear();
885882
mintPrevTextSize = 0;
886-
dat_in_prev_check_len = 0;
887883
dat_in_new_len = 0;
888884
last_format = pre;
889885

@@ -1021,15 +1017,14 @@ void AutScrollEdit::update_display()
10211017

10221018
if (vt100_control_mode == VT100_MODE_STRIP)
10231019
{
1024-
AutEscape::strip_vt100_formatting(&mstrDatIn, dat_in_prev_check_len);
1020+
AutEscape::strip_vt100_formatting(&mstrDatIn, 0);
10251021
}
10261022

10271023
//TODO: deal with partial VT100 escape codes
10281024

1029-
#if 1
10301025
//Replace unprintable characters with escape codes
10311026
int32_t i = mstrDatIn.length() - 1;
1032-
while (i >= dat_in_prev_check_len)
1027+
while (i >= 0)
10331028
{
10341029
uint8_t current = (uint8_t)mstrDatIn.at(i);
10351030

@@ -1044,17 +1039,30 @@ void AutScrollEdit::update_display()
10441039

10451040
--i;
10461041
}
1047-
#endif
10481042

1049-
if (dat_in_prev_check_len != mstrDatIn.length())
1043+
if (mstrDatIn.length() > 0)
10501044
{
1051-
QString append_data = mstrDatIn.mid(dat_in_prev_check_len);
1045+
QString append_data = mstrDatIn;
10521046
QList<vt100_format_code> format;
10531047
int32_t end = 0;
10541048

1049+
//Check if we have unicode replacement characters, if so, wait for next chunk
1050+
i = append_data.length() - 1;
1051+
while (i >= 0 && append_data[i] == unicode_replacement_char && end < 3)
1052+
{
1053+
++end;
1054+
--i;
1055+
}
1056+
1057+
if (end > 0)
1058+
{
1059+
cannot_parse_bytes += end;
1060+
append_data.remove((append_data.length() - end), end);
1061+
}
1062+
10551063
if (vt100_control_mode == VT100_MODE_DECODE && vt100_process(&append_data, 0, &format, &end) == false)
10561064
{
1057-
cannot_parse_bytes = append_data.length() - end;
1065+
cannot_parse_bytes += append_data.length() - end;
10581066
append_data.remove(end, (append_data.length() - end));
10591067
}
10601068

@@ -1186,7 +1194,7 @@ void AutScrollEdit::update_display()
11861194

11871195
//Update previous text size variables
11881196
mintPrevTextSize = dat_in_new_len;
1189-
dat_in_prev_check_len = mstrDatIn.length() - cannot_parse_bytes;
1197+
mstrDatIn.remove(0, (mstrDatIn.length() - cannot_parse_bytes));
11901198

11911199
//Update the cursor position
11921200
this->update_cursor();

AuTerm/AutScrollEdit.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ enum vt100_format_type {
5050
};
5151

5252
struct vt100_format_code {
53-
uint32_t start;
53+
int32_t start;
5454
QColor background_color;
5555
bool background_color_set;
5656
QColor foreground_color;
@@ -130,7 +130,6 @@ class AutScrollEdit : public QPlainTextEdit
130130
uint32_t mintPrevTextSize; //Holds a count of the previous text size
131131
bool mbSliderShown; //True if the slider moving to the bottom position upon appearing has been ran
132132
bool dat_out_updated; //True if mstrDatOut has been updated and needs redrawing
133-
int32_t dat_in_prev_check_len; //Holds position of mstrDatIn where hex character escaping was last performed to
134133
int32_t dat_in_new_len; //Holds position of QString-version of mstrDatIn where the mstrDatIn ends
135134
QTextCharFormat last_format; //Last format applied to dat out data
136135
vt100_mode vt100_control_mode; //VT100 control code mode

AuTerm/UwxMainWindow.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4980,24 +4980,30 @@ MainWindow::SendSpeedTestData(
49804980
int intMaxLength
49814981
)
49824982
{
4983-
//Send string out. It's OK to send less than the maximum length but not more
4984-
int intSendTimes = (intMaxLength / gintSpeedTestMatchDataLength);
4983+
//Send string out. It's OK to send less than the maximum length but not more, unless none fit
4984+
int intSendTimes = 1;
4985+
4986+
if (intMaxLength > gintSpeedTestMatchDataLength)
4987+
{
4988+
intSendTimes = (intMaxLength / gintSpeedTestMatchDataLength);
4989+
}
4990+
49854991
if (ui->check_SpeedShowTX->isChecked())
49864992
{
49874993
//Show TX data in terminal
4988-
while (intSendTimes > 0)
4994+
int print_times = intSendTimes;
4995+
4996+
while (print_times > 0)
49894997
{
49904998
//Append to buffer
49914999
gbaSpeedDisplayBuffer.append(gbaSpeedMatchData);
4992-
--intSendTimes;
5000+
--print_times;
49935001
}
5002+
49945003
if (!gtmrSpeedUpdateTimer.isActive())
49955004
{
49965005
gtmrSpeedUpdateTimer.start();
49975006
}
4998-
4999-
//Reset variable for actual sending
5000-
intSendTimes = (intMaxLength / gintSpeedTestMatchDataLength);
50015007
}
50025008

50035009
while (intSendTimes > 0)
@@ -5068,7 +5074,7 @@ MainWindow::SpeedTestReceive(
50685074
if (ui->combo_SpeedDataType->currentIndex() != 0)
50695075
{
50705076
//Test data is OK
5071-
uint32_t remove_size = 0;
5077+
int32_t remove_size = 0;
50725078
gbaSpeedReceivedData.append(gspSerialPort.read(received_bytes));
50735079
while (remove_size < gbaSpeedReceivedData.length())
50745080
{
@@ -5080,7 +5086,7 @@ MainWindow::SpeedTestReceive(
50805086
}
50815087

50825088
//Optimised search check function. for testing only
5083-
uint32_t i = 0;
5089+
int32_t i = 0;
50845090
bool good = true;
50855091
pointer_buf rec_buf;
50865092
pointer_buf match_buf;
@@ -5182,7 +5188,7 @@ MainWindow::SpeedTestReceive(
51825188
uint16_t new_offset = (i > 5 ? i - 5 : 0);
51835189
QString strFirst(gbaSpeedReceivedData.mid(remove_size + new_offset));
51845190
QString strSecond(gbaSpeedMatchData.mid(gintSpeedTestReceiveIndex + new_offset));
5185-
uint32_t max_size = strFirst.length() > strSecond.length() ? strSecond.length() : strFirst.length();
5191+
int32_t max_size = strFirst.length() > strSecond.length() ? strSecond.length() : strFirst.length();
51865192
quint16 iOffset = 0;
51875193
while (iOffset < max_size)
51885194
{

AuTerm/UwxMainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
// Constants
104104
/******************************************************************************/
105105
//Constants for version and functions
106-
const QString UwVersion = "0.15"; //Version string
106+
const QString UwVersion = "0.16"; //Version string
107107
//Constants for timeouts and streaming
108108
const qint16 FileReadBlock = 512; //Number of bytes to read per block when streaming files
109109
const qint16 StreamProgress = 10000; //Number of bytes between streaming progress updates

AuTerm/version.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <windows.h>
22

33
VS_VERSION_INFO VERSIONINFO
4-
FILEVERSION 0, 1, 0, 0
5-
PRODUCTVERSION 0, 1, 0, 0
4+
FILEVERSION 0, 16, 0, 0
5+
PRODUCTVERSION 0, 16, 0, 0
66
FILEFLAGSMASK 0x3fL
77
FILEFLAGS 0
88
FILEOS VOS_NT_WINDOWS32
@@ -19,12 +19,12 @@
1919
BEGIN
2020
VALUE "CompanyName", "thedjnK\0"
2121
VALUE "FileDescription", "AuTerm\0"
22-
VALUE "FileVersion", "0.15.0.0\0"
22+
VALUE "FileVersion", "0.16.0.0\0"
2323
VALUE "InternalName", "AuTerm\0"
2424
VALUE "LegalCopyright", "Copyright 2023 thedjnK\0"
2525
VALUE "OriginalFilename", "AuTerm.exe\0"
2626
VALUE "ProductName", "AuTerm\0"
27-
VALUE "ProductVersion", "0.15.0.0\0"
27+
VALUE "ProductVersion", "0.16.0.0\0"
2828
END
2929
END
3030
END

0 commit comments

Comments
 (0)