target="1.6"
source="1.6"
>
+ <compilerarg value="-Xlint"/>
+ <compilerarg value="-Xdiags:verbose"/>
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>
} // synchronized (emulator)
}
+ /**
+ * Wait for a period of time to get output from the launched process.
+ *
+ * @param millis millis to wait for, or 0 to wait forever
+ * @return true if the launched process has emitted something
+ */
+ public boolean waitForOutput(final int millis) {
+ if (emulator == null) {
+ return false;
+ }
+ return emulator.waitForOutput(millis);
+ }
+
/**
* Check if a mouse press/release/motion event coordinate is over the
* emulator.
newStatusBar(i18n.getString("statusBarRunning"));
// Spin it up
- terminal = new TTerminalWidget(this, 0, 0, new TAction() {
+ terminal = new TTerminalWidget(this, 0, 0, command, new TAction() {
public void DO() {
onShellExit();
}
getApplication().postEvent(new TMenuEvent(TMenu.MID_REPAINT));
}
+ /**
+ * Wait for a period of time to get output from the launched process.
+ *
+ * @param millis millis to wait for, or 0 to wait forever
+ * @return true if the launched process has emitted something
+ */
+ public boolean waitForOutput(final int millis) {
+ if (terminal == null) {
+ return false;
+ }
+ return terminal.waitForOutput(millis);
+ }
+
}
int B = 23;
int hash = A;
hash = (B * hash) + super.hashCode();
- hash = (B * hash) + (int)ch;
+ hash = (B * hash) + ch;
hash = (B * hash) + width.hashCode();
if (image != null) {
/*
* @return color associated with name, e.g. bold yellow on blue
*/
public CellAttributes getColor(final String name) {
- CellAttributes attr = (CellAttributes) colors.get(name);
+ CellAttributes attr = colors.get(name);
return attr;
}
*/
private ArrayList<TInputEvent> userQueue = new ArrayList<TInputEvent>();
+ /**
+ * Number of bytes/characters passed to consume().
+ */
+ private long readCount = 0;
+
/**
* DECSC/DECRC save/restore a subset of the total state. This class
* encapsulates those specific flags/modes.
// ECMA48 -----------------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * Wait for a period of time to get output from the launched process.
+ *
+ * @param millis millis to wait for, or 0 to wait forever
+ * @return true if the launched process has emitted something
+ */
+ public boolean waitForOutput(final int millis) {
+ if (millis < 0) {
+ throw new IllegalArgumentException("timeout must be >= 0");
+ }
+ int waitedMillis = millis;
+ final int pollTimeout = 5;
+ while (true) {
+ if (readCount != 0) {
+ return true;
+ }
+ if ((millis > 0) && (waitedMillis < 0)){
+ return false;
+ }
+ try {
+ Thread.sleep(pollTimeout);
+ } catch (InterruptedException e) {
+ // SQUASH
+ }
+ waitedMillis -= pollTimeout;
+ }
+ }
+
/**
* Process keyboard and mouse events from the user.
*
* @param ch character from the remote side
*/
private void consume(final int ch) {
+ readCount++;
// DEBUG
// System.err.printf("%c STATE = %s\n", ch, scanState);
case REPEAT:
if ((ch >= '0') && (ch <= '9')) {
if (repeatCount == -1) {
- repeatCount = (int) (ch - '0');
+ repeatCount = (ch - '0');
} else {
repeatCount *= 10;
- repeatCount += (int) (ch - '0');
+ repeatCount += (ch - '0');
}
}
return;