js mode: pjs directive regex fix, crash on cancel-need-save fix and more

This commit is contained in:
fjenett
2011-06-22 21:21:45 +00:00
parent 92aa4d3920
commit d274f19ff2
5 changed files with 55 additions and 8 deletions

View File

@@ -145,10 +145,14 @@ public class DirectivesEditor
/* remove framing */
mm = mm.replaceAll("^\\/\\*\\s*@pjs","").replaceAll("\\s*\\*\\/\\s*$","");
/* fix multiline nice formatting */
mm = mm.replaceAll("[\\s]*([^;\\s\\n\\r]+)[\\s]*,[\\s]*[\\n\\r]+","$1,");
/* fix multiline version without semicolons */
mm = mm.replaceAll("([^;\\s\\n\\r]+)[\\s]*[\\n\\r]+","$1;");
mm = mm.replaceAll("\n","").replaceAll("\r","");
mm = mm.replaceAll("[\\s]*([^;\\s\\n\\r]+)[\\s]*[\\n\\r]+","$1;");
mm = mm.replaceAll("\n"," ").replaceAll("\r"," ");
System.out.println(mm);
if ( clean )
{
m.appendReplacement(buffer, "");
@@ -198,7 +202,14 @@ public class DirectivesEditor
return;
}
String key = pair[0].trim(), value = pair[1].trim();
String key = pair[0].trim(),
value = pair[1].trim();
// clean these, might have too much whitespace around commas
if ( validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD )
{
value = value.replaceAll("[\\s]*,[\\s]*", ",");
}
if ( validKeys.indexOf(key) == -1 )
{

View File

@@ -351,10 +351,15 @@ public class JavaScriptEditor extends Editor
*/
public boolean handleExport ( boolean openFolder )
{
if (handleExportCheckModified())
if ( !handleExportCheckModified() )
{
return false;
}
else
{
toolbar.activate(JavaScriptToolbar.EXPORT);
try {
try
{
boolean success = jsMode.handleExport(sketch);
if ( success && openFolder )
{

View File

@@ -115,8 +115,8 @@ public class JavaScriptMode extends Mode
File[] jModeExamples = new File[] {
new File(jExamples, "Basics"),
new File(jExamples, "Topics"),
new File(jExamples, "3D"),
new File(jExamples, "Books")
new File(jExamples, "3D") /*,
new File(jExamples, "Books")*/
};
// merge them all

View File

@@ -14,7 +14,6 @@ class JavaScriptServer implements HttpConstants, Runnable
Thread thread = null;
ServerSocket server = null;
// TODO: this needed? SocketException on stop coming from here?
//private ArrayList<Worker> threads = new ArrayList<Worker>();
//private int workers = 5;