トップ 一覧 検索 ヘルプ RSS ログイン

日記/2005-10-16の変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!codeプラグインに行番号を引き継げる様にするパッチを作った
これ作っている時に思いついたネタとして、こういうdiff/patchを色分けするようなのもいいかなと思った。
 --- Code.pm.orig	Sun Sep  4 03:14:16 2005
 +++ Code.pm	Sun Oct 16 13:27:02 2005
 @@ -22,6 +22,15 @@
  	return bless $self,$class;
  }
  
 +use vars qw($maxline $place);
 +#===========================================================
 +# フックメソッド(initialize用)
 +#===========================================================
 +sub hook {
 +	$maxline = 1;
 +	$place = 1;
 +}
 +
  #===========================================================
  # ブロックプラグイン
  #===========================================================
 @@ -62,8 +71,16 @@
  		# 行番号表示
  		if    ($line eq 'false') {$line='0';}
  		elsif ($line eq 'true' || $line =~ /^ *$/ ) {$line='1';}
 -		if ($line !~ /[^ 0-9]/ && $line !~ /^ *0$/){
 -			my $maxline = split(/\n/,$source) + $line-1;
 +		if ($line !~ /[^-+ 0-9]/ && $line !~ /^ *0$/){
 +			if ($line =~ /[+-]/){
 +				if ($line < 0 or $line =~ /\+/ and $line == 0){
 +					$line++;
 +				}
 +				$line = $maxline+$line;
 +				$line = " "x($place - length $line) . $line;
 +			}
 +			$place = length $line;
 +			$maxline = split(/\n/,$source) + $line-1;
  			$html .= "<td class=\"line\"><pre>";
  			for(my $i=$line;$i<=$maxline;$i++){
  				$html .= "$i<br>";
 --- Install.pm.orig	Sun Oct 16 01:07:16 2005
 +++ Install.pm	Sun Oct 16 13:26:21 2005
 @@ -10,6 +10,7 @@
  	my $wiki = shift;
  	$wiki->add_block_plugin("code","plugin::code::Code","HTML");
  	$wiki->add_paragraph_plugin("ref_code","plugin::code::RefCode","HTML");
 +	$wiki->add_hook("initialize","plugin::code::Code","HTML");
 +	$wiki->add_hook("initialize","plugin::code::Code");
  }
  
  1;