aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer
diff options
context:
space:
mode:
authorPeti Gomori <[email protected]>2012-06-13 18:35:02 +0200
committerHenrik Nord <[email protected]>2012-06-15 08:55:45 +0200
commitf530bdb22a3a59ef97b35d7be11f9c06b0c34356 (patch)
tree30cc2959c31517f94444b278decfe8929edd6697 /lib/observer
parent12db9a2c150edd41bafaf58b119ee88fe75b8814 (diff)
downloadotp-f530bdb22a3a59ef97b35d7be11f9c06b0c34356.tar.gz
otp-f530bdb22a3a59ef97b35d7be11f9c06b0c34356.tar.bz2
otp-f530bdb22a3a59ef97b35d7be11f9c06b0c34356.zip
Escape control characters in Table Viewer
Similar behaviour to old tv. Objects in tables supposed to be printed in a single line and it looks ugly when a [...,10,...] integer list creates a new-line.
Diffstat (limited to 'lib/observer')
-rw-r--r--lib/observer/src/observer_tv_table.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl
index d339a853cb..97d18ec03c 100644
--- a/lib/observer/src/observer_tv_table.erl
+++ b/lib/observer/src/observer_tv_table.erl
@@ -762,7 +762,7 @@ format_tuple(_Tuple, 1, 0) ->
format_list([]) -> "[]";
format_list(List) ->
case printable_list(List) of
- true -> io_lib:format("\"~ts\"", [List]);
+ true -> io_lib:format("\"~ts\"", [map_printable_list(List)]);
false -> [$[ | make_list(List)]
end.
@@ -771,6 +771,24 @@ make_list([Last]) ->
make_list([Head|Tail]) ->
[format(Head), $,|make_list(Tail)].
+map_printable_list([$\n|Cs]) ->
+ [$\\, $n|map_printable_list(Cs)];
+map_printable_list([$\r|Cs]) ->
+ [$\\, $r|map_printable_list(Cs)];
+map_printable_list([$\t|Cs]) ->
+ [$\\, $t|map_printable_list(Cs)];
+map_printable_list([$\v|Cs]) ->
+ [$\\, $v|map_printable_list(Cs)];
+map_printable_list([$\b|Cs]) ->
+ [$\\, $b|map_printable_list(Cs)];
+map_printable_list([$\f|Cs]) ->
+ [$\\, $f|map_printable_list(Cs)];
+map_printable_list([$\e|Cs]) ->
+ [$\\, $e|map_printable_list(Cs)];
+map_printable_list([]) -> [];
+map_printable_list([C|Cs]) ->
+ [C|map_printable_list(Cs)].
+
%% printable_list([Char]) -> bool()
%% Return true if CharList is a list of printable characters, else
%% false.