Menu

#1 TextArea() isn't showing lone newlines.

Unstable (example)
open
nobody
5
2005-04-08
2005-04-08
Anonymous
No

Doing an AddText() on a TextArea doesn't show
newlines, as a byproduct of how the line vector gets
built (the strtok invocation in AddText() eats up
newlines).

Here's my fix (against version 0.78.2):

void TextArea::AddText(const char *text) {
char *tok;
char *copy;
char *temp;

copy = new char[ustrsizez(text)];
ustrcpy(copy, text);

temp = copy;
while (*temp == '\n')
{
string s = "";
lines.push_back(s);
temp++;
}

tok = ustrtok(temp, "\n");
while (tok) {
string s = tok;
lines.push_back(s);

temp += ustrsizez(tok);
while ((*temp == '\n') && (*temp !
= '\0'))
{
string s = "";
lines.push_back(s);
temp++;
}
if (*temp == '\0')
{
break;
}

tok = ustrtok(temp, "\n");
}

CalculateRange();

delete [] copy;
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.