err(getLocalizationManager().getLocalizedTextString("lineJunk")); //$NON-NLS-1$
}
else
{
int half = listsize/2;
SourceFile file = m_fileInfo.getFile(module1);
numLines = file.getLineCount();
int newLine;
if (numLines == 1 && file.getLine(1).equals("")) //$NON-NLS-1$
{
// there's no source in the file at all!
// this presumably means that the source file isn't in the current directory
err(getLocalizationManager().getLocalizedTextString("sourceFileNotFound")); //$NON-NLS-1$
newLine = currentLine;
}
else
{
// pressing return is ok, otherwise throw the exception
if (line1 > numLines && arg1 != null)
throw new IndexOutOfBoundsException();
/* if no arg2 then user requested the next N lines around something */
if (arg2 == null)
{
line2 = line1 + (half) - 1;
line1 = line1 - (listsize-half);
}
/* adjust our range of lines to ensure we conform */
if (line1 < 1)
{
/* shrink line 1, grow line2 */
line2 += -(line1 - 1);
line1 = 1;
}
if (line2 > numLines)
line2 = numLines;
// System.out.println("1="+module1+":"+line1+",2="+module2+":"+line2+",num="+numLines+",half="+half);
/* nothing to display */
if (line1 > line2)
throw new IndexOutOfBoundsException();
/* now do it! */
SourceFile source = m_fileInfo.getFile(module1);
for(int i=line1; i<=line2; i++)
outputSource(module1, i, source.getLine(i));
newLine = line2 + half + (((listsize % 2) == 0) ? 1 : 2); // add one if even, 2 for odd;
}
/* save away valid context */