-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added console, maintaining compatibility with Pand, code cleanup and …
…fixes.
- Loading branch information
Showing
7 changed files
with
131 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.panda_lang.lily.ui; | ||
|
||
import javafx.scene.control.TextArea; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.scene.layout.Region; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.PrintStream; | ||
|
||
public class ConsolePane extends BorderPane { | ||
|
||
private static ConsolePane instance; | ||
private final ConsoleOutputStream consoleOutputStream; | ||
private final TextArea textArea; | ||
|
||
protected ConsolePane() { | ||
this.textArea = new TextArea(); | ||
this.consoleOutputStream = new ConsoleOutputStream(this); | ||
|
||
instance = this; | ||
setCenter(textArea); | ||
System.setOut(new PrintStream(consoleOutputStream)); | ||
} | ||
|
||
public void bind(Region parent) { | ||
prefWidthProperty().bind(parent.prefWidthProperty()); | ||
prefHeightProperty().bind(parent.prefHeightProperty()); | ||
} | ||
|
||
public void clear() { | ||
textArea.setText(""); | ||
} | ||
|
||
public void write(char c) { | ||
textArea.setText(textArea.getText() + c); | ||
} | ||
|
||
public TextArea getTextArea() { | ||
return textArea; | ||
} | ||
|
||
public ConsoleOutputStream getConsoleOutputStream() { | ||
return consoleOutputStream; | ||
} | ||
|
||
public static ConsolePane getInstance() { | ||
return instance == null ? new ConsolePane() : instance; | ||
} | ||
|
||
private class ConsoleOutputStream extends OutputStream { | ||
|
||
private final ConsolePane consolePane; | ||
|
||
public ConsoleOutputStream(ConsolePane consolePane) { | ||
this.consolePane = consolePane; | ||
} | ||
|
||
@Override | ||
public void write(int b) throws IOException { | ||
consolePane.write((char) b); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters