private void updateState( Delta delta )
{
m_index++;
Chunk orig = delta.getOriginal();
if (orig.first() > m_firstElem)
{
// We "skip" some lines in the output.
// So flush out the last Change, if one exists.
flushChanges();
// Allow us to "skip" large swaths of unchanged text, show a "limited" amound of
// unchanged context so the changes are shown in
if ((orig.first() - m_firstElem) > 2 * m_unchangedContextLimit)
{
if (m_firstElem > 0)
{
int endIndex = Math.min( m_firstElem + m_unchangedContextLimit, m_origStrings.length -1 );
for (int j = m_firstElem; j < endIndex; j++)
m_sb.append(m_origStrings[j]);
m_sb.append(m_elidedTailIndicatorHtml);
}
m_sb.append(m_elidedHeadIndicatorHtml);
int startIndex = Math.max(orig.first() - m_unchangedContextLimit, 0);
for (int j = startIndex; j < orig.first(); j++)
m_sb.append(m_origStrings[j]);
}
else
{
// No need to skip anything, just output the whole range...
for (int j = m_firstElem; j < orig.first(); j++)
m_sb.append( m_origStrings[j] );
}
}
m_firstElem = orig.last() + 1;
}