Ejemplo n.º 1
0
 function testRenderHexHighlightWithinFragment()
 {
     $highlight1 = new Highlight(15, 18, Highlight::MATCH, 0, 0, 'ref1');
     $splitPositions = array(15 => array(new SplitPosition(1, SplitPosition::START, $highlight1)), 18 => array(new SplitPosition(1, SplitPosition::END, $highlight1)));
     $renderedText = $this->textRenderer->renderHex($this->textFragment, $splitPositions);
     assertThat($renderedText, is("0x0000000A |66 6f 6f 20 62 <a id=\"highlight\"></a><span class=\"hi-match\" title=\"ref1\">61 72 20 </span>62 61 7a 20 71 75 75 78| |foo&nbsp;b<a id=\"highlight\"></a><span class=\"hi-match\" title=\"ref1\">ar&nbsp;</span>baz&nbsp;quux|<br/>\n"));
 }
Ejemplo n.º 2
0
 /**
  * \brief Given a file handle, display a "hex dump" of the file.
  * Output goes to stdout!
  */
 function getHex($inputFile, $startOffset = 0, $outputLength = -1, $splitPositions = array())
 {
     if (!($outputLength = $this->checkAndPrepare($inputFile, $startOffset, $outputLength))) {
         return "";
     }
     $output = "";
     fseek($inputFile, $startOffset, SEEK_SET);
     $textFragment = new TextFragment($startOffset, fread($inputFile, $outputLength));
     $output .= "<div class='mono'>";
     $renderedText = $this->textRenderer->renderHex($textFragment, $splitPositions);
     $output .= $renderedText;
     $output .= "</div>\n";
     return $output;
 }