stopped flicker in PdeEditorTextPane loading.. yeowchh

This commit is contained in:
benfry
2002-10-22 02:48:30 +00:00
parent 2a8459dfeb
commit 33f91aca0b
5 changed files with 78 additions and 28 deletions

View File

@@ -10,9 +10,9 @@ import javax.comm.*;
import javax.swing.text.*;
public class PdeBase implements ActionListener {
public class PdeBase extends Frame implements ActionListener {
static Properties properties;
static Frame frame;
static Frame frame; // now 'this'
static String encoding;
static Image icon;
@@ -83,16 +83,39 @@ public class PdeBase implements ActionListener {
}
}
//try {
PdeBase app = new PdeBase();
// people attempting to use p5 in headless mode are
// already setting themselves up for disappointment
//} catch (HeadlessException e) {
//e.printStackTrace();
//System.exit(1);
//}
}
// hack for #@#)$(* macosx
public Dimension getMinimumSize() {
return new Dimension(300, 300);
}
public PdeBase() {
super(WINDOW_TITLE);
//#ifdef JDK14
// try {
//#endif
/*
frame = new Frame(WINDOW_TITLE) {
// hack for #@#)$(* macosx
public Dimension getMinimumSize() {
return new Dimension(300, 300);
}
};
*/
frame = this; // clean this up later
//#ifdef JDK14
//#endif
try {
icon = Toolkit.getDefaultToolkit().getImage("lib/icon.gif");

View File

@@ -115,9 +115,13 @@ public class PdeEditor extends Panel {
textarea = new PdeEditorTextPane();
JScrollPane scroller = new JScrollPane();
//scroller.setDoubleBuffered(true);
JViewport viewport = scroller.getViewport();
viewport.setDoubleBuffered(true);
//textarea = new JEditorPane("text/java", "");
viewport.add(textarea);
// viewport.setScrollMode(JViewport.BLIT_SCROLL_MODE);
//textarea.setFont(PdeBase.getFont("editor.program.font",
// new Font("Monospaced",
@@ -397,7 +401,7 @@ public class PdeEditor extends Panel {
}
if (found) {
// read lines until the next separator
//textarea.setText("");
//textarea.editorSetText("");
line = reader.readLine(); // ignored
String sep = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer();
@@ -407,7 +411,7 @@ public class PdeEditor extends Panel {
buffer.append(line + sep);
//System.out.println("'" + line + "'");
}
textarea.setText(buffer.toString());
textarea.editorSetText(buffer.toString());
historyLast = textarea.getText();
setSketchModified(false);
@@ -779,18 +783,18 @@ public class PdeEditor extends Panel {
// once read all the bytes, convert it to the proper
// local encoding for this system.
//textarea.setText(app.languageEncode(data));
//textarea.editorSetText(app.languageEncode(data));
// what the hell was i thinking when i wrote this code
//if (app.encoding == null)
program = new String(data);
//textarea.setText(new String(data));
textarea.setText(program);
//textarea.editorSetText(new String(data));
textarea.editorSetText(program);
//System.out.println(" loading program = " + new String(data));
//else
//textarea.setText(new String(data, app.encoding));
//textarea.editorSetText(new String(data, app.encoding));
} else {
textarea.setText("");
textarea.editorSetText("");
}
//System.out.println("should be done opening");
sketchName = isketchName;
@@ -922,7 +926,7 @@ public class PdeEditor extends Panel {
handleOpen(newSketchName, newSketchFile, newSketchDir);
// update with the new junk and save that as the new code
textarea.setText(textareaContents);
textarea.editorSetText(textareaContents);
textarea.setCaretPosition(textareaPosition);
doSave();
}
@@ -1426,7 +1430,7 @@ public class PdeEditor extends Panel {
gotBlankLine = false;
}
}
textarea.setText(buffer.toString());
textarea.editorSetText(buffer.toString());
setSketchModified(true);
buttons.clear();
}

View File

@@ -67,6 +67,8 @@ public class PdeEditorTextPane extends JTextPane {
setStyledDocument(document);
textPane = this;
//setDoubleBuffered(true);
//textPane.setCaretPosition(0);
//textPane.setMargin(new Insets(5,5,5,5));
@@ -122,23 +124,29 @@ public class PdeEditorTextPane extends JTextPane {
StyleConstants.setItalic(dstyle, false);
//styles.put("body", style);
/*
styles.put("body", PdeBase.getStyle("body", dstyle));
styles.put("tag", PdeBase.getStyle("tag", dstyle));
styles.put("endtag", PdeBase.getStyle("tag", dstyle)); // same
styles.put("reference", PdeBase.getStyle("reference", dstyle));
styles.put("name", PdeBase.getStyle("name", dstyle));
styles.put("value", PdeBase.getStyle("value", dstyle));
styles.put("preprocessor", PdeBase.getStyle("preprocessor", dstyle));
styles.put("text", PdeBase.getStyle("text", dstyle));
*/
styles.put("reservedWord", PdeBase.getStyle("reserved_word", dstyle));
styles.put("identifier", PdeBase.getStyle("identifier", dstyle));
styles.put("whitespace", PdeBase.getStyle("whitespace", dstyle));
styles.put("literal", PdeBase.getStyle("literal", dstyle));
styles.put("separator", PdeBase.getStyle("separator", dstyle));
styles.put("operator", PdeBase.getStyle("operator", dstyle));
styles.put("identifier", PdeBase.getStyle("identifier", dstyle));
styles.put("comment", PdeBase.getStyle("comment", dstyle));
styles.put("preprocessor", PdeBase.getStyle("preprocessor", dstyle));
styles.put("whitespace", PdeBase.getStyle("whitespace", dstyle));
styles.put("operator", PdeBase.getStyle("operator", dstyle));
/*
styles.put("error", PdeBase.getStyle("error", dstyle));
styles.put("unknown", PdeBase.getStyle("unknown", dstyle));
*/
// create the new document.
documentReader = new DocumentReader(document);
@@ -178,18 +186,21 @@ public class PdeEditorTextPane extends JTextPane {
//////////////////////////////////////////////////////////////
/*
public void setText(String program) {
public void editorSetText(String program) {
try {
//System.out.println("good settext ");
document.remove(0, document.getLength());
document.insertString(0, program, grabStyle("text"));
//document.insertString(0, program, grabStyle("text"));
document.insertString(0, program, grabStyle("whitespace"));
} catch (BadLocationException ble) {
System.err.println("PdeEditorTextPane.setText() failed");
}
}
public String getText() {
/*
public String egetText() {
try {
return document.getText(0, document.getLength());
@@ -198,7 +209,9 @@ public class PdeEditorTextPane extends JTextPane {
}
return null;
}
*/
/*
public void setCaretPosition(int what) {
textPane.setCaretPosition(what);
@@ -409,12 +422,14 @@ public class PdeEditorTextPane extends JTextPane {
// to the hash table that has been set up ahead of time.
synchronized (doclock){
if (t.getCharEnd() <= document.getLength()){
document.setCharacterAttributes(
t.getCharBegin() + change,
// System.out.println(t.getDescription() + " " +
// (t.getCharBegin() + change));
//if (!t.getDescription().equals("text")) {
document.setCharacterAttributes(t.getCharBegin() + change,
t.getCharEnd()-t.getCharBegin(),
grabStyle(t.getDescription()),
true
);
true);
//}
// record the position of the last bit of text that we colored
dpEnd = new DocPosition(t.getCharEnd());
}
@@ -521,7 +536,7 @@ public class PdeEditorTextPane extends JTextPane {
* @param adjustment amount of text inserted or removed
* at the starting point.
*/
public void color(int position, int adjustment){
public void color(int position, int adjustment) {
colorer.color(position, adjustment);
}

View File

@@ -62,13 +62,15 @@ cd ..
### -- BUILD PDE ------------------------------------------------
echo Building PDE for JDK 1.3
#echo Building PDE for JDK 1.3
echo Building PDE for JDK 1.4
cd app
CLASSPATH=../build/windows/work/classes:../build/windows/work/lib/kjc.jar:../build/windows/work/lib/oro.jar:../build/windows/work/java/lib/rt.jar:../build/windows/work/java/lib/ext/comm.jar
perl ../bagel/buzz.pl "jikes +D -classpath $CLASSPATH -d ../build/windows/work/classes" -dJDK13 *.java lexer/*.java
#perl ../bagel/buzz.pl "jikes +D -classpath $CLASSPATH -d ../build/windows/work/classes" -dJDK13 *.java lexer/*.java
perl ../bagel/buzz.pl "jikes +D -classpath $CLASSPATH -d ../build/windows/work/classes" -dJDK13 -dJDK14 *.java lexer/*.java
cd ../build/windows/work/classes
rm -f ../lib/pde.jar

View File

@@ -1,12 +1,17 @@
0046
X install new swing-based textarea with syntax highlighting
_ set better defaults for coloring
_ improve the flicker problems (re-enable backing store?)
_ implement edit menu
bagel
_ font smoothing (unless hint SMOOTH_IMAGES enabled) is broken
_ images don't load during setup()
_ finish fill mode of flat circle function
_ 'image' is too generic a variable to have inside BApplet
_ check for others that shouldn't be used (pixels? width? height?)
_ these boxes overlap but shouldn't:
_ may be simple <= instead of <, leftover from dbn
int thick = 36;
size(200, 200);
background(0);
@@ -35,6 +40,7 @@ _ ME seems to be very broken
macosx
_ put mac rxtx inside the p5 folder (hide it?)
_ include more strongly worded message about rxtx
_ bug report from the site
resizing the editor window in Mac OS X leaves the status bar in
place. The result is an editor window with a grey bar layered on top,