#!/usr/bin/perl #Timeline, is a utility to draw diagrams that depict a time sequence #of data, message or information exchange between entities or states. #Such and similar diagrams are also known as Function Call Trees, Sequence #Diagrams, or Chronological State Transition Diagrams in different contexts. #Copyright (C) 2003 Atul Nene (www.atulnene.com) # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; specifically version 2 #of the License # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details at #http://www.gnu.org/licenses/gpl.html . $totalcols = 4 ; $colmarker = "|" ; $emptyline = " " ; $line = "---------------" ; $linelen = 15 ; $arrow = ">" ; $space = " " ; $minus = "-" ; $tcount = 1 ; while() { #print $_; # echo line read printf "t%-5d", $tcount ; $tcount = $tcount + 1 ; #s/^\s+//; @array = split (' ', $_) ; $fromcol = @array[0] ; $tocol = @array[1] ; $funcname = @array[2] ; for ( $i = 1; $i < $fromcol ; ++$i ) { print $colmarker ; print $emptyline ; print $space ; } if ($fromcol == $tocol) { print $colmarker ; print "<=" ; $tmplen= length ($funcname) ; $tmplen = $linelen - $tmplen - 1 ; $tmpstr = substr($emptyline, 0, $tmplen ) ; printf "%s%-${tmplen}s", $funcname, $tmpstr; } else { for ( $i = $fromcol; $i < $tocol ; ++$i ) { print $colmarker ; if ($i == $fromcol) { $tmplen= length ($funcname) ; $tmplen = $linelen - $tmplen ; $tmpstr = substr($line, 0, $tmplen) ; printf "%${tmplen}s%s", $tmpstr, $funcname; if ($i == $tocol - 1 ) { print $arrow ; } else { print $minus ; } } else { print $line ; if ($i == $tocol - 1 ) { print $arrow ; } else { print $minus ; } } } } for ( $i = $tocol; $i <= $totalcols ; ++$i ) { print $colmarker ; print $emptyline ; print $space ; } print "\n"; }