diff options
author | Ralph Amissah <ralph@amissah.com> | 2013-08-21 23:22:34 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2013-08-21 23:22:34 -0400 |
commit | 2c5b71e36a335fc89c5198259166ed7de478819c (patch) | |
tree | 6e7abab3e67b2735428a3d0bf80baa964864b29d /lib/sisu/v5/utils.rb | |
parent | debian/changelog (4.1.11-1) (diff) | |
parent | v5: vim syntax additions, sisu.vim (diff) |
Merge tag 'sisu_4.1.12' into debian/sid
SiSU 4.1.12
Diffstat (limited to 'lib/sisu/v5/utils.rb')
-rw-r--r-- | lib/sisu/v5/utils.rb | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/lib/sisu/v5/utils.rb b/lib/sisu/v5/utils.rb index eb707ee9..8ebc3647 100644 --- a/lib/sisu/v5/utils.rb +++ b/lib/sisu/v5/utils.rb @@ -92,15 +92,39 @@ module SiSU_Utils #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}") c end - def set(color=nil) - c=ansi(color) + def var(v,x) + h={ c: nil, m: '' } + if v.class == Hash + h[:c] = (defined? v[:c]) ? v[:c] : '' + h[:m] = (defined? v[:m]) ? v[:m] : '' + else + if v.class == Symbol + h[:c]=v + elsif v.class == String + h[:m]=v + end + if x.class == Symbol + h[:c]=x + elsif x.class == String + h[:m]=x + end + h[:c] = (defined? h[:c]) ? h[:c] : '' + h[:m] = (defined? h[:m]) ? h[:m] : '' + end + h[:c]=ansi(h[:c]) + h[:m]=message(h[:m]) + h + end + def message(msg='') + @message=(msg.empty?) ? '' : " #{msg}" + end + def set(v=nil,x=nil) + v=var(v,x) file,path=File.basename(@file),File.dirname(@file) - c[:on] + @line + c[:off] + ' ' + path + '/' "#{c[:on]}#{file}#{c[:off]}" + v[:c][:on] + @line + v[:c][:off] + ' ' + path + '/' "#{v[:c][:on]}#{file}#{v[:c][:off]}" + v[:m] end - def set_(color=nil) - c=ansi(color) - c[:on] + @line + c[:off] + ' ' + - @file.gsub(/([^\/]+$)/,"#{c[:on]}\\1#{c[:off]}") + def mark(v=nil,x=nil) + puts set(v,x) end end class Path @@ -116,9 +140,29 @@ module SiSU_Utils end end __END__ -puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:red) -puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:green) -puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:inv_red) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark({ m: %{ + code: #{@@flag[:code]}, <-- close "#{t_o}" +}}) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark({ m: %{ + code: #{@@flag['code']}, <-- close "#{t_o}" +}, c: :green}) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark({ m: %{ + code: #{@@flag['code']}, open --> "#{t_o}" +}}) if t_o=~/^```/m +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark(%{ code: #{@@flag['code']}, open --> "#{t_o}" }) \ +if t_o=~/^```/m +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark("open -->",:green) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:green,"open -->") +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark("open -->") +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:green) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("open -->") +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark('open -->',:green) +SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).mark puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).set -puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).set -puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:inv_red).set +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set('',:green) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set('',:fuchsia) +puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__ +puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}" +puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}") +puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:red]}\\1#{ANSI_C[:off]}") |