From: Kevin Lamonte Date: Sun, 10 Nov 2019 23:10:54 +0000 (-0600) Subject: lint X-Git-Tag: fanfix-swing-0.0.1~12^2~13^2^2~16 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=5ca5f8e5310b189232ed337643f3b7b2ce6cd3b1;p=fanfix-swing.git lint --- diff --git a/build.xml b/build.xml index 327793a4..2e861676 100644 --- a/build.xml +++ b/build.xml @@ -52,6 +52,8 @@ target="1.6" source="1.6" > + + diff --git a/src/jexer/TTerminalWidget.java b/src/jexer/TTerminalWidget.java index acd1cc27..f488320c 100644 --- a/src/jexer/TTerminalWidget.java +++ b/src/jexer/TTerminalWidget.java @@ -999,6 +999,19 @@ public class TTerminalWidget extends TScrollableWidget } // 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. diff --git a/src/jexer/TTerminalWindow.java b/src/jexer/TTerminalWindow.java index e96c50c9..bb3e14a9 100644 --- a/src/jexer/TTerminalWindow.java +++ b/src/jexer/TTerminalWindow.java @@ -166,7 +166,7 @@ public class TTerminalWindow extends TScrollableWindow { 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(); } @@ -452,4 +452,17 @@ public class TTerminalWindow extends TScrollableWindow { 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); + } + } diff --git a/src/jexer/bits/Cell.java b/src/jexer/bits/Cell.java index a8efa2b3..ed3c202a 100644 --- a/src/jexer/bits/Cell.java +++ b/src/jexer/bits/Cell.java @@ -419,7 +419,7 @@ public final class Cell extends CellAttributes { 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) { /* diff --git a/src/jexer/teditor/Highlighter.java b/src/jexer/teditor/Highlighter.java index a4841945..44a2ed08 100644 --- a/src/jexer/teditor/Highlighter.java +++ b/src/jexer/teditor/Highlighter.java @@ -87,7 +87,7 @@ public class Highlighter { * @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; } diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index 369eca93..c6aa0b21 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -506,6 +506,11 @@ public class ECMA48 implements Runnable { */ private ArrayList userQueue = new ArrayList(); + /** + * 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. @@ -854,6 +859,34 @@ public class ECMA48 implements Runnable { // 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. * @@ -4971,6 +5004,7 @@ public class ECMA48 implements Runnable { * @param ch character from the remote side */ private void consume(final int ch) { + readCount++; // DEBUG // System.err.printf("%c STATE = %s\n", ch, scanState); diff --git a/src/jexer/tterminal/Sixel.java b/src/jexer/tterminal/Sixel.java index a4c00fc6..5768a0f0 100644 --- a/src/jexer/tterminal/Sixel.java +++ b/src/jexer/tterminal/Sixel.java @@ -574,10 +574,10 @@ public class Sixel { 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;