Replies: 1 comment 2 replies
-
Hi Jens! First of all, your code contains memory safety errors. The Here is a possible fix: @@ -16,16 +16,16 @@ TEditor::formatLine(
Color = 0x1e;
while (1) {
+ if (P >= bufLen || X >= Width) break;
chars = bufChars(P);
Ch = chars[0];
- if (X >= Width) break;
if (Ch == '(') {
::setCell(Cells[X], '(', 0x1e);
X++;
P++;
chars = bufChars(P);
Ch = chars[0];
- if (X >= Width) break;
+ if (P >= bufLen || X >= Width) break;
if (Ch == '*') {
tokenIsComment = true;
::setCell(Cells[X-1], '(', 0x03);
@@ -33,13 +33,14 @@ TEditor::formatLine(
X++;
P++;
while (1) {
+ if (P >= bufLen || X >= Width) break;
chars = bufChars(P);
Ch = chars[0];
- if (X >= Width) break;
if (Ch == '*') {
::setCell(Cells[X], '*', 0x03);
X++;
P++;
+ if (P >= bufLen || X >= Width) break;
chars = bufChars(P);
Ch = chars[0];
if (Ch == ')') {
@@ -84,6 +85,7 @@ TEditor::formatLine(
::setCell(Cells[X], '*', 0x03);
X++;
P++;
+ if (P >= bufLen || X >= Width) break;
chars = bufChars(P);
Ch = chars[0];
@@ -137,4 +139,6 @@ TEditor::formatLine(
break;
}
}
+ while (X < Width)
+ ::setCell(Cells[X++], ' ', Color);
} Then, the What if you have scrolled down the document and the comment begin ( |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have working on a simple Syntax Highlighter for using by other Developers.
At the current Time, only Pascal Comment's are supported.
Pleas forgive me for the poor implementation - I am not so the good programmer.
It would be nice, if you left a note on the work from me.
For doing Syntax Highlighting, I change the "edtis.cpp" from the magiblot 1 source tree of Turbo Vision.
The "Turbo" thing was me so big, to adapt the code, so I working on my own.
Have fun with it, and stay tuned ...
Here is a simple Example source
And there, you can see a Example Application with a Text-Editor in Front of:
https://imgur.com/rdAn5sO
Beta Was this translation helpful? Give feedback.
All reactions