brfrn169 commented on a change in pull request #476: HBASE-11062 hbtop
URL: https://github.com/apache/hbase/pull/476#discussion_r318121107
 
 

 ##########
 File path: 
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/EscapeSequences.java
 ##########
 @@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.hbtop.terminal.impl;
+
+import org.apache.hadoop.hbase.hbtop.terminal.Color;
+import org.apache.yetus.audience.InterfaceAudience;
+
+
+/**
+ * Utility class for escape sequences.
+ */
[email protected]
+public final class EscapeSequences {
+  private EscapeSequences() {
+  }
+
+  public static String clearAll() {
+    return "\033[0;37;40m\033[2J";
+  }
+
+  public static String setTitle(String title) {
+    return "\033]2;" + title + "\007";
+  }
+
+  public static String cursor(boolean on) {
+    if (on) {
+      return "\033[?25h";
+    }
+    return "\033[?25l";
+  }
+
+  public static String moveCursor(int column, int row) {
+    return String.format("\033[%d;%dH", row + 1, column + 1);
+  }
+
+  public static String clearRemainingLine() {
+    return "\033[0;37;40m\033[K";
+  }
+
+  public static String color(Color foregroundColor, Color backgroundColor, 
boolean bold,
+    boolean reverse, boolean blink, boolean underline) {
+
+    int foregroundColorValue = getColorValue(foregroundColor, true);
+    int backgroundColorValue = getColorValue(backgroundColor, false);
+
+    StringBuilder sb = new StringBuilder();
+    if (bold && reverse && blink && !underline) {
+      sb.append("\033[0;1;7;5;");
+    } else if (bold && reverse && !blink && !underline) {
+      sb.append("\033[0;1;7;");
+    } else if (!bold && reverse && blink && !underline) {
+      sb.append("\033[0;7;5;");
+    } else if (bold && !reverse && blink && !underline) {
+      sb.append("\033[0;1;5;");
+    } else if (bold && !reverse && !blink && !underline) {
+      sb.append("\033[0;1;");
+    } else if (!bold && reverse && !blink && !underline) {
+      sb.append("\033[0;7;");
+    } else if (!bold && !reverse && blink && !underline) {
+      sb.append("\033[0;5;");
+    } else if (bold && reverse && blink /* && underline */) {
 
 Review comment:
   I removed the comments. Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to