59 public function format( $diff ) {
73 foreach ( $diff->edits
as $edit ) {
74 if ( $edit->type ==
'copy' ) {
75 if ( is_array( $block ) ) {
76 if ( count( $edit->orig ) <= $nlead + $ntrail ) {
80 $context = array_slice( $edit->orig, 0, $ntrail );
83 $this->
block( $x0, $ntrail + $xi - $x0,
84 $y0, $ntrail + $yi - $y0,
89 $context = $edit->orig;
91 if ( !is_array( $block ) ) {
92 $context = array_slice( $context, count( $context ) - $nlead );
93 $x0 = $xi - count( $context );
94 $y0 = $yi - count( $context );
104 $xi += count( $edit->orig );
106 if ( $edit->closing ) {
107 $yi += count( $edit->closing );
111 if ( is_array( $block ) ) {
112 $this->
block( $x0, $xi - $x0,
132 protected function block( $xbeg, $xlen, $ybeg, $ylen, &$edits ) {
135 foreach ( $edits
as $edit ) {
136 if ( $edit->type ==
'copy' ) {
138 } elseif ( $edit->type ==
'add' ) {
139 $this->
added( $edit->closing );
140 } elseif ( $edit->type ==
'delete' ) {
142 } elseif ( $edit->type ==
'change' ) {
143 $this->
changed( $edit->orig, $edit->closing );
145 throw new MWException(
"Unknown edit type: {$edit->type}" );
160 $val = ob_get_contents();
174 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
176 $xbeg .=
',' . ( $xbeg + $xlen - 1 );
179 $ybeg .=
',' . ( $ybeg + $ylen - 1 );
182 return $xbeg . ( $xlen ? ( $ylen ?
'c' :
'd' ) :
'a' ) . $ybeg;
208 protected function lines(
$lines, $prefix =
' ' ) {
210 echo
"$prefix $line\n";
241 protected function changed( $orig, $closing ) {
244 $this->
added( $closing );