working on editor and fixing colors

This commit is contained in:
benfry
2003-01-05 20:45:46 +00:00
parent 245ef1f8a1
commit e40680f508
2 changed files with 15 additions and 21 deletions

View File

@@ -1006,42 +1006,32 @@ public class PdeBase extends Frame implements ActionListener {
return parsed;
}
static public Font getFont(String which, Font otherwise) {
//System.out.println("getting font '" + which + "'");
String str = get(which);
if (str == null) return otherwise; // ENABLE LATER
StringTokenizer st = new StringTokenizer(str, ",");
return new Font(st.nextToken(),
st.nextToken().equals("bold") ? Font.BOLD : Font.PLAIN,
return new Font(st.nextToken(), Font.PLAIN,
Integer.parseInt(st.nextToken()));
}
static public SimpleAttributeSet getStyle(String what,
SimpleAttributeSet otherwise) {
String str = get("editor.program." + what + ".style");
if (str == null) return otherwise; // ENABLE LATER
static public SyntaxStyle getStyle(String what, String dflt) {
String str = get("editor.program." + what + ".style", dflt);
StringTokenizer st = new StringTokenizer(str, ",");
SimpleAttributeSet style = new SimpleAttributeSet();
StyleConstants.setFontFamily(style, st.nextToken());
String s = st.nextToken();
StyleConstants.setBold(style, s.indexOf("bold") != -1);
StyleConstants.setItalic(style, s.indexOf("italic") != -1);
StyleConstants.setFontSize(style, Integer.parseInt(st.nextToken()));
if (s.indexOf("#") == 0) s = s.substring(1);
Color color = new Color(Integer.parseInt(s, 16));
s = st.nextToken();
if (s.indexOf("#") == 0) s = s.substring(1);
StyleConstants.setForeground(style, new Color(Integer.parseInt(s, 16)));
boolean bold = (s.indexOf("bold") != -1);
boolean italic = (s.indexOf("italic") != -1);
//System.out.println(str + " " + bold + " " + italic);
s = st.nextToken();
if (s.indexOf("#") == 0) s = s.substring(1);
StyleConstants.setBackground(style, new Color(Integer.parseInt(s, 16)));
return style;
return new SyntaxStyle(color, italic, bold);
}

View File

@@ -587,6 +587,7 @@ public class PdeEditor extends Panel {
}
//textarea.editorSetText(buffer.toString());
textarea.setText(buffer.toString());
textarea.select(0, 0);
historyLast = textarea.getText();
setSketchModified(false);
@@ -990,6 +991,7 @@ afterwards, some of these steps need a cleanup function
//System.out.print(program);
//textarea.editorSetText(program);
textarea.setText(program);
textarea.select(0, 0);
//System.out.print(textarea.getText());
@@ -1027,6 +1029,7 @@ afterwards, some of these steps need a cleanup function
//System.out.println("new guy, so setting empty");
// style info only gets set if there's text
textarea.setText("");
textarea.select(0, 0);
//textarea.editorSetText(" ");
// now set to now text. yay hack!
//textarea.editorSetText(""); // this doesn't work. oh well
@@ -1703,6 +1706,7 @@ afterwards, some of these steps need a cleanup function
}
//textarea.editorSetText(buffer.toString());
textarea.setText(buffer.toString());
textarea.select(0, 0);
setSketchModified(true);
buttons.clear();
}