TabularFormatter: values with line ends will not break our tables v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 30 Dec 2013 23:46:41 +0100
branchv_0
changeset 103 5410b6afc839
parent 102 ff47349e24bf
child 104 245f1b88a3e6
TabularFormatter: values with line ends will not break our tables
java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java
--- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Mon Dec 30 15:50:05 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Mon Dec 30 23:46:41 2013 +0100
@@ -141,7 +141,14 @@
 			printTableBorder(" │ ");
 		}
 
-		out.print(TerminalColor.Cyan, toString(value));
+		String[] valueParts = toString(value).split("\n");
+		for (int i = 0; i < valueParts.length; i++) {
+			String valuePart = valueParts[i];
+			out.print(TerminalColor.Cyan, valuePart);
+			if (i < valueParts.length - 1) {
+				out.print(TerminalColor.Red, "↲");
+			}
+		}
 
 		if (isCurrentColumnLast()) {
 			printTableBorder(" │");