Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#414: slow StyledTextRenderer for unicode and unprintable control cha… #1439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,14 @@ public boolean isDisposed () {
return device == null;
}

private static char replaceBelowSpaceCharacters(char chr) {
if (chr >= 0x20 || chr == '\t' || chr == '\r' || chr == '\n') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider allowing more?
Other characters that are used in CLI applications:

  • \u0007 : BELL, makes a "beep" sound
  • \u0008 : BS, backspace, moves back one character
  • \u001B : ESC, used for ANSI escape sequences (changing colors, cursor movement, clear screen, etc). This one is used quite a lot.

Since the Eclipse Console is built on top of the styled text widget not allowing ESC might break quite a lot of things.
(see https://eclipse.dev/eclipse/news/4.25/platform.php#debug-ansi-support)

return chr;
}

return '?'; // (char)(0x2400 + chr);
}

/*
* Itemize the receiver text
*/
Expand Down Expand Up @@ -2881,6 +2889,9 @@ StyleItem[] itemize () {
int[] pcItems = new int[1];
char[] chars = new char[length];
segmentsText.getChars(0, length, chars, 0);
for (int i = 0; i < length; i++) {
chars[i] = replaceBelowSpaceCharacters(chars[i]);
}
// enable font ligatures
scriptControl.fMergeNeutralItems = true;
/*
Expand Down Expand Up @@ -3740,6 +3751,9 @@ void shape (GC gc, final long hdc, final StyleItem run) {
final int[] buffer = new int[1];
final char[] chars = new char[run.length];
segmentsText.getChars(run.start, run.start + run.length, chars, 0);
for (int i = 0; i < chars.length; i++) {
chars[i] = replaceBelowSpaceCharacters(chars[i]);
}

final int maxGlyphs = (chars.length * 3 / 2) + 16;
long hHeap = OS.GetProcessHeap();
Expand Down
Loading