require_cmd "${TM_SVN:=svn}"
: ${TM_RUBY:=ruby}
FORMAT_INFO="${TM_BUNDLE_SUPPORT}/format_annotate.rb"
"$TM_SVN" annotate "$TM_FILEPATH" |"$TM_RUBY" -- "$FORMAT_INFO"
And here's the Ruby formatter:
require ENV['TM_BUNDLE_SUPPORT']+'/svn_helper.rb'
include SVNHelper
puts html_head(:window_title => "Info", :page_title => "SVN Annotation", :sub_title => 'Subversion')
puts '<div class="subversion">'
STDOUT.flush
@colors = ['BlanchedAlmond',
'BlueViolet',
'Brown',
'BurlyWood',
'CadetBlue',
'Chartreuse',
'Chocolate',
'Coral',
'CornflowerBlue',
'Crimson',
'Cyan',
'DarkBlue',
'DarkCyan',
'DarkGoldenRod',
'DarkGray',
'DarkGreen',
'DarkKhaki',
'DarkMagenta',
'DarkOliveGreen',
'Darkorange',
'DarkOrchid',
'DarkRed',
'DarkSalmon',
'DarkSeaGreen'] #see http://www.w3schools.com/html/html_colornames.asp for more pretty colors
@color_hash = Hash.new
@color_ind_size = @colors.size() -1
def color_for_rev(rev)
color = @color_hash[rev]
unless (color)
color_index = rev % @color_ind_size
color = @colors[color_index]
@color_hash[rev] = color
end
color
end
$stdin.each_line do |line|
rev = line.strip.split(" ").first.to_i
color = color_for_rev(rev)
colored = "<div style='color:#{color}'>#{htmlize(line.strip)}"
puts(colored)
end
puts("</div>")
html_footer()
No comments:
Post a Comment