mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-12 22:36:02 -04:00
terminal automatically detects if a console or dialog terminal is required
This commit is contained in:
parent
652767c865
commit
b7eb5221a3
@ -131,6 +131,13 @@ public class Model implements Iterable<Node>, SyncAccess {
|
||||
return windowPosManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this model runs in the main frame
|
||||
*/
|
||||
public boolean runningInMainFrame() {
|
||||
return getWindowPosManager().getMainFrame() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual step counter.
|
||||
* This counter is incremented by every micro step
|
||||
|
@ -22,7 +22,6 @@ import static de.neemann.digital.core.element.PinInfo.input;
|
||||
* Component which represents a text terminal.
|
||||
*/
|
||||
public class Terminal extends Node implements Element {
|
||||
private static final boolean HIDE_DIALOG = GraphicsEnvironment.isHeadless() || System.getProperty("testdata") != null;
|
||||
|
||||
/**
|
||||
* The terminal description
|
||||
@ -72,10 +71,10 @@ public class Terminal extends Node implements Element {
|
||||
long value = data.getValue();
|
||||
if (value != 0) {
|
||||
if (terminal == null) {
|
||||
if (HIDE_DIALOG) {
|
||||
terminal = new ConsoleTerminal();
|
||||
} else {
|
||||
if (getModel().runningInMainFrame()) {
|
||||
terminal = TerminalDialog.getTerminal(getModel(), attr);
|
||||
} else {
|
||||
terminal = new ConsoleTerminal();
|
||||
}
|
||||
}
|
||||
terminal.addChar((char) value);
|
||||
@ -89,9 +88,9 @@ public class Terminal extends Node implements Element {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the terminal dialog
|
||||
* @return the terminal interface
|
||||
*/
|
||||
public TerminalInterface getTerminalDialog() {
|
||||
public TerminalInterface getTerminalInterface() {
|
||||
return terminal;
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ public class TestInGUI extends TestCase {
|
||||
List<Terminal> n = main.getModel().findNode(Terminal.class);
|
||||
assertEquals(1, n.size());
|
||||
Terminal t = n.get(0);
|
||||
assertEquals("\nHello World!", t.getTerminalDialog().getText());
|
||||
assertEquals("\nHello World!", t.getTerminalInterface().getText());
|
||||
}))
|
||||
.execute();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user