Tabular formatter: fix problem with CR (carriage return). v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 01 Feb 2015 00:03:40 +0100
branchv_0
changeset 185087d8ec75109
parent 184 53fb05ce504c
child 186 6c6a7904b22a
Tabular formatter: fix problem with CR (carriage return).
Less command or orher programs shows it as ^M (two characters) and it breaks the table layout – so we need to translate it to a single symbol.
java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Sat Jan 31 23:40:31 2015 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Sun Feb 01 00:03:40 2015 +0100
     1.3 @@ -27,10 +27,14 @@
     1.4  import java.util.regex.Pattern;
     1.5  
     1.6  /**
     1.7 - * <p>Prints human-readable output – tables of result sets and text messages with update counts.</p>
     1.8 + * <p>
     1.9 + * Prints human-readable output – tables of result sets and text messages with update counts.
    1.10 + * </p>
    1.11   *
    1.12 - * <p>Longer values might break the table – overflow the cells – see alternative tabular formatters
    1.13 - * and the {@linkplain #PROPERTY_TRIM} property.</p>
    1.14 + * <p>
    1.15 + * Longer values might break the table – overflow the cells – see alternative tabular formatters
    1.16 + * and the {@linkplain #PROPERTY_TRIM} property.
    1.17 + * </p>
    1.18   *
    1.19   * @author Ing. František Kučera (frantovo.cz)
    1.20   * @see TabularPrefetchingFormatter
    1.21 @@ -45,7 +49,7 @@
    1.22  	public static final String PROPERTY_COLORFUL = "color";
    1.23  	public static final String PROPERTY_TRIM = "trim";
    1.24  	private static final String NBSP = " ";
    1.25 -	private static final Pattern whitespaceToReplace = Pattern.compile("\\n|\\t|" + NBSP);
    1.26 +	private static final Pattern whitespaceToReplace = Pattern.compile("\\n|\\r|\\t|" + NBSP);
    1.27  	protected ColorfulPrintWriter out;
    1.28  	private boolean firstResult = true;
    1.29  	private int[] columnWidth;
    1.30 @@ -282,6 +286,9 @@
    1.31  				case "\n":
    1.32  					out.print(TerminalColor.Red, "↲");
    1.33  					break;
    1.34 +				case "\r":
    1.35 +					out.print(TerminalColor.Red, "⏎");
    1.36 +					break;
    1.37  				case "\t":
    1.38  					out.print(TerminalColor.Red, "↹");
    1.39  					break;