image support test

This commit is contained in:
Kevin Lamonte 2020-06-08 08:57:26 -05:00
parent c587758fed
commit e5b5a181bd
2 changed files with 41 additions and 3 deletions

View file

@ -87,6 +87,13 @@ public class TApplication implements Runnable {
// Constants --------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* If true, do not confirm on exit, and leave the terminal in its final
* state (do not restore the console). This is used for generating
* captures to test terminals that advertise images support.
*/
public static final boolean imageSupportTest = false;
/**
* If true, emit thread stuff to System.err.
*/
@ -652,6 +659,13 @@ public class TApplication implements Runnable {
final int windowHeight, final int fontSize)
throws UnsupportedEncodingException {
if (imageSupportTest) {
backend = new ECMA48Backend(this, null, null, windowWidth,
windowHeight, fontSize);
TApplicationImpl();
return;
}
switch (backendType) {
case SWING:
backend = new SwingBackend(this, windowWidth, windowHeight,
@ -681,6 +695,12 @@ public class TApplication implements Runnable {
public TApplication(final BackendType backendType)
throws UnsupportedEncodingException {
if (imageSupportTest) {
backend = new ECMA48Backend(this, null, null);
TApplicationImpl();
return;
}
switch (backendType) {
case SWING:
// The default SwingBackend is 80x25, 20 pt font. If you want to
@ -981,6 +1001,11 @@ public class TApplication implements Runnable {
protected boolean onCommand(final TCommandEvent command) {
// Default: handle cmExit
if (command.equals(cmExit)) {
if (imageSupportTest) {
exit();
return true;
}
if (messageBox(i18n.getString("exitDialogTitle"),
i18n.getString("exitDialogText"),
TMessageBox.Type.YESNO).isYes()) {
@ -1041,6 +1066,11 @@ public class TApplication implements Runnable {
// Default: handle MID_EXIT
if (menu.getId() == TMenu.MID_EXIT) {
if (imageSupportTest) {
exit();
return true;
}
if (messageBox(i18n.getString("exitDialogTitle"),
i18n.getString("exitDialogText"),
TMessageBox.Type.YESNO).isYes()) {
@ -2090,6 +2120,12 @@ public class TApplication implements Runnable {
*/
protected void onPreDraw() {
// Default does nothing
if (imageSupportTest) {
menuTrayText = String.format("%d x %d cells, %d x %d cell size",
getScreen().getWidth(), getScreen().getHeight(),
getScreen().getTextWidth(), getScreen().getTextHeight());
}
}
/**

View file

@ -1486,9 +1486,11 @@ public class ECMA48Terminal extends LogicalScreen
// Disable mouse reporting and show cursor. Defensive null check
// here in case closeTerminal() is called twice.
if (output != null) {
output.printf("%s%s%s%s", mouse(false), cursor(true),
defaultColor(), xtermResetSixelSettings());
output.printf("\033[>4m");
if (!jexer.TApplication.imageSupportTest) {
output.printf("%s%s%s%s", mouse(false), cursor(true),
defaultColor(), xtermResetSixelSettings());
output.printf("\033[>4m");
}
output.flush();
}