-/**
+/*
* Jexer - Java Text User Interface
*
- * License: LGPLv3 or later
- *
- * This module is licensed under the GNU Lesser General Public License
- * Version 3. Please see the file "COPYING" in this directory for more
- * information about the GNU Lesser General Public License Version 3.
+ * The MIT License (MIT)
*
- * Copyright (C) 2015 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see
- * http://www.gnu.org/licenses/, or write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*
* @author Kevin Lamonte [kevin.lamonte@gmail.com]
* @version 1
*/
package jexer;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.ResourceBundle;
-import jexer.bits.Cell;
-import jexer.bits.CellAttributes;
+import jexer.menu.TMenu;
import jexer.event.TKeypressEvent;
+import jexer.event.TMenuEvent;
import jexer.event.TMouseEvent;
import jexer.event.TResizeEvent;
-import jexer.tterminal.DisplayLine;
-import jexer.tterminal.ECMA48;
import static jexer.TKeypress.*;
/**
* TTerminalWindow exposes a ECMA-48 / ANSI X3.64 style terminal in a window.
*/
-public class TTerminalWindow extends TWindow {
+public class TTerminalWindow extends TScrollableWindow {
/**
- * The emulator.
+ * Translated strings.
*/
- private ECMA48 emulator;
+ private static final ResourceBundle i18n = ResourceBundle.getBundle(TTerminalWindow.class.getName());
+
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
- * The Process created by the shell spawning constructor.
+ * The terminal.
*/
- private Process shell;
+ private TTerminalWidget terminal;
/**
- * Vertical scrollbar.
+ * If true, close the window when the shell exits.
*/
- private TVScroller vScroller;
+ private boolean closeOnExit = false;
+
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
- * Public constructor spawns a shell.
+ * Public constructor spawns a custom command line.
*
* @param application TApplication that manages this window
* @param x column relative to parent
* @param y row relative to parent
- * @param flags mask of CENTERED, MODAL, or RESIZABLE
+ * @param commandLine the command line to execute
*/
public TTerminalWindow(final TApplication application, final int x,
- final int y, final int flags) {
-
- super(application, "Terminal", x, y, 80 + 2, 24 + 2, flags);
-
- // Assume XTERM
- ECMA48.DeviceType deviceType = ECMA48.DeviceType.XTERM;
-
- try {
- String [] cmdShellWindows = {
- "cmd.exe"
- };
-
- // You cannot run a login shell in a bare Process interactively,
- // due to libc's behavior of buffering when stdin/stdout aren't a
- // tty. Use 'script' instead to run a shell in a pty.
- String [] cmdShell = {
- "script", "-fqe", "/dev/null"
- };
- // Spawn a shell and pass its I/O to the other constructor.
-
- ProcessBuilder pb;
- if (System.getProperty("os.name").startsWith("Windows")) {
- pb = new ProcessBuilder(cmdShellWindows);
- } else {
- pb = new ProcessBuilder(cmdShell);
- }
- Map<String, String> env = pb.environment();
- env.put("TERM", ECMA48.deviceTypeTerm(deviceType));
- env.put("LANG", ECMA48.deviceTypeLang(deviceType, "en"));
- env.put("COLUMNS", "80");
- env.put("LINES", "24");
- pb.redirectErrorStream(true);
- shell = pb.start();
- emulator = new ECMA48(deviceType, shell.getInputStream(),
- shell.getOutputStream());
- } catch (IOException e) {
- e.printStackTrace();
- }
+ final int y, final String commandLine) {
- // Setup the scroll bars
- onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(),
- getHeight()));
+ this(application, x, y, RESIZABLE, commandLine.split("\\s+"),
+ System.getProperty("jexer.TTerminal.closeOnExit",
+ "false").equals("true"));
}
/**
- * Public constructor.
+ * Public constructor spawns a custom command line.
*
* @param application TApplication that manages this window
* @param x column relative to parent
* @param y row relative to parent
- * @param flags mask of CENTERED, MODAL, or RESIZABLE
- * @param input an InputStream connected to the remote side. For type ==
- * XTERM, input is converted to a Reader with UTF-8 encoding.
- * @param output an OutputStream connected to the remote user. For type
- * == XTERM, output is converted to a Writer with UTF-8 encoding.
- * @throws UnsupportedEncodingException if an exception is thrown when
- * creating the InputStreamReader
+ * @param commandLine the command line to execute
+ * @param closeOnExit if true, close the window when the command exits
*/
public TTerminalWindow(final TApplication application, final int x,
- final int y, final int flags, final InputStream input,
- final OutputStream output) throws UnsupportedEncodingException {
-
- super(application, "Terminal", x, y, 80 + 2, 24 + 2, flags);
-
- emulator = new ECMA48(ECMA48.DeviceType.XTERM, input, output);
-
- // Setup the scroll bars
- onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(),
- getHeight()));
+ final int y, final String commandLine, final boolean closeOnExit) {
+ this(application, x, y, RESIZABLE, commandLine.split("\\s+"),
+ closeOnExit);
}
/**
- * Draw the display buffer.
+ * Public constructor spawns a custom command line.
+ *
+ * @param application TApplication that manages this window
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param flags mask of CENTERED, MODAL, or RESIZABLE
+ * @param command the command line to execute
*/
- @Override
- public void draw() {
- // Synchronize against the emulator so we don't stomp on its reader
- // thread.
- synchronized (emulator) {
-
- // Update the scroll bars
- reflow();
-
- // Draw the box using my superclass
- super.draw();
-
- List<DisplayLine> scrollback = emulator.getScrollbackBuffer();
- List<DisplayLine> display = emulator.getDisplayBuffer();
-
- // Put together the visible rows
- int visibleHeight = getHeight() - 2;
- int visibleBottom = scrollback.size() + display.size()
- + vScroller.getValue();
- assert (visibleBottom >= 0);
-
- List<DisplayLine> preceedingBlankLines = new LinkedList<DisplayLine>();
- int visibleTop = visibleBottom - visibleHeight;
- if (visibleTop < 0) {
- for (int i = visibleTop; i < 0; i++) {
- preceedingBlankLines.add(emulator.getBlankDisplayLine());
- }
- visibleTop = 0;
- }
- assert (visibleTop >= 0);
-
- List<DisplayLine> displayLines = new LinkedList<DisplayLine>();
- displayLines.addAll(scrollback);
- displayLines.addAll(display);
-
- List<DisplayLine> visibleLines = new LinkedList<DisplayLine>();
- visibleLines.addAll(preceedingBlankLines);
- visibleLines.addAll(displayLines.subList(visibleTop,
- visibleBottom));
-
- visibleHeight -= visibleLines.size();
- assert (visibleHeight >= 0);
-
- // Now draw the emulator screen
- int row = 1;
- for (DisplayLine line: visibleLines) {
- int widthMax = emulator.getWidth();
- if (line.isDoubleWidth()) {
- widthMax /= 2;
- }
- if (widthMax > getWidth() - 2) {
- widthMax = getWidth() - 2;
- }
- for (int i = 0; i < widthMax; i++) {
- Cell ch = line.charAt(i);
- Cell newCell = new Cell();
- newCell.setTo(ch);
- boolean reverse = line.isReverseColor() ^ ch.getReverse();
- newCell.setReverse(false);
- if (reverse) {
- newCell.setBackColor(ch.getForeColor());
- newCell.setForeColor(ch.getBackColor());
- }
- if (line.isDoubleWidth()) {
- getScreen().putCharXY((i * 2) + 1, row, newCell);
- getScreen().putCharXY((i * 2) + 2, row, ' ', newCell);
- } else {
- getScreen().putCharXY(i + 1, row, newCell);
- }
- }
- row++;
- if (row == getHeight() - 1) {
- // Don't overwrite the box edge
- break;
- }
- }
- CellAttributes background = new CellAttributes();
- // Fill in the blank lines on bottom
- for (int i = 0; i < visibleHeight; i++) {
- getScreen().hLineXY(1, i + row, getWidth() - 2, ' ',
- background);
- }
-
- } // synchronized (emulator)
+ public TTerminalWindow(final TApplication application, final int x,
+ final int y, final int flags, final String [] command) {
+ this(application, x, y, flags, command,
+ System.getProperty("jexer.TTerminal.closeOnExit",
+ "false").equals("true"));
}
/**
- * Handle window close.
+ * Public constructor spawns a custom command line.
+ *
+ * @param application TApplication that manages this window
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param flags mask of CENTERED, MODAL, or RESIZABLE
+ * @param command the command line to execute
+ * @param closeOnExit if true, close the window when the command exits
*/
- @Override public void onClose() {
- emulator.close();
+ public TTerminalWindow(final TApplication application, final int x,
+ final int y, final int flags, final String [] command,
+ final boolean closeOnExit) {
+
+ super(application, i18n.getString("windowTitle"), x, y,
+ 80 + 2, 24 + 2, flags);
+
+ // Require at least one line for the display.
+ setMinimumWindowHeight(3);
+
+ this.closeOnExit = closeOnExit;
+ vScroller = new TVScroller(this, getWidth() - 2, 0, getHeight() - 2);
+
+ // Claim the keystrokes the emulator will need.
+ addShortcutKeys();
+
+ // Add shortcut text
+ newStatusBar(i18n.getString("statusBarRunning"));
+
+ // Spin it up
+ terminal = new TTerminalWidget(this, 0, 0, command, new TAction() {
+ public void DO() {
+ onShellExit();
+ }
+ });
}
/**
- * Copy out variables from the emulator that TTerminal has to expose on
- * screen.
+ * Public constructor spawns a shell.
+ *
+ * @param application TApplication that manages this window
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param flags mask of CENTERED, MODAL, or RESIZABLE
*/
- private void readEmulatorState() {
- // Synchronize against the emulator so we don't stomp on its reader
- // thread.
- synchronized (emulator) {
-
- setCursorX(emulator.getCursorX() + 1);
- setCursorY(emulator.getCursorY() + 1
- + (getHeight() - 2 - emulator.getHeight()));
- if (vScroller != null) {
- setCursorY(getCursorY() - vScroller.getValue());
- }
- setHasCursor(emulator.visibleCursor());
- if (getCursorX() > getWidth() - 2) {
- setHasCursor(false);
- }
- if ((getCursorY() > getHeight() - 2) || (getCursorY() < 0)) {
- setHasCursor(false);
- }
- if (emulator.getScreenTitle().length() > 0) {
- // Only update the title if the shell is still alive
- if (shell != null) {
- setTitle(emulator.getScreenTitle());
- }
- }
+ public TTerminalWindow(final TApplication application, final int x,
+ final int y, final int flags) {
- // Check to see if the shell has died.
- if (!emulator.isReading() && (shell != null)) {
- // The emulator exited on its own, all is fine
- setTitle(String.format("%s [Completed - %d]",
- getTitle(), shell.exitValue()));
- shell = null;
- emulator.close();
- } else if (emulator.isReading() && (shell != null)) {
- // The shell might be dead, let's check
- try {
- int rc = shell.exitValue();
- // If we got here, the shell died.
- setTitle(String.format("%s [Completed - %d]",
- getTitle(), rc));
- shell = null;
- emulator.close();
- } catch (IllegalThreadStateException e) {
- // The shell is still running, do nothing.
- }
- }
+ this(application, x, y, flags,
+ System.getProperty("jexer.TTerminal.closeOnExit",
+ "false").equals("true"));
- } // synchronized (emulator)
}
/**
- * Handle window/screen resize events.
+ * Public constructor spawns a shell.
*
- * @param resize resize event
+ * @param application TApplication that manages this window
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param flags mask of CENTERED, MODAL, or RESIZABLE
+ * @param closeOnExit if true, close the window when the shell exits
*/
- @Override
- public void onResize(final TResizeEvent resize) {
+ public TTerminalWindow(final TApplication application, final int x,
+ final int y, final int flags, final boolean closeOnExit) {
- // Synchronize against the emulator so we don't stomp on its reader
- // thread.
- synchronized (emulator) {
+ super(application, i18n.getString("windowTitle"), x, y,
+ 80 + 2, 24 + 2, flags);
- if (resize.getType() == TResizeEvent.Type.WIDGET) {
- // Resize the scroll bars
- reflow();
+ // Require at least one line for the display.
+ setMinimumWindowHeight(3);
- // Get out of scrollback
- vScroller.setValue(0);
- }
- return;
+ this.closeOnExit = closeOnExit;
+ vScroller = new TVScroller(this, getWidth() - 2, 0, getHeight() - 2);
+
+ // Claim the keystrokes the emulator will need.
+ addShortcutKeys();
- } // synchronized (emulator)
+ // Add shortcut text
+ newStatusBar(i18n.getString("statusBarRunning"));
+
+ // Spin it up
+ terminal = new TTerminalWidget(this, 0, 0, new TAction() {
+ public void DO() {
+ onShellExit();
+ }
+ });
}
+ // ------------------------------------------------------------------------
+ // TScrollableWindow ------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
- * Resize scrollbars for a new width/height.
+ * Draw the display buffer.
*/
- private void reflow() {
-
- // Synchronize against the emulator so we don't stomp on its reader
- // thread.
- synchronized (emulator) {
-
- // Pull cursor information
- readEmulatorState();
-
- // Vertical scrollbar
- if (vScroller == null) {
- vScroller = new TVScroller(this, getWidth() - 2, 0,
- getHeight() - 2);
- vScroller.setBottomValue(0);
- vScroller.setValue(0);
- } else {
- vScroller.setX(getWidth() - 2);
- vScroller.setHeight(getHeight() - 2);
- }
- vScroller.setTopValue(getHeight() - 2
- - (emulator.getScrollbackBuffer().size()
- + emulator.getDisplayBuffer().size()));
- vScroller.setBigChange(getHeight() - 2);
-
- } // synchronized (emulator)
+ @Override
+ public void draw() {
+ if (terminal != null) {
+ setTitle(terminal.getTitle());
+ }
+ reflowData();
+ super.draw();
}
/**
- * Check if a mouse press/release/motion event coordinate is over the
- * emulator.
+ * Handle window/screen resize events.
*
- * @param mouse a mouse-based event
- * @return whether or not the mouse is on the emulator
+ * @param resize resize event
*/
- private final boolean mouseOnEmulator(final TMouseEvent mouse) {
-
- synchronized (emulator) {
- if (!emulator.isReading()) {
- return false;
+ @Override
+ public void onResize(final TResizeEvent resize) {
+ if (resize.getType() == TResizeEvent.Type.WIDGET) {
+ if (terminal != null) {
+ terminal.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+ getWidth() - 2, getHeight() - 2));
}
+
+ // Resize the scroll bars
+ reflowData();
+ placeScrollbars();
}
+ return;
+ }
- if ((mouse.getAbsoluteX() >= getAbsoluteX() + 1)
- && (mouse.getAbsoluteX() < getAbsoluteX() + getWidth() - 1)
- && (mouse.getAbsoluteY() >= getAbsoluteY() + 1)
- && (mouse.getAbsoluteY() < getAbsoluteY() + getHeight() - 1)
- ) {
- return true;
+ /**
+ * Resize scrollbars for a new width/height.
+ */
+ @Override
+ public void reflowData() {
+ // Vertical scrollbar
+ if (terminal != null) {
+ terminal.reflowData();
+ setTopValue(terminal.getTopValue());
+ setBottomValue(terminal.getBottomValue());
+ setVerticalBigChange(terminal.getVerticalBigChange());
+ setVerticalValue(terminal.getVerticalValue());
}
- return false;
}
/**
*/
@Override
public void onKeypress(final TKeypressEvent keypress) {
-
- // Scrollback up/down
- if (keypress.equals(kbShiftPgUp)
- || keypress.equals(kbCtrlPgUp)
- || keypress.equals(kbAltPgUp)
- ) {
- vScroller.bigDecrement();
- return;
+ if ((terminal != null) && (terminal.isReading())) {
+ terminal.onKeypress(keypress);
+ } else {
+ super.onKeypress(keypress);
}
- if (keypress.equals(kbShiftPgDn)
- || keypress.equals(kbCtrlPgDn)
- || keypress.equals(kbAltPgDn)
- ) {
- vScroller.bigIncrement();
- return;
- }
-
- // Synchronize against the emulator so we don't stomp on its reader
- // thread.
- synchronized (emulator) {
- if (emulator.isReading()) {
- // Get out of scrollback
- vScroller.setValue(0);
- emulator.keypress(keypress.getKey());
-
- // UGLY HACK TIME! cmd.exe needs CRLF, not just CR, so if
- // this is kBEnter then also send kbCtrlJ.
- if (System.getProperty("os.name").startsWith("Windows")) {
- if (keypress.equals(kbEnter)) {
- emulator.keypress(kbCtrlJ);
- }
- }
-
- readEmulatorState();
- return;
- }
- }
-
- // Process is closed, honor "normal" TUI keystrokes
- super.onKeypress(keypress);
}
/**
return;
}
- if (mouse.getMouseWheelUp()) {
- vScroller.decrement();
- return;
- }
- if (mouse.getMouseWheelDown()) {
- vScroller.increment();
- return;
- }
- if (mouseOnEmulator(mouse)) {
- synchronized (emulator) {
- mouse.setX(mouse.getX() - 1);
- mouse.setY(mouse.getY() - 1);
- emulator.mouse(mouse);
- readEmulatorState();
- return;
- }
- }
-
- // Emulator didn't consume it, pass it on
super.onMouseDown(mouse);
}
return;
}
- if (mouseOnEmulator(mouse)) {
- synchronized (emulator) {
- mouse.setX(mouse.getX() - 1);
- mouse.setY(mouse.getY() - 1);
- emulator.mouse(mouse);
- readEmulatorState();
- return;
+ super.onMouseUp(mouse);
+
+ if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) {
+ // Clicked on vertical scrollbar
+ if (terminal != null) {
+ terminal.setVerticalValue(getVerticalValue());
}
}
-
- // Emulator didn't consume it, pass it on
- super.onMouseUp(mouse);
}
/**
return;
}
- if (mouseOnEmulator(mouse)) {
- synchronized (emulator) {
- mouse.setX(mouse.getX() - 1);
- mouse.setY(mouse.getY() - 1);
- emulator.mouse(mouse);
- readEmulatorState();
- return;
+ super.onMouseMotion(mouse);
+
+ if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) {
+ // Clicked/dragged on vertical scrollbar
+ if (terminal != null) {
+ terminal.setVerticalValue(getVerticalValue());
}
}
+ }
- // Emulator didn't consume it, pass it on
- super.onMouseMotion(mouse);
+ // ------------------------------------------------------------------------
+ // TTerminalWindow --------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns true if this window does not want the application-wide mouse
+ * cursor drawn over it.
+ *
+ * @return true if this window does not want the application-wide mouse
+ * cursor drawn over it
+ */
+ @Override
+ public boolean hasHiddenMouse() {
+ if (terminal != null) {
+ return terminal.hasHiddenMouse();
+ }
+ return false;
+ }
+
+ /**
+ * Claim the keystrokes the emulator will need.
+ */
+ private void addShortcutKeys() {
+ addShortcutKeypress(kbCtrlA);
+ addShortcutKeypress(kbCtrlB);
+ addShortcutKeypress(kbCtrlC);
+ addShortcutKeypress(kbCtrlD);
+ addShortcutKeypress(kbCtrlE);
+ addShortcutKeypress(kbCtrlF);
+ addShortcutKeypress(kbCtrlG);
+ addShortcutKeypress(kbCtrlH);
+ addShortcutKeypress(kbCtrlU);
+ addShortcutKeypress(kbCtrlJ);
+ addShortcutKeypress(kbCtrlK);
+ addShortcutKeypress(kbCtrlL);
+ addShortcutKeypress(kbCtrlM);
+ addShortcutKeypress(kbCtrlN);
+ addShortcutKeypress(kbCtrlO);
+ addShortcutKeypress(kbCtrlP);
+ addShortcutKeypress(kbCtrlQ);
+ addShortcutKeypress(kbCtrlR);
+ addShortcutKeypress(kbCtrlS);
+ addShortcutKeypress(kbCtrlT);
+ addShortcutKeypress(kbCtrlU);
+ addShortcutKeypress(kbCtrlV);
+ addShortcutKeypress(kbCtrlW);
+ addShortcutKeypress(kbCtrlX);
+ addShortcutKeypress(kbCtrlY);
+ addShortcutKeypress(kbCtrlZ);
+ addShortcutKeypress(kbF1);
+ addShortcutKeypress(kbF2);
+ addShortcutKeypress(kbF3);
+ addShortcutKeypress(kbF4);
+ addShortcutKeypress(kbF5);
+ addShortcutKeypress(kbF6);
+ addShortcutKeypress(kbF7);
+ addShortcutKeypress(kbF8);
+ addShortcutKeypress(kbF9);
+ addShortcutKeypress(kbF10);
+ addShortcutKeypress(kbF11);
+ addShortcutKeypress(kbF12);
+ addShortcutKeypress(kbAltA);
+ addShortcutKeypress(kbAltB);
+ addShortcutKeypress(kbAltC);
+ addShortcutKeypress(kbAltD);
+ addShortcutKeypress(kbAltE);
+ addShortcutKeypress(kbAltF);
+ addShortcutKeypress(kbAltG);
+ addShortcutKeypress(kbAltH);
+ addShortcutKeypress(kbAltU);
+ addShortcutKeypress(kbAltJ);
+ addShortcutKeypress(kbAltK);
+ addShortcutKeypress(kbAltL);
+ addShortcutKeypress(kbAltM);
+ addShortcutKeypress(kbAltN);
+ addShortcutKeypress(kbAltO);
+ addShortcutKeypress(kbAltP);
+ addShortcutKeypress(kbAltQ);
+ addShortcutKeypress(kbAltR);
+ addShortcutKeypress(kbAltS);
+ addShortcutKeypress(kbAltT);
+ addShortcutKeypress(kbAltU);
+ addShortcutKeypress(kbAltV);
+ addShortcutKeypress(kbAltW);
+ addShortcutKeypress(kbAltX);
+ addShortcutKeypress(kbAltY);
+ addShortcutKeypress(kbAltZ);
+ }
+
+ /**
+ * Hook for subclasses to be notified of the shell termination.
+ */
+ public void onShellExit() {
+ if (closeOnExit) {
+ close();
+ }
+ clearShortcutKeypresses();
+ 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);
+ }
+
+ /**
+ * Get the exit value for the emulator.
+ *
+ * @return exit value
+ */
+ public int getExitValue() {
+ if (terminal == null) {
+ return -1;
+ }
+ return terminal.getExitValue();
}
}