From 842be156c1c15b74c1b4bfe30c2866773494a2af Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Tue, 27 Aug 2019 20:08:35 -0500 Subject: [PATCH] #55 restore default attributes on exit --- src/jexer/backend/ECMA48Terminal.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index 44c4038..3fc6c20 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -1349,7 +1349,7 @@ 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", mouse(false), cursor(true), normal()); + output.printf("%s%s%s", mouse(false), cursor(true), defaultColor()); output.flush(); } @@ -3643,7 +3643,7 @@ public class ECMA48Terminal extends LogicalScreen } /** - * Create a SGR parameter sequence to reset to defaults. + * Create a SGR parameter sequence to reset to VT100 defaults. * * @return the string to emit to an ANSI / ECMA-style terminal, * e.g. "\033[0m" @@ -3652,6 +3652,29 @@ public class ECMA48Terminal extends LogicalScreen return normal(true) + rgbColor(false, Color.WHITE, Color.BLACK); } + /** + * Create a SGR parameter sequence to reset to ECMA-48 default + * foreground/background. + * + * @return the string to emit to an ANSI / ECMA-style terminal, + * e.g. "\033[0m" + */ + private String defaultColor() { + /* + * VT100 normal. + * Normal (neither bold nor faint). + * Not italicized. + * Not underlined. + * Steady (not blinking). + * Positive (not inverse). + * Visible (not hidden). + * Not crossed-out. + * Default foreground color. + * Default background color. + */ + return "\033[0;22;23;24;25;27;28;29;39;49m"; + } + /** * Create a SGR parameter sequence to reset to defaults. * -- 2.27.0