0.0.2:
+- Fix clipping errors
- AWT:
- Blinking cursor
-- Clean up TWidget constuctors (everyone is doing setX() / setY() / set...)
- ECMA48Backend running on socket
- TTreeView
- TDirectoryList
0.0.4:
- Bugs
- - Bare ESC isn't being returned immediately
- TTimer is jittery with I/O
- TSubMenu keyboard mnemonic not working
- - kbDel and use by TMenu (MID_CLEAR)
+ - Making TMenu keyboard accelerators active/inactive
- TDirectoryList cannot be navigated only with keyboard
- TTreeView cannot be navigated only with keyboard
- RangeViolation after dragging scrollbar up/down
*/
private static final boolean debugThreads = false;
+ /**
+ * If true, emit events being processed to System.err.
+ */
+ private static final boolean debugEvents = false;
+
/**
* WidgetEventHandler is the main event consumer loop. There are at most
* two such threads in existence: the primary for normal case and a
*/
private void metaHandleEvent(final TInputEvent event) {
- /*
- System.err.printf(String.format("metaHandleEvents event: %s\n",
- event)); System.err.flush();
- */
+ if (debugEvents) {
+ System.err.printf(String.format("metaHandleEvents event: %s\n",
+ event)); System.err.flush();
+ }
if (quit) {
// Do no more processing if the application is already trying
*/
private void primaryHandleEvent(final TInputEvent event) {
- // System.err.printf("Handle event: %s\n", event);
+ if (debugEvents) {
+ System.err.printf("Handle event: %s\n", event);
+ }
// Special application-wide events -----------------------------------
mouse.setX(mouse.getX() - window.getX());
mouse.setY(mouse.getY() - window.getY());
}
- // System.err("TApplication dispatch event: %s\n", event);
+ if (debugEvents) {
+ System.err.printf("TApplication dispatch event: %s\n",
+ event);
+ }
window.handleEvent(event);
break;
}
final String label, final boolean checked) {
// Set parent and window
- super(parent);
+ super(parent, x, y, label.length() + 4, 1);
- setX(x);
- setY(y);
- setHeight(1);
this.label = label;
- setWidth(label.length() + 4);
this.checked = checked;
setHasCursor(true);
final TAction enterAction, final TAction updateAction) {
// Set parent and window
- super(parent);
- setX(x);
- setY(y);
- setHeight(1);
- setWidth(width);
- setHasCursor(true);
+ super(parent, x, y, width, 1);
+ setHasCursor(true);
this.fixed = fixed;
this.text = text;
this.enterAction = enterAction;
final int width) {
// Set parent and window
- super(parent);
-
- setX(x);
- setY(y);
- setHeight(1);
- setWidth(width);
+ super(parent, x, y, width, 1);
}
/**
final int y, final String colorKey) {
// Set parent and window
- super(parent, false);
+ super(parent, false, x, y, text.length(), 1);
this.text = text;
- setX(x);
- setY(y);
- setHeight(1);
- setWidth(text.length());
this.colorKey = colorKey;
}
final int width, final int value) {
// Set parent and window
- super(parent, false);
+ super(parent, false, x, y, width, 1);
- setX(x);
- setY(y);
- setHeight(1);
- setWidth(width);
this.value = value;
}
final String label, final int id) {
// Set parent and window
- super(parent);
+ super(parent, x, y, label.length() + 4, 1);
- setX(x);
- setY(y);
- setHeight(1);
this.label = label;
- setWidth(label.length() + 4);
this.id = id;
setHasCursor(true);
final String label) {
// Set parent and window
- super(parent);
+ super(parent, x, y, label.length() + 4, 2);
- setX(x);
- setY(y);
- setHeight(2);
this.label = label;
- setWidth(label.length() + 4);
}
/**
final int y, final int width, final int height, final String colorKey) {
// Set parent and window
- super(parent);
+ super(parent, x, y, width, height);
- setX(x);
- setY(y);
- setWidth(width);
- setHeight(height);
this.text = text;
this.colorKey = colorKey;
final int height) {
// Set parent and window
- super(parent);
-
- setX(x);
- setY(y);
- setHeight(height);
- setWidth(1);
+ super(parent, x, y, 1, height);
}
/**
this(parent, true);
}
+ /**
+ * Protected constructor.
+ *
+ * @param parent parent widget
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width width of widget
+ * @param height height of widget
+ */
+ protected TWidget(final TWidget parent, final int x, final int y,
+ final int width, final int height) {
+
+ this(parent, true, x, y, width, height);
+ }
+
/**
* Protected constructor used by subclasses that are disabled by default.
*
parent.addChild(this);
}
+ /**
+ * Protected constructor used by subclasses that are disabled by default.
+ *
+ * @param parent parent widget
+ * @param enabled if true assume enabled
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width width of widget
+ * @param height height of widget
+ */
+ protected TWidget(final TWidget parent, final boolean enabled,
+ final int x, final int y, final int width, final int height) {
+
+ this.enabled = enabled;
+ this.parent = parent;
+ this.window = parent.window;
+ children = new LinkedList<TWidget>();
+ parent.addChild(this);
+
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
/**
* Add a child widget to my list of children. We set its tabOrder to 0
* and increment the tabOrder of all other children.
if ((children.size() == 0)
// TODO
// || (cast(TTreeView)this)
- // || (cast(TText)this)
+ || (this instanceof TText)
) {
// Defaults:
}
}
if (keypress.equals(kbShiftLeft)) {
- if (getWidth() > minimumWindowWidth) {
+ if ((getWidth() > minimumWindowWidth)
+ || (minimumWindowWidth <= 0)
+ ) {
setWidth(getWidth() - 1);
}
}
if (keypress.equals(kbShiftRight)) {
- if (getWidth() < maximumWindowWidth) {
+ if ((getWidth() < maximumWindowWidth)
+ || (maximumWindowWidth <= 0)
+ ) {
setWidth(getWidth() + 1);
}
}
if (keypress.equals(kbShiftUp)) {
- if (getHeight() > minimumWindowHeight) {
+ if ((getHeight() > minimumWindowHeight)
+ || (minimumWindowHeight <= 0)
+ ) {
setHeight(getHeight() - 1);
}
}
if (keypress.equals(kbShiftDown)) {
- if (getHeight() < maximumWindowHeight) {
+ if ((getHeight() < maximumWindowHeight)
+ || (maximumWindowHeight <= 0)
+ ) {
setHeight(getHeight() + 1);
}
}
synchronized (terminal) {
try {
terminal.wait(timeout);
- if (terminal.hasEvents()) {
- // System.err.println("getEvents()");
- terminal.getEvents(queue);
- } else {
- // If I got here, then I timed out. Call
- // terminal.getIdleEvents() to pick up stragglers
- // like bare resize.
- // System.err.println("getIdleEvents()");
- terminal.getIdleEvents(queue);
- }
} catch (InterruptedException e) {
// Spurious interrupt, pretend it was like a timeout.
// System.err.println("[interrupt] getEvents()");
- terminal.getIdleEvents(queue);
+ }
+ if (terminal.hasEvents()) {
+ // System.err.println("getEvents()");
+ terminal.getEvents(queue);
}
}
} else {
*/
private long escapeTime;
+ /**
+ * The time we last checked the window size. We try not to spawn stty
+ * more than once per second.
+ */
+ private long windowSizeTime;
+
/**
* true if mouse1 was down. Used to report mouse1 on the release event.
*/
*
* @param queue list to append new events to
*/
- public void getIdleEvents(final List<TInputEvent> queue) {
+ private void getIdleEvents(final List<TInputEvent> queue) {
+ Date now = new Date();
// Check for new window size
- sessionInfo.queryWindowSize();
- int newWidth = sessionInfo.getWindowWidth();
- int newHeight = sessionInfo.getWindowHeight();
- if ((newWidth != windowResize.getWidth())
- || (newHeight != windowResize.getHeight())
- ) {
- TResizeEvent event = new TResizeEvent(TResizeEvent.Type.SCREEN,
- newWidth, newHeight);
- windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN,
- newWidth, newHeight);
- synchronized (eventQueue) {
- eventQueue.add(event);
+ long windowSizeDelay = now.getTime() - windowSizeTime;
+ if (windowSizeDelay > 1000) {
+ sessionInfo.queryWindowSize();
+ int newWidth = sessionInfo.getWindowWidth();
+ int newHeight = sessionInfo.getWindowHeight();
+ if ((newWidth != windowResize.getWidth())
+ || (newHeight != windowResize.getHeight())
+ ) {
+ TResizeEvent event = new TResizeEvent(TResizeEvent.Type.SCREEN,
+ newWidth, newHeight);
+ windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN,
+ newWidth, newHeight);
+ queue.add(event);
}
+ windowSizeTime = now.getTime();
}
- synchronized (eventQueue) {
- if (eventQueue.size() > 0) {
- synchronized (queue) {
- queue.addAll(eventQueue);
- }
- eventQueue.clear();
+ // ESCDELAY type timeout
+ if (state == ParseState.ESCAPE) {
+ long escDelay = now.getTime() - escapeTime;
+ if (escDelay > 100) {
+ // After 0.1 seconds, assume a true escape character
+ queue.add(controlChar((char)0x1B, false));
+ reset();
}
}
}
// Parameter separator
if (ch == ';') {
paramI++;
- params.set(paramI, "");
+ params.add("");
return;
}
// Parameter separator
if (ch == ';') {
paramI++;
- params.set(paramI, "");
+ params.add(paramI, "");
return;
}
}
}
} else {
+ getIdleEvents(events);
+ if (events.size() > 0) {
+ synchronized (eventQueue) {
+ eventQueue.addAll(events);
+ }
+ events.clear();
+ }
+
// Wait 10 millis for more data
Thread.sleep(10);
}