Ok, i am currently busy with an project to minimize the console output window to put as much as possible source code on my screen, because i rather have as much as possible source code in my screen because i work in there. The console output is the result.
I currently created this, it catches the console output in a file and with a button i can read the console output. The errors are still in the console output window because i can't find a way to give text a different colour in the GUI textbox (i currently think that there is no option at all). It's also possible to put the textbox in a window, or a panel. I am currently busy with that, but i still have problems with windows and panels.
btw, i used Quarks GUI components library.
- import guicomponents.*;
- GTextField eventLog1;
- GButton eventLog1up, eventLog1down, consolePromptloadout;
- String OUT_FILE = "out.txt";
- String ERR_FILE = "err.txt";
- ArrayList events1 = new ArrayList();
- void setup() {
- size(800,400);
- eventLog1 = new GTextField(this, "eventlog", 10, 150, 700, 100, true);
- eventLog1.tag = "eventLog1 -> ";
- // eventLog1up
- eventLog1up = new GButton(this, "Up", 10, 250, 50, 20);
- eventLog1up.tag = "Console SCROLL UP";
- eventLog1down = new GButton(this, "Down", 70, 250, 50, 20);
- eventLog1down.tag = "Console SCROLL DOWN";
- consolePromptloadout = new GButton(this, "Out", 200, 250, 50, 20);
- consolePromptloadout.tag = "consolePrompt READOUT";
- File outFile = sketchFile(OUT_FILE);
- File errFile = sketchFile(ERR_FILE);
- // if (errFile.exists()) errFile.delete(); // not needed, it always overwrite
- try {
- System.setOut(new PrintStream(new FileOutputStream(outFile, false)));
- // System.setErr(new PrintStream(new FileOutputStream(errFile, false)));
- }
- catch (IOException e) {
- System.err.println("Error! "+e);
- }
- for (int i=0;i<100;i++) println("Console output line : "+i);
- }
- void draw() {
- }
- void handleButtonEvents(GButton button) {
- if (button == consolePromptloadout && button.eventType == GButton.CLICKED) {
- File outFile = sketchFile(OUT_FILE);
- String lines[] = loadStrings(outFile);
- //println("there are " + lines.length + " lines");
- for (int i=0; i < lines.length; i++) {
- // System.err.println(lines[i]);
- String data = lines[i];
- events1.add(data);
- }
- eventLog1.setText(join((String[])events1.toArray(new String[events1.size()]), '\n'));
- // Scroll down until last event is visible.
- while(eventLog1.scroll(GTextField.SCROLL_DOWN));
- }
- if (button == eventLog1up && button.eventType == GButton.CLICKED) {
- eventLog1.scroll(GTextField.SCROLL_UP);
- }
- if (button == eventLog1down && button.eventType == GButton.CLICKED) {
- eventLog1.scroll(GTextField.SCROLL_DOWN);
- }
- }