Skip to content

Commit c12c14d

Browse files
committed
Version 0.16a, made the following changes:
- Fixed issue with reworked scroll edit not adding newline - Fixed issue with scroll edit adding escape characters when not in VT100 decode mode - Fixed missing variable increment in escape code - Improve efficiency of escape code by replacing escape sequences instead of inserting then removing
1 parent f74334d commit c12c14d

5 files changed

Lines changed: 25 additions & 23 deletions

File tree

AuTerm/AutEscape.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,38 @@ AutEscape::escape_characters(
4141
{
4242
//Escapes character sequences
4343
qint32 next = data->indexOf("\\");
44+
4445
while (next != -1)
4546
{
4647
QChar cur_char;
4748

48-
if (data->length() <= next)
49+
if (data->length() <= (next + 1))
4950
{
5051
//No more string length, ignore
5152
break;
5253
}
5354

54-
cur_char = data->at(next + 1);
55+
cur_char = QChar(data->at(next + 1)).toLower();
5556

5657
if (cur_char == '\\')
5758
{
5859
//This is a \\ so remove one of the slashes and ignore the conversion
5960
data->remove(next, 1);
6061
}
61-
else if (cur_char == 'r' || cur_char == 'R')
62+
else if (cur_char == 'r')
6263
{
6364
//This is a \r or \R
64-
data->insert(next, "\r");
65-
data->remove((next + 1), 2);
65+
data->replace(next, 2, "\r");
6666
}
67-
else if (cur_char == 'n' || cur_char == 'N')
67+
else if (cur_char == 'n')
6868
{
6969
//This is a \n or \N
70-
data->insert(next, "\n");
71-
data->remove((next + 1), 2);
70+
data->replace(next, 2, "\n");
7271
}
73-
else if (cur_char == 't' || cur_char == 'T')
72+
else if (cur_char == 't')
7473
{
7574
//This is a \t or \T
76-
data->insert(next, "\t");
77-
data->remove((next + 1), 2);
75+
data->replace(next, 2, "\t");
7876
}
7977
else if (data->length() <= (next + 2))
8078
{
@@ -83,13 +81,13 @@ AutEscape::escape_characters(
8381
}
8482
else
8583
{
86-
QChar next_char = data->at(next + 2);
84+
QChar next_char = QChar(data->at(next + 2)).toLower();
8785

88-
if (((cur_char >= '0' && cur_char <= '9') || (cur_char >= 'a' && cur_char <= 'f') || (cur_char >= 'A' && cur_char <= 'F')) && ((next_char >= '0' && next_char <= '9') || (next_char >= 'a' && next_char <= 'f') || (next_char >= 'A' && next_char <= 'F')))
86+
if (((cur_char >= '0' && cur_char <= '9') || (cur_char >= 'a' && cur_char <= 'f')) && ((next_char >= '0' && next_char <= '9') || (next_char >= 'a' && next_char <= 'f')))
8987
{
9088
//Character to escape
91-
data->insert(next, (char)data->mid((next + 1), 2).toInt(NULL, 16));
92-
data->remove((next + 1), 3);
89+
char replacement = (char)data->mid((next + 1), 2).toInt(NULL, 16);
90+
data->replace(next, 3, &replacement, sizeof(char));
9391
}
9492
}
9593

AuTerm/AutScrollEdit.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ AutScrollEdit::AutScrollEdit(QWidget *parent) : QPlainTextEdit(parent)
5858
mbSliderShown = false;
5959
dat_out_updated = false;
6060
dat_in_new_len = 0;
61+
had_dat_in_data = false;
6162

6263
mstrDatIn.reserve(32768);
6364

@@ -815,7 +816,7 @@ void AutScrollEdit::add_dat_in_text(QByteArray *baDat, bool apply_formatting)
815816
//Adds data to the DatIn buffer
816817
bool added = false;
817818

818-
if (mstrDatIn.isEmpty() == true)
819+
if (had_dat_in_data == false)
819820
{
820821
//Remove first newline
821822
uint32_t i = 0;
@@ -828,7 +829,7 @@ void AutScrollEdit::add_dat_in_text(QByteArray *baDat, bool apply_formatting)
828829
if (i > 0)
829830
{
830831
//TODO: a better way to deal with this "hack"
831-
if (apply_formatting == false)
832+
if (apply_formatting == false && vt100_control_mode == VT100_MODE_DECODE)
832833
{
833834
mstrDatIn += "\x1b[0m";
834835
}
@@ -839,13 +840,14 @@ void AutScrollEdit::add_dat_in_text(QByteArray *baDat, bool apply_formatting)
839840

840841
if (added == false)
841842
{
842-
if (apply_formatting == false)
843+
if (apply_formatting == false && vt100_control_mode == VT100_MODE_DECODE)
843844
{
844845
mstrDatIn += "\x1b[0m";
845846
}
846847
mstrDatIn += baDat->replace("\r\n", "\n").replace("\r", "\n");
847848
}
848849

850+
had_dat_in_data = true;
849851
this->update_display();
850852
}
851853

@@ -885,6 +887,7 @@ void AutScrollEdit::clear_dat_in()
885887

886888
this->clear();
887889
dat_out_updated = true;
890+
had_dat_in_data = false;
888891

889892
this->moveCursor(QTextCursor::End);
890893
this->update_display();

AuTerm/AutScrollEdit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class AutScrollEdit : public QPlainTextEdit
133133
int32_t dat_in_new_len; //Holds position of QString-version of mstrDatIn where the mstrDatIn ends
134134
QTextCharFormat last_format; //Last format applied to dat out data
135135
vt100_mode vt100_control_mode; //VT100 control code mode
136+
bool had_dat_in_data; //True if there is current data displayed from the dat in buffer
136137

137138
public:
138139
bool mbLocalEcho; //True if local echo is enabled

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.16"; //Version string
106+
const QString UwVersion = "0.16a"; //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, 16, 0, 0
5-
PRODUCTVERSION 0, 16, 0, 0
4+
FILEVERSION 0, 16, 1, 0
5+
PRODUCTVERSION 0, 16, 1, 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.16.0.0\0"
22+
VALUE "FileVersion", "0.16.1.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.16.0.0\0"
27+
VALUE "ProductVersion", "0.16.1.0\0"
2828
END
2929
END
3030
END

0 commit comments

Comments
 (0)