Commits

mabe02 committed 527a4e4

Contribution from Adrian:
* Make the SwingTerminal also reset the foreground and background colors on RESET_ALL SGR

  • Participants
  • Parent commits 1b2a4b7
  • Branches 1.0.x-branch

Comments (0)

Files changed (2)

src/org/lantern/terminal/SwingTerminal.java

     {
         for(SGR sgr: options)
         {
-            if(sgr == SGR.RESET_ALL)
+            if(sgr == SGR.RESET_ALL) {
                 currentlyBold = false;
+                currentForegroundColor = Color.DEFAULT;
+                currentBackgroundColor = Color.DEFAULT;
+            }
             else if(sgr == SGR.ENTER_BOLD)
                 currentlyBold = true;
             else if(sgr == SGR.EXIT_BOLD)

src/org/lantern/test/ResetAllTest.java

+/*
+ * Copyright (C) 2011 martin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.lantern.test;
+
+import org.lantern.LanternException;
+import org.lantern.LanternTerminal;
+import org.lantern.TerminalFactory.Common;
+import org.lantern.terminal.Terminal;
+
+/**
+ *
+ * @author martin
+ */
+public class ResetAllTest {
+    public static void main(String[] args) throws LanternException, InterruptedException {
+        Terminal terminal = new LanternTerminal().getUnderlyingTerminal();
+        terminal.enterPrivateMode();
+        terminal.clearScreen();
+        terminal.moveCursor(10, 5);
+        terminal.putCharacter('H');
+        terminal.putCharacter('e');
+        terminal.applySGR(Terminal.SGR.ENTER_BOLD);
+        terminal.putCharacter('l');
+        terminal.applyForegroundColor(Terminal.Color.CYAN);
+        terminal.putCharacter('l');
+        terminal.applySGR(Terminal.SGR.ENTER_REVERSE);
+        terminal.putCharacter('o');
+        terminal.applySGR(Terminal.SGR.RESET_ALL);
+        terminal.putCharacter('!');
+        terminal.moveCursor(0, 0);
+
+        Thread.sleep(5000);
+        terminal.exitPrivateMode();
+    }
+}