X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FTWindowBackend.java;h=f644b76ba4bf3d9e1642502ae330fc97146d1a5d;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=ed701ad0076dc93d2a9a54f66254f70d2bd0204f;hpb=c88c4ced6e9392a53030a1c680fe114931a1a928;p=nikiroo-utils.git diff --git a/src/jexer/backend/TWindowBackend.java b/src/jexer/backend/TWindowBackend.java index ed701ad..f644b76 100644 --- a/src/jexer/backend/TWindowBackend.java +++ b/src/jexer/backend/TWindowBackend.java @@ -28,15 +28,17 @@ */ package jexer.backend; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; +import jexer.TApplication; +import jexer.TWindow; +import jexer.event.TCommandEvent; import jexer.event.TInputEvent; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; import jexer.event.TResizeEvent; -import jexer.TApplication; -import jexer.TWindow; +import static jexer.TCommand.*; /** * TWindowBackend uses a window in one TApplication to provide a backend for @@ -110,6 +112,26 @@ public class TWindowBackend extends TWindow implements Backend { window.setHeight(getHeight() + 2); } + /** + * Get the width of a character cell in pixels. + * + * @return the width in pixels of a character cell + */ + @Override + public int getTextWidth() { + return window.getScreen().getTextWidth(); + } + + /** + * Get the height of a character cell in pixels. + * + * @return the height in pixels of a character cell + */ + @Override + public int getTextHeight() { + return window.getScreen().getTextHeight(); + } + } @@ -134,7 +156,7 @@ public class TWindowBackend extends TWindow implements Backend { super(application, title, width, height); this.listener = listener; - eventQueue = new LinkedList(); + eventQueue = new ArrayList(); sessionInfo = new TSessionInfo(width, height); otherScreen = new OtherScreen(this); otherScreen.setDimensions(width - 2, height - 2); @@ -160,7 +182,7 @@ public class TWindowBackend extends TWindow implements Backend { super(application, title, width, height, flags); this.listener = listener; - eventQueue = new LinkedList(); + eventQueue = new ArrayList(); sessionInfo = new TSessionInfo(width, height); otherScreen = new OtherScreen(this); otherScreen.setDimensions(width - 2, height - 2); @@ -187,7 +209,7 @@ public class TWindowBackend extends TWindow implements Backend { super(application, title, x, y, width, height); this.listener = listener; - eventQueue = new LinkedList(); + eventQueue = new ArrayList(); sessionInfo = new TSessionInfo(width, height); otherScreen = new OtherScreen(this); otherScreen.setDimensions(width - 2, height - 2); @@ -216,7 +238,7 @@ public class TWindowBackend extends TWindow implements Backend { super(application, title, x, y, width, height, flags); this.listener = listener; - eventQueue = new LinkedList(); + eventQueue = new ArrayList(); sessionInfo = new TSessionInfo(width, height); otherScreen = new OtherScreen(this); otherScreen.setDimensions(width - 2, height - 2); @@ -408,7 +430,9 @@ public class TWindowBackend extends TWindow implements Backend { */ @Override public void onClose() { - // TODO: send a screen disconnect + synchronized (eventQueue) { + eventQueue.add(new TCommandEvent(cmBackendDisconnect)); + } } // ------------------------------------------------------------------------