add support for < and > is copyAsHTML (issue #351)

This commit is contained in:
benfry
2010-08-11 00:13:48 +00:00
parent ea15d09985
commit 555c26a1c4
3 changed files with 25 additions and 1 deletions
@@ -1621,6 +1621,7 @@ public class JEditTextArea extends JComponent
for (int j = 0; j < segmentCount; j++) {
char c = segmentArray[j + segmentOffset];
cf = cf.append(c);
appendAsHTML(cf, c);
}
} else {
// If syntax coloring is enabled, we have to do this
@@ -1644,7 +1645,8 @@ public class JEditTextArea extends JComponent
if (id == Token.END) {
char c = segmentArray[segmentOffset + offset];
if (segmentOffset + offset < limit) {
cf.append(c);
// cf.append(c);
appendAsHTML(cf, c);
} else {
cf.append('\n');
}
@@ -1679,6 +1681,22 @@ public class JEditTextArea extends JComponent
}
}
}
/**
* Handle encoding HTML entities for lt, gt, and anything non-ASCII.
*/
private void appendAsHTML(StringBuffer buffer, char c) {
if (c == '<') {
buffer.append("&lt;");
} else if (c == '>') {
buffer.append("&rt;");
} else if (c > 127) {
buffer.append("&#" + ((int) c) + ";"); // use unicode entity
} else {
buffer.append(c); // normal character
}
}
/**
+3
View File
@@ -6,6 +6,9 @@ X fix the behavior
_ need to finish font changes wrt native fonts before any release
_ right now not in a good place--default font will be bitmapped and ugly
_ bug in SVG parser for shorthand curves (T/t and S/s)
_ http://code.google.com/p/processing/issues/detail?id=350
_ image resizing is ugly (just use java2d?)
_ http://code.google.com/p/processing/issues/detail?id=332
+3
View File
@@ -5,6 +5,9 @@ X the open button on the toolbar is goofed up
X http://code.google.com/p/processing/issues/detail?id=323
X changed how "Save As" works, now copies everything in the folder
X but ignores applet, application.*, screen-* files/folders
X Edit > Copy as HTML doesn't properly encode < and >
X http://code.google.com/p/processing/issues/detail?id=351
X also fixed unicode entities
earlier
X add warning message when not using a version of sun java w/ p5 on linux