// Let TWidget set my size.
super.onResize(resize);
+ if (emulator == null) {
+ return;
+ }
+
// Synchronize against the emulator so we don't stomp on its reader
// thread.
synchronized (emulator) {
return;
}
- if (emulator.isReading()) {
+ if ((emulator != null) && (emulator.isReading())) {
// Get out of scrollback
setVerticalValue(0);
emulator.addUserEvent(keypress);
typingHidMouse = false;
}
- // If the emulator is tracking mouse buttons, it needs to see wheel
- // events.
- if (emulator.getMouseProtocol() == ECMA48.MouseProtocol.OFF) {
- if (mouse.isMouseWheelUp()) {
- verticalDecrement();
- dirty = true;
- return;
+ if (emulator != null) {
+ // If the emulator is tracking mouse buttons, it needs to see
+ // wheel events.
+ if (emulator.getMouseProtocol() == ECMA48.MouseProtocol.OFF) {
+ if (mouse.isMouseWheelUp()) {
+ verticalDecrement();
+ dirty = true;
+ return;
+ }
+ if (mouse.isMouseWheelDown()) {
+ verticalIncrement();
+ dirty = true;
+ return;
+ }
}
- if (mouse.isMouseWheelDown()) {
- verticalIncrement();
- dirty = true;
+ if (mouseOnEmulator(mouse)) {
+ emulator.addUserEvent(mouse);
+ readEmulatorState();
return;
}
}
- if (mouseOnEmulator(mouse)) {
- emulator.addUserEvent(mouse);
- readEmulatorState();
- return;
- }
// Emulator didn't consume it, pass it on
super.onMouseDown(mouse);
typingHidMouse = false;
}
- if (mouseOnEmulator(mouse)) {
+ if ((emulator != null) && (mouseOnEmulator(mouse))) {
emulator.addUserEvent(mouse);
readEmulatorState();
return;
typingHidMouse = false;
}
- if (mouseOnEmulator(mouse)) {
+ if ((emulator != null) && (mouseOnEmulator(mouse))) {
emulator.addUserEvent(mouse);
readEmulatorState();
return;
*/
@Override
public void draw() {
+ if (emulator == null) {
+ return;
+ }
+
int width = getDisplayWidth();
boolean syncEmulator = false;
*/
@Override
public void close() {
- emulator.close();
+ if (emulator != null) {
+ emulator.close();
+ }
if (shell != null) {
terminateShellChildProcess();
shell.destroy();
*/
@Override
public void reflowData() {
+ if (emulator == null) {
+ return;
+ }
// Synchronize against the emulator so we don't stomp on its reader
// thread.
* cursor drawn over it
*/
public boolean hasHiddenMouse() {
+ if (emulator == null) {
+ return false;
+ }
return (emulator.hasHiddenMousePointer() || typingHidMouse);
}
* side
*/
public boolean isReading() {
+ if (emulator == null) {
+ return false;
+ }
return emulator.isReading();
}
* screen.
*/
private void readEmulatorState() {
+ if (emulator == null) {
+ return;
+ }
+
// Synchronize against the emulator so we don't stomp on its reader
// thread.
synchronized (emulator) {
* @return whether or not the mouse is on the emulator
*/
private boolean mouseOnEmulator(final TMouseEvent mouse) {
+ if (emulator == null) {
+ return false;
+ }
if (!emulator.isReading()) {
return false;
*/
@Override
public void draw() {
- setTitle(terminal.getTitle());
+ if (terminal != null) {
+ setTitle(terminal.getTitle());
+ }
reflowData();
super.draw();
}
@Override
public void onResize(final TResizeEvent resize) {
if (resize.getType() == TResizeEvent.Type.WIDGET) {
- terminal.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
- getWidth() - 2, getHeight() - 2));
+ if (terminal != null) {
+ terminal.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+ getWidth() - 2, getHeight() - 2));
+ }
// Resize the scroll bars
reflowData();
@Override
public void reflowData() {
// Vertical scrollbar
- terminal.reflowData();
- setTopValue(terminal.getTopValue());
- setBottomValue(terminal.getBottomValue());
- setVerticalBigChange(terminal.getVerticalBigChange());
- setVerticalValue(terminal.getVerticalValue());
+ if (terminal != null) {
+ terminal.reflowData();
+ setTopValue(terminal.getTopValue());
+ setBottomValue(terminal.getBottomValue());
+ setVerticalBigChange(terminal.getVerticalBigChange());
+ setVerticalValue(terminal.getVerticalValue());
+ }
}
/**
*/
@Override
public void onKeypress(final TKeypressEvent keypress) {
- if (terminal.isReading()) {
+ if ((terminal != null) && (terminal.isReading())) {
terminal.onKeypress(keypress);
} else {
super.onKeypress(keypress);
if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) {
// Clicked on vertical scrollbar
- terminal.setVerticalValue(getVerticalValue());
+ if (terminal != null) {
+ terminal.setVerticalValue(getVerticalValue());
+ }
}
}
if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) {
// Clicked/dragged on vertical scrollbar
- terminal.setVerticalValue(getVerticalValue());
+ if (terminal != null) {
+ terminal.setVerticalValue(getVerticalValue());
+ }
}
}
*/
@Override
public boolean hasHiddenMouse() {
- return terminal.hasHiddenMouse();
+ if (terminal != null) {
+ return terminal.hasHiddenMouse();
+ }
+ return false;
}
/**