[Swift-commit] r5830 - trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Thu Jul 12 16:36:01 CDT 2012
Author: hategan
Date: 2012-07-12 16:36:00 -0500 (Thu, 12 Jul 2012)
New Revision: 5830
Added:
trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/UnicodeDrawingScheme.java
Modified:
trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSIContext.java
Log:
forgot UnicodeDrawingScheme and disable unicode if the output stream writer does not support UTF8
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSIContext.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSIContext.java 2012-07-12 21:03:37 UTC (rev 5829)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSIContext.java 2012-07-12 21:36:00 UTC (rev 5830)
@@ -51,16 +51,17 @@
private UnicodeDrawingScheme uds;
public ANSIContext(OutputStream os, InputStream is) {
+ unicode = "true".equals(System.getProperty("tui.use.unicode"));
try {
this.os = new OutputStreamWriter(os, "UTF8");
}
catch (UnsupportedEncodingException e) {
logger.warn("UTF8 not supported here");
this.os = new OutputStreamWriter(os);
+ unicode = false;
}
this.is = is;
doubleBuffered = true;
- unicode = "true".equals(System.getProperty("tui.use.unicode"));
if (unicode) {
uds = new UnicodeDrawingScheme.RoundedLight();
}
Added: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/UnicodeDrawingScheme.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/UnicodeDrawingScheme.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/UnicodeDrawingScheme.java 2012-07-12 21:36:00 UTC (rev 5830)
@@ -0,0 +1,177 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 12, 2012
+ */
+package org.griphyn.vdl.karajan.monitor.monitors.ansi.tui;
+
+public interface UnicodeDrawingScheme {
+ char getChar(int code);
+
+
+ public static class ASCII implements UnicodeDrawingScheme {
+ @Override
+ public char getChar(int code) {
+ switch(code) {
+ case ANSI.GCH_LR_CORNER:
+ case ANSI.GCH_UR_CORNER:
+ case ANSI.GCH_UL_CORNER:
+ case ANSI.GCH_LL_CORNER:
+ case ANSI.GCH_CROSS:
+ case ANSI.GCH_H_LINE:
+ case ANSI.GCH_V_LINE:
+ case ANSI.GCH_ML_CORNER:
+ case ANSI.GCH_MR_CORNER:
+ case ANSI.GCH_LM_CORNER:
+ case ANSI.GCH_UM_CORNER:
+ case ANSI.GCH_HASH:
+ case ANSI.GCH_BULLET:
+ return (char) code;
+ case ANSI.GCH_ARROW_DOWN:
+ case ANSI.GCH_ARROW_UP:
+ return '-';
+ case ANSI.GCH_ARROW_LEFT:
+ case ANSI.GCH_ARROW_RIGHT:
+ return '|';
+ default:
+ return '.';
+ }
+ }
+ }
+
+ public static class SquareHeavy implements UnicodeDrawingScheme {
+ @Override
+ public char getChar(int code) {
+ switch(code) {
+ case ANSI.GCH_LR_CORNER:
+ return '\u251b';
+ case ANSI.GCH_UR_CORNER:
+ return '\u2513';
+ case ANSI.GCH_UL_CORNER:
+ return '\u250f';
+ case ANSI.GCH_LL_CORNER:
+ return '\u2517';
+ case ANSI.GCH_CROSS:
+ return '\u254b';
+ case ANSI.GCH_H_LINE:
+ return '\u2501';
+ case ANSI.GCH_V_LINE:
+ return '\u2503';
+ case ANSI.GCH_ML_CORNER:
+ return '\u2523';
+ case ANSI.GCH_MR_CORNER:
+ return '\u252b';
+ case ANSI.GCH_LM_CORNER:
+ return '\u253b';
+ case ANSI.GCH_UM_CORNER:
+ return '\u2533';
+ case ANSI.GCH_HASH:
+ return '\u2592';
+ case ANSI.GCH_BULLET:
+ return '\u2022';
+ case ANSI.GCH_ARROW_DOWN:
+ return '\u21e9';
+ case ANSI.GCH_ARROW_UP:
+ return '\u21e7';
+ case ANSI.GCH_ARROW_LEFT:
+ return '\u21e6';
+ case ANSI.GCH_ARROW_RIGHT:
+ return '\u21e8';
+ default:
+ return '.';
+ }
+ }
+ }
+
+ public static class SquareLight implements UnicodeDrawingScheme {
+ @Override
+ public char getChar(int code) {
+ switch(code) {
+ case ANSI.GCH_LR_CORNER:
+ return '\u2518';
+ case ANSI.GCH_UR_CORNER:
+ return '\u2510';
+ case ANSI.GCH_UL_CORNER:
+ return '\u250c';
+ case ANSI.GCH_LL_CORNER:
+ return '\u2514';
+ case ANSI.GCH_CROSS:
+ return '\u253c';
+ case ANSI.GCH_H_LINE:
+ return '\u2500';
+ case ANSI.GCH_V_LINE:
+ return '\u2502';
+ case ANSI.GCH_ML_CORNER:
+ return '\u251c';
+ case ANSI.GCH_MR_CORNER:
+ return '\u2524';
+ case ANSI.GCH_LM_CORNER:
+ return '\u2534';
+ case ANSI.GCH_UM_CORNER:
+ return '\u252c';
+ case ANSI.GCH_HASH:
+ return '\u2591';
+ case ANSI.GCH_BULLET:
+ return '\u2022';
+ case ANSI.GCH_ARROW_DOWN:
+ return '\u21e9';
+ case ANSI.GCH_ARROW_UP:
+ return '\u21e7';
+ case ANSI.GCH_ARROW_LEFT:
+ return '\u21e6';
+ case ANSI.GCH_ARROW_RIGHT:
+ return '\u21e8';
+ default:
+ return '.';
+ }
+ }
+ }
+
+ public static class RoundedLight implements UnicodeDrawingScheme {
+ @Override
+ public char getChar(int code) {
+ switch(code) {
+ case ANSI.GCH_LR_CORNER:
+ return '\u256f';
+ case ANSI.GCH_UR_CORNER:
+ return '\u256e';
+ case ANSI.GCH_UL_CORNER:
+ return '\u256d';
+ case ANSI.GCH_LL_CORNER:
+ return '\u2570';
+ case ANSI.GCH_CROSS:
+ return '\u253c';
+ case ANSI.GCH_H_LINE:
+ return '\u2500';
+ case ANSI.GCH_V_LINE:
+ return '\u2502';
+ case ANSI.GCH_ML_CORNER:
+ return '\u251c';
+ case ANSI.GCH_MR_CORNER:
+ return '\u2524';
+ case ANSI.GCH_LM_CORNER:
+ return '\u2534';
+ case ANSI.GCH_UM_CORNER:
+ return '\u252c';
+ case ANSI.GCH_HASH:
+ return '\u2591';
+ case ANSI.GCH_BULLET:
+ return '\u2263';
+ case ANSI.GCH_ARROW_DOWN:
+ return '\u25bc';
+ case ANSI.GCH_ARROW_UP:
+ return '\u25b2';
+ case ANSI.GCH_ARROW_LEFT:
+ return '\u25c0';
+ case ANSI.GCH_ARROW_RIGHT:
+ return '\u25b6';
+ default:
+ return '.';
+ }
+ }
+ }
+}
More information about the Swift-commit
mailing list