]> git.sur5r.net Git - i3/i3/blobdiff - contrib/dump-asy.pl
dump-asy.pl: Add marks
[i3/i3] / contrib / dump-asy.pl
index 478a896a5c4b403c36962a6ad675c670f9351608..636b20ce3a3f3324b6712efa3e04de1d4362c255 100755 (executable)
@@ -15,6 +15,12 @@ use AnyEvent::I3;
 use File::Temp;
 use File::Basename;
 use v5.10;
+use IPC::Cmd qw[can_run];
+
+# prerequisites check so we can be specific about failures caused
+# by not having these tools in the path
+can_run('asy') or die 'Please install asymptote';
+can_run('gv') or die 'Please install gv';
 
 my $i3 = i3();
 
@@ -31,7 +37,7 @@ sub dump_node {
 
     my $o = ($n->{orientation} eq 'none' ? "u" : ($n->{orientation} eq 'horizontal' ? "h" : "v"));
     my $w = (defined($n->{window}) ? $n->{window} : "N");
-    my $na = $n->{name};
+    my $na = ($n->{name} or "[Empty]");
     $na =~ s/#/\\#/g;
     $na =~ s/\$/\\\$/g;
     $na =~ s/&/\\&/g;
@@ -39,9 +45,10 @@ sub dump_node {
     $na =~ s/~/\\textasciitilde{}/g;
     my $type = 'leaf';
     if (!defined($n->{window})) {
-        $type = $n->{orientation} . '-split';
+        $type = $n->{layout};
     }
-    my $name = qq|``$na'' ($type)|;
+    my $marks = $n->{marks} ? ' [' . join('][', @{$n->{marks}}) . ']' : '';
+    my $name = qq|``$na'' ($type)$marks|;
 
     print $tmp "TreeNode n" . $n->{id} . " = makeNode(";