/** * @param method "size" or "fullScreen" * @param args parameters passed to the function so we can show the user * @return true if safely inside the settings() method */ boolean insideSettings(String method, Object... args) { if (insideSettings) { return true; } final String url = "https://processing.org/reference/" + method + "_.html"; if (!external) { // post a warning for users of Eclipse and other IDEs StringList argList = new StringList(args); System.err.println("When not using the PDE, " + method + "() can only be used inside settings()."); System.err.println("Remove the " + method + "() method from setup(), and add the following:"); System.err.println("public void settings() {"); System.err.println(" " + method + "(" + argList.join(", ") + ");"); System.err.println("}"); } throw new IllegalStateException(method + "() cannot be used here, see " + url); }
/** * @param method "size" or "fullScreen" * @param args parameters passed to the function so we can show the user * @return true if safely inside the settings() method */ boolean insideSettings(String method, Object... args) { if (insideSettings) { return true; } final String url = "https://processing.org/reference/" + method + "_.html"; if (!external) { // post a warning for users of Eclipse and other IDEs StringList argList = new StringList(args); System.err.println("When not using the PDE, " + method + "() can only be used inside settings()."); System.err.println("Remove the " + method + "() method from setup(), and add the following:"); System.err.println("public void settings() {"); System.err.println(" " + method + "(" + argList.join(", ") + ");"); System.err.println("}"); } throw new IllegalStateException(method + "() cannot be used here, see " + url); }
/** * Return this dictionary as a String in JSON format. */ public String toJSON() { StringList items = new StringList(); for (int i = 0; i < count; i++) { items.append(JSONObject.quote(keys[i])+ ": " + values[i]); } return "{ " + items.join(", ") + " }"; }
/** * Return this dictionary as a String in JSON format. */ public String toJSON() { StringList items = new StringList(); for (int i = 0; i < count; i++) { items.append(JSONObject.quote(keys[i])+ ": " + values[i]); } return "{ " + items.join(", ") + " }"; }
/** * Return this dictionary as a String in JSON format. */ public String toJSON() { StringList items = new StringList(); for (int i = 0; i < count; i++) { items.append(JSONObject.quote(keys[i])+ ": " + JSONObject.quote(values[i])); } return "{ " + items.join(", ") + " }"; }
/** * Return this dictionary as a String in JSON format. */ public String toJSON() { StringList temp = new StringList(); for (String item : this) { temp.append(JSONObject.quote(item)); } return "[ " + temp.join(", ") + " ]"; }
/** * Same as exec() above, but prefixes the call with a shell. */ static public int shell(StringList stdout, StringList stderr, String... args) { String shell; String runCmd; StringList argList = new StringList(); if (platform == WINDOWS) { shell = System.getenv("COMSPEC"); runCmd = "/C"; } else { shell = "/bin/sh"; runCmd = "-c"; // attempt emulate the behavior of an interactive shell // can't use -i or -l since the version of bash shipped with macOS does not support this together with -c // also we want to make sure no motd or similar gets returned as stdout argList.append("if [ -f /etc/profile ]; then . /etc/profile >/dev/null 2>&1; fi;"); argList.append("if [ -f ~/.bash_profile ]; then . ~/.bash_profile >/dev/null 2>&1; elif [ -f ~/.bash_profile ]; then . ~/.bash_profile >/dev/null 2>&1; elif [ -f ~/.profile ]; then ~/.profile >/dev/null 2>&1; fi;"); } for (String arg : args) { argList.append(arg); } return exec(stdout, stderr, shell, runCmd, argList.join(" ")); }