mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
finishing up for 46
X fix default fonts, font size on mac X fix lots of annoying crap about highlighting lines on errors X re-enable console, add synchronized (hrmph)
This commit is contained in:
+4
-1
@@ -184,10 +184,13 @@ public class KjcEngine extends PdeEngine {
|
||||
if (PdeBase.getBoolean("compiler.color_datatype", true)) {
|
||||
// so that regexp works correctly in this strange edge case
|
||||
if (program.indexOf("color") == 0) program = " " + program;
|
||||
// swap 'color' with 'int' when used as a datatype
|
||||
program = substipoot(program,
|
||||
"([;\\s])color([\\s])", "$1int$2");
|
||||
//"([^A-Za-z0-9_.])color([^A-Za-z0-9_\\(.])", "$1int$2");
|
||||
program = substipoot(program, "([^A-Za-z0-9_])color\\((.*)\\)", "$1(int)($2)");
|
||||
// color(something) like int() and the rest is no good
|
||||
// because there is already a function called 'color' in BGraphics
|
||||
//program = substipoot(program, "([^A-Za-z0-9_])color\\((.*)\\)", "$1(int)($2)");
|
||||
}
|
||||
|
||||
if (PdeBase.getBoolean("compiler.inline_web_colors", true)) {
|
||||
|
||||
+4
-25
@@ -408,8 +408,8 @@ public class PdeBase extends Frame implements ActionListener {
|
||||
try {
|
||||
undo.undo();
|
||||
} catch (CannotUndoException ex) {
|
||||
System.out.println("Unable to undo: " + ex);
|
||||
ex.printStackTrace();
|
||||
//System.out.println("Unable to undo: " + ex);
|
||||
//ex.printStackTrace();
|
||||
}
|
||||
updateUndoState();
|
||||
redoAction.updateRedoState();
|
||||
@@ -437,8 +437,8 @@ public class PdeBase extends Frame implements ActionListener {
|
||||
try {
|
||||
undo.redo();
|
||||
} catch (CannotRedoException ex) {
|
||||
System.out.println("Unable to redo: " + ex);
|
||||
ex.printStackTrace();
|
||||
//System.out.println("Unable to redo: " + ex);
|
||||
//ex.printStackTrace();
|
||||
}
|
||||
updateRedoState();
|
||||
undoAction.updateUndoState();
|
||||
@@ -998,27 +998,6 @@ public class PdeBase extends Frame implements ActionListener {
|
||||
Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
|
||||
// return a default style, based on old conventions
|
||||
static public SimpleAttributeSet getStyle() {
|
||||
|
||||
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()));
|
||||
|
||||
s = st.nextToken();
|
||||
if (s.indexOf("#") == 0) s = s.substring(1);
|
||||
StyleConstants.setForeground(style, new Color(Integer.parseInt(s, 16)));
|
||||
|
||||
s = st.nextToken();
|
||||
if (s.indexOf("#") == 0) s = s.substring(1);
|
||||
StyleConstants.setBackground(style, new Color(Integer.parseInt(s, 16)));
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
static public SimpleAttributeSet getStyle(String what,
|
||||
SimpleAttributeSet otherwise) {
|
||||
|
||||
+38
-6
@@ -126,11 +126,31 @@ public class PdeEditor extends Panel {
|
||||
viewport.add(textarea);
|
||||
// viewport.setScrollMode(JViewport.BLIT_SCROLL_MODE);
|
||||
|
||||
// hack to set the font using the style, at least until i
|
||||
// can figure out something better to do with styles/coloring
|
||||
textarea.setFont(PdeBase.getFont("editor.program.default.style",
|
||||
new Font("Monospaced",
|
||||
Font.PLAIN, 12)));
|
||||
/*
|
||||
// doesn't work
|
||||
String farbe = PdeBase.get("editor.program.default.style");
|
||||
farbe = farbe.substring(farbe.indexOf("#") + 1, farbe.lastIndexOf(","));
|
||||
try {
|
||||
int v = Integer.parseInt(farbe, 16);
|
||||
textarea.setBackground(new Color(v));
|
||||
System.out.println(new Color(v));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} // oh well
|
||||
*/
|
||||
|
||||
/*
|
||||
textarea.setFont(PdeBase.getFont("editor.program.font",
|
||||
new Font("Monospaced",
|
||||
Font.PLAIN, 12)));
|
||||
textarea.setForeground(PdeBase.getColor("editor.program.fgcolor",
|
||||
Color.black));
|
||||
*/
|
||||
textarea.setBackground(PdeBase.getColor("editor.program.bgcolor",
|
||||
Color.white));
|
||||
|
||||
@@ -988,7 +1008,13 @@ afterwards, some of these steps need a cleanup function
|
||||
//setSketchModified(false);
|
||||
|
||||
} else {
|
||||
//System.out.println("new guy, so setting empty");
|
||||
// style info only gets set if there's text
|
||||
textarea.editorSetText("");
|
||||
//textarea.editorSetText(" ");
|
||||
// now set to now text. yay hack!
|
||||
//textarea.editorSetText(""); // this doesn't work. oh well
|
||||
//textarea.setCaretPosition(0); // next best thing
|
||||
}
|
||||
//System.out.println("should be done opening");
|
||||
sketchName = isketchName;
|
||||
@@ -1684,15 +1710,19 @@ afterwards, some of these steps need a cleanup function
|
||||
//System.out.println(lnum);
|
||||
String s = textarea.getText();
|
||||
int len = s.length();
|
||||
//int lnum = .line;
|
||||
int st = -1, end = -1;
|
||||
int st = -1;
|
||||
int ii = 0;
|
||||
int end = -1;
|
||||
int lc = 0;
|
||||
if (lnum == 0) st = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
ii++;
|
||||
//if ((s.charAt(i) == '\n') || (s.charAt(i) == '\r')) {
|
||||
boolean newline = false;
|
||||
if (s.charAt(i) == '\r') {
|
||||
if ((i != len-1) && (s.charAt(i+1) == '\n')) i++;
|
||||
if ((i != len-1) && (s.charAt(i+1) == '\n')) {
|
||||
i++; //ii--;
|
||||
}
|
||||
lc++;
|
||||
newline = true;
|
||||
} else if (s.charAt(i) == '\n') {
|
||||
@@ -1701,16 +1731,18 @@ afterwards, some of these steps need a cleanup function
|
||||
}
|
||||
if (newline) {
|
||||
if (lc == lnum)
|
||||
st = i+1;
|
||||
//st = i+1;
|
||||
st = ii;
|
||||
else if (lc == lnum+1) {
|
||||
end = i;
|
||||
//end = i;
|
||||
end = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (end == -1) end = len;
|
||||
//System.out.println("st/end: "+st+"/"+end);
|
||||
textarea.select(st, end+1);
|
||||
textarea.select(st, end);
|
||||
//if (iexplorerp) {
|
||||
//textarea.invalidate();
|
||||
//textarea.repaint();
|
||||
|
||||
+49
-47
@@ -31,7 +31,7 @@ public class PdeEditorConsole extends Component {
|
||||
int firstLine;
|
||||
int scrollOffset;
|
||||
|
||||
byte cline[] = new byte[1024];
|
||||
byte cline[] = new byte[4096];
|
||||
byte clength;
|
||||
boolean cerror;
|
||||
|
||||
@@ -114,10 +114,10 @@ public class PdeEditorConsole extends Component {
|
||||
consoleErr =
|
||||
new PrintStream(new PdeEditorConsoleStream(this, true, stderrFile));
|
||||
|
||||
/*
|
||||
System.setOut(consoleOut);
|
||||
System.setErr(consoleErr);
|
||||
*/
|
||||
if (PdeBase.getBoolean("editor.console.enabled", true)) {
|
||||
System.setOut(consoleOut);
|
||||
System.setErr(consoleErr);
|
||||
}
|
||||
}
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@@ -205,14 +205,14 @@ public class PdeEditorConsole extends Component {
|
||||
if (offscreen == null) return;
|
||||
Graphics g = offscreen.getGraphics();
|
||||
/*
|
||||
if (font == null) {
|
||||
if (font == null) {
|
||||
font = PdeBase.getFont("editor.console.font",
|
||||
new Font("Monospaced", Font.PLAIN, 11));
|
||||
new Font("Monospaced", Font.PLAIN, 11));
|
||||
//font = new Font("SansSerif", Font.PLAIN, 10);
|
||||
g.setFont(font);
|
||||
metrics = g.getFontMetrics();
|
||||
ascent = metrics.getAscent();
|
||||
}
|
||||
}
|
||||
*/
|
||||
g.setFont(font);
|
||||
|
||||
@@ -256,48 +256,50 @@ public class PdeEditorConsole extends Component {
|
||||
}
|
||||
|
||||
public void write(byte b[], int offset, int length, boolean err) {
|
||||
if ((clength > 0) && (err != cerror)) {
|
||||
// advance the line because switching between err/out streams
|
||||
message(new String(cline, 0, clength), cerror, true);
|
||||
clength = 0;
|
||||
}
|
||||
int last = offset+length - 1;
|
||||
// starting a new line, so set its output type to out or err
|
||||
if (clength == 0) cerror = err;
|
||||
for (int i = offset; i <= last; i++) {
|
||||
if (b[i] == CR) { // mac CR or win CRLF
|
||||
if ((i != last) && (b[i+1] == LF)) {
|
||||
// if windows CRLF, skip the LF too
|
||||
i++;
|
||||
}
|
||||
synchronized (cline) {
|
||||
if ((clength > 0) && (err != cerror)) {
|
||||
// advance the line because switching between err/out streams
|
||||
message(new String(cline, 0, clength), cerror, true);
|
||||
clength = 0;
|
||||
|
||||
} else if (b[i] == LF) { // unix LF only
|
||||
message(new String(cline, 0, clength), cerror, true);
|
||||
clength = 0;
|
||||
|
||||
} else if (b[i] == TAB) {
|
||||
if (clength + TAB_SIZE > cline.length) {
|
||||
byte temp[] = new byte[clength * 2];
|
||||
System.arraycopy(cline, 0, temp, 0, clength);
|
||||
cline = temp;
|
||||
}
|
||||
for (int m = 0; m < TAB_SIZE; m++) {
|
||||
cline[clength++] = ' ';
|
||||
}
|
||||
|
||||
} else {
|
||||
if (cline.length == clength) {
|
||||
byte temp[] = new byte[clength * 2];
|
||||
System.arraycopy(cline, 0, temp, 0, clength);
|
||||
cline = temp;
|
||||
}
|
||||
cline[clength++] = b[i];
|
||||
}
|
||||
}
|
||||
if (clength != 0) {
|
||||
message(new String(cline, 0, clength), cerror, false);
|
||||
int last = offset+length - 1;
|
||||
// starting a new line, so set its output type to out or err
|
||||
if (clength == 0) cerror = err;
|
||||
for (int i = offset; i <= last; i++) {
|
||||
if (b[i] == CR) { // mac CR or win CRLF
|
||||
if ((i != last) && (b[i+1] == LF)) {
|
||||
// if windows CRLF, skip the LF too
|
||||
i++;
|
||||
}
|
||||
message(new String(cline, 0, clength), cerror, true);
|
||||
clength = 0;
|
||||
|
||||
} else if (b[i] == LF) { // unix LF only
|
||||
message(new String(cline, 0, clength), cerror, true);
|
||||
clength = 0;
|
||||
|
||||
} else if (b[i] == TAB) {
|
||||
if (clength + TAB_SIZE > cline.length) {
|
||||
byte temp[] = new byte[clength * 2];
|
||||
System.arraycopy(cline, 0, temp, 0, clength);
|
||||
cline = temp;
|
||||
}
|
||||
for (int m = 0; m < TAB_SIZE; m++) {
|
||||
cline[clength++] = ' ';
|
||||
}
|
||||
|
||||
} else {
|
||||
if (cline.length == clength) {
|
||||
byte temp[] = new byte[clength * 2];
|
||||
System.arraycopy(cline, 0, temp, 0, clength);
|
||||
cline = temp;
|
||||
}
|
||||
cline[clength++] = b[i];
|
||||
}
|
||||
}
|
||||
if (clength != 0) {
|
||||
message(new String(cline, 0, clength), cerror, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,11 +140,14 @@ public class PdeEditorTextPane extends JTextPane {
|
||||
styles.put("text", PdeBase.getStyle("text", dstyle));
|
||||
*/
|
||||
|
||||
styles.put("default", PdeBase.getStyle("default", dstyle));
|
||||
styles.put("identifier", PdeBase.getStyle("default", dstyle));
|
||||
|
||||
styles.put("reservedWord", PdeBase.getStyle("reserved_word", dstyle));
|
||||
styles.put("whitespace", PdeBase.getStyle("whitespace", dstyle));
|
||||
styles.put("literal", PdeBase.getStyle("literal", dstyle));
|
||||
styles.put("separator", PdeBase.getStyle("separator", dstyle));
|
||||
styles.put("identifier", PdeBase.getStyle("identifier", dstyle));
|
||||
//styles.put("identifier", PdeBase.getStyle("identifier", dstyle));
|
||||
styles.put("comment", PdeBase.getStyle("comment", dstyle));
|
||||
styles.put("operator", PdeBase.getStyle("operator", dstyle));
|
||||
|
||||
@@ -196,7 +199,11 @@ public class PdeEditorTextPane extends JTextPane {
|
||||
//System.out.println("good settext ");
|
||||
document.remove(0, document.getLength());
|
||||
//document.insertString(0, program, grabStyle("text"));
|
||||
document.insertString(0, program, grabStyle("whitespace"));
|
||||
//document.insertString(0, program, grabStyle("whitespace"));
|
||||
//Style style = (Style) grabStyle("default");
|
||||
//if (style != null) setLogicalStyle(style);
|
||||
document.insertString(0, program, grabStyle("default"));
|
||||
//setCaretPosition(0);
|
||||
|
||||
} catch (BadLocationException ble) {
|
||||
System.err.println("PdeEditorTextPane.setText() failed");
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
# osx makes things a little large by default
|
||||
editor.program.font = Monospaced,plain,10
|
||||
# the usual 12 point from other platforms is too big on osx
|
||||
editor.program.default.style = Monospaced,plain,10,#000000,#ffffff
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
#editor.buttons.status.font = SansSerif,plain,10
|
||||
#editor.buttons.status.color = #333333
|
||||
|
||||
#editor.program.rows = 20
|
||||
#editor.program.columns = 60
|
||||
#editor.program.font = Monospaced,plain,12
|
||||
|
||||
# default/base style for everything
|
||||
editor.program.default.style = Monospaced,plain,12,#000000,#ffffff
|
||||
|
||||
# int, void, public, etc..
|
||||
editor.program.reserved_word.style = Monospaced,plain,12,#000080,#ffffff
|
||||
@@ -23,36 +21,24 @@ editor.program.comment.style = Monospaced,plain,12,#808080,#ffffff
|
||||
editor.program.whitespace.style = Monospaced,plain,12,#000000,#ffffff
|
||||
|
||||
# brackets, semicolons, etc
|
||||
#editor.program.separator.style = Monospaced,plain,12,#008000,#ffffff
|
||||
#editor.program.separator.style = Monospaced,plain,12,#008000,#ffffff
|
||||
|
||||
# math guys + - / *
|
||||
#editor.program.operator.style = Monospaced,plain,12,#008000,#ffffff
|
||||
#editor.program.operator.style = Monospaced,plain,12,#008000,#ffffff
|
||||
|
||||
# just about everything else
|
||||
#editor.program.identifier.style = Monospaced,plain,12,#000000,#ffffff
|
||||
|
||||
# unused for java editor
|
||||
|
||||
#editor.program.body.style = Monospaced,plain,12,#000000,#ffffff
|
||||
#editor.program.tag.style = Monospaced,plain,12,#800000,#ffffff
|
||||
#editor.program.reference.style = Monospaced,plain,12,#000000,#ffffff
|
||||
#editor.program.name.style = Monospaced,plain,12,#b03060,#ffffff
|
||||
#editor.program.value.style = Monospaced,plain,12,#b03060,#ffffff
|
||||
#editor.program.text.style = Monospaced,plain,12,#000000,#ffffff
|
||||
#editor.program.preprocessor.style = Monospaced,plain,12,#a020f0,#ffffff
|
||||
#editor.program.error.style = Monospaced,plain,12,#800000,#ffffff
|
||||
#editor.program.unknown.style = Monospaced,plain,12,#804000,#ffffff
|
||||
# just about everything (ignored, default is used instead)
|
||||
#editor.program.identifier.style = Monospaced,plain,12,#000000,#ffffff
|
||||
|
||||
#editor.header.bgcolor = #333333
|
||||
#editor.header.fgcolor.primary = #ffffff
|
||||
#editor.header.fgcolor.secondary = #cccccc
|
||||
#editor.header.font = SansSerif,plain,12
|
||||
|
||||
#editor.console.bgcolor = #0a0a0a
|
||||
#editor.console.fgcolor.output = #cccccc
|
||||
#editor.console.fgcolor.error = #cc0000
|
||||
#editor.console.font = Monospaced,plain,11
|
||||
#editor.console.lines = 6
|
||||
#editor.console.bgcolor = #0a0a0a
|
||||
#editor.console.fgcolor.output = #cccccc
|
||||
#editor.console.fgcolor.error = #cc0000
|
||||
#editor.console.font = Monospaced,plain,11
|
||||
#editor.console.lines = 6
|
||||
|
||||
#editor.status.notice.fgcolor = #333333
|
||||
#editor.status.notice.bgcolor = #cccccc
|
||||
@@ -80,7 +66,7 @@ editor.program.whitespace.style = Monospaced,plain,12,#000000,#ffffff
|
||||
#editor.balance_parens=false
|
||||
|
||||
|
||||
# these properties are no longer especially in use
|
||||
# these properties are no longer in use
|
||||
|
||||
# enable this to run hack-version mildly stabler external processing
|
||||
#play.external = true
|
||||
@@ -92,6 +78,6 @@ editor.program.whitespace.style = Monospaced,plain,12,#000000,#ffffff
|
||||
# it will also be necessary to put processing in c:\
|
||||
#play.externalCommand = C:\\processing\\bin\\jre -cp c:\\processing\\lib;c:\\processing\\lib\\pde.jar;c:\\processing\\lib\\kjc.jar;c:\\processing\\lib\\comm.jar ProcessingAppletViewer
|
||||
|
||||
#update.enabled
|
||||
# auto updating
|
||||
#update.url = http://acg.media.mit.edu/people/fry/processing/update/
|
||||
#update.url = http://imrf.or.jp/processing/update/
|
||||
|
||||
@@ -98,16 +98,13 @@ X 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,
|
||||
obscuring the editable text.
|
||||
X fix default fonts, font size on mac
|
||||
X fix lots of annoying crap about highlighting lines on errors
|
||||
X re-enable console, add synchronized (hrmph)
|
||||
|
||||
|
||||
FINISH for 46
|
||||
|
||||
pde
|
||||
_ lots of problems with the console [maybe this needs to be a textarea?]
|
||||
_ long lines seem to be trouble
|
||||
_ also printing of objects, esp when null, in jdk 14
|
||||
_ exception when trying to write to stdout
|
||||
|
||||
macosx
|
||||
_ update dist script for new layout
|
||||
_ put mac rxtx inside the p5 folder (hide it?)
|
||||
@@ -136,6 +133,14 @@ _ make into oval function
|
||||
_ font smoothing (unless hint SMOOTH_IMAGES enabled) is broken
|
||||
|
||||
pde
|
||||
_ lots of problems with the console
|
||||
_ [maybe this needs to be a textarea?]
|
||||
_ long lines seem to be trouble
|
||||
_ also printing of objects, esp when null, in jdk 14
|
||||
_ exception when trying to write to stdout
|
||||
_ color not set for default text area with empty text
|
||||
_ color not set on 'new', setForeground won't do it
|
||||
_ probably reasonably simple fix, but not in time
|
||||
_ support 'classes' folder, through the use of a classloader
|
||||
_ could also be done by launching external java app
|
||||
_ all .jar files etc are added from this folder automatically
|
||||
@@ -148,6 +153,11 @@ _ is setText goobering up on beautify?
|
||||
_ how are line endings working during save?
|
||||
_ get syntax coloring debugged?
|
||||
_ talk to casey about better default colors
|
||||
_ scroll to beginning after setText()
|
||||
_ undo/redo
|
||||
_ should enable/disable as available
|
||||
_ undo-ing too much will empty the text area
|
||||
_ the setText is an undoable thing. grr.
|
||||
|
||||
windows
|
||||
_ need splash screen, startup takes a long time
|
||||
|
||||
Reference in New Issue
Block a user