import java.util.LinkedList;
import jexer.TKeypress;
-import jexer.bits.Color;
import jexer.event.TCommandEvent;
import jexer.event.TInputEvent;
import jexer.event.TKeypressEvent;
return sessionInfo;
}
+ /**
+ * The listening object that run() wakes up on new input.
+ */
+ private Object listener;
+
/**
* The event queue, filled up by a thread reading on input.
*/
/**
* Constructor sets up state for getEvent().
*
+ * @param listener the object this backend needs to wake up when new
+ * input comes in
* @param screen the top-level AWT frame
*/
- public AWTTerminal(final AWTScreen screen) {
+ public AWTTerminal(final Object listener, final AWTScreen screen) {
+ this.listener = listener;
this.screen = screen;
mouse1 = false;
mouse2 = false;
}
}
- /**
- * Return any events in the IO queue due to timeout.
- *
- * @param queue list to append new events to
- */
- public void getIdleEvents(final List<TInputEvent> queue) {
-
- // Insert any polling action here...
-
- // Return any events that showed up
- synchronized (eventQueue) {
- if (eventQueue.size() > 0) {
- synchronized (queue) {
- queue.addAll(eventQueue);
- }
- eventQueue.clear();
- }
- }
- }
-
/**
* Pass AWT keystrokes into the event queue.
*
System.err.printf(" ctrl: %s\n", ctrl);
System.err.printf(" shift: %s\n", shift);
System.err.printf(" ch: %s\n", ch);
- */
+ */
// Special case: not return the bare modifier presses
switch (key.getKeyCode()) {
case 0x0A:
keypress = kbEnter;
break;
+ case 0x1B:
+ keypress = kbEsc;
+ break;
case 0x0D:
keypress = kbEnter;
break;
+ case 0x09:
+ keypress = kbTab;
+ break;
case 0x7F:
keypress = kbDel;
break;
synchronized (eventQueue) {
eventQueue.add(new TKeypressEvent(keypress));
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
*/
@Override
public void windowActivated(final WindowEvent event) {
- // Ignore
+ // Force a total repaint
+ synchronized (screen) {
+ screen.clearPhysical();
+ }
}
/**
synchronized (eventQueue) {
eventQueue.add(new TCommandEvent(cmAbort));
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight());
eventQueue.add(windowResize);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
mouse1 = eventMouse1;
mouse2 = eventMouse2;
mouse3 = eventMouse3;
- int x = sessionInfo.textColumn(mouse.getX());
- int y = sessionInfo.textRow(mouse.getY());
+ int x = screen.textColumn(mouse.getX());
+ int y = screen.textRow(mouse.getY());
TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_MOTION,
x, y, x, y, mouse1, mouse2, mouse3, false, false);
synchronized (eventQueue) {
eventQueue.add(mouseEvent);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
*/
@Override
public void mouseMoved(final MouseEvent mouse) {
- int x = sessionInfo.textColumn(mouse.getX());
- int y = sessionInfo.textRow(mouse.getY());
+ int x = screen.textColumn(mouse.getX());
+ int y = screen.textRow(mouse.getY());
TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_MOTION,
x, y, x, y, mouse1, mouse2, mouse3, false, false);
synchronized (eventQueue) {
eventQueue.add(mouseEvent);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
mouse1 = eventMouse1;
mouse2 = eventMouse2;
mouse3 = eventMouse3;
- int x = sessionInfo.textColumn(mouse.getX());
- int y = sessionInfo.textRow(mouse.getY());
+ int x = screen.textColumn(mouse.getX());
+ int y = screen.textRow(mouse.getY());
TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_DOWN,
x, y, x, y, mouse1, mouse2, mouse3, false, false);
synchronized (eventQueue) {
eventQueue.add(mouseEvent);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
mouse3 = false;
eventMouse3 = true;
}
- int x = sessionInfo.textColumn(mouse.getX());
- int y = sessionInfo.textRow(mouse.getY());
+ int x = screen.textColumn(mouse.getX());
+ int y = screen.textRow(mouse.getY());
TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_UP,
x, y, x, y, eventMouse1, eventMouse2, eventMouse3, false, false);
synchronized (eventQueue) {
eventQueue.add(mouseEvent);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}
mouse1 = eventMouse1;
mouse2 = eventMouse2;
mouse3 = eventMouse3;
- int x = sessionInfo.textColumn(mouse.getX());
- int y = sessionInfo.textRow(mouse.getY());
+ int x = screen.textColumn(mouse.getX());
+ int y = screen.textRow(mouse.getY());
if (mouse.getWheelRotation() > 0) {
mouseWheelDown = true;
}
synchronized (eventQueue) {
eventQueue.add(mouseEvent);
}
- // Wake up the backend
- synchronized (this) {
- this.notifyAll();
+ synchronized (listener) {
+ listener.notifyAll();
}
}