mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-06 04:29:56 +00:00
xref line numbers in columns
This commit is contained in:
parent
4071baff77
commit
94a5753fea
@ -334,32 +334,18 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
if (basicPreferences.showSymbols && !arrayLines.isEmpty ())
|
||||
showSymbols (fullText, arrayLines, "Array ");
|
||||
|
||||
if (basicPreferences.showDuplicateSymbols && !uniqueSymbols.isEmpty ())
|
||||
showDuplicates (fullText, uniqueSymbols, "Var ");
|
||||
|
||||
if (basicPreferences.showDuplicateSymbols && !uniqueArrays.isEmpty ())
|
||||
showDuplicates (fullText, uniqueArrays, "Array ");
|
||||
|
||||
if (basicPreferences.showFunctions && !functionLines.isEmpty ())
|
||||
showSymbols (fullText, functionLines, "Fnction");
|
||||
|
||||
if (basicPreferences.showConstants && !constants.isEmpty ())
|
||||
showIntegerLines (fullText, constants, " Const");
|
||||
|
||||
if (basicPreferences.showDuplicateSymbols && !uniqueSymbols.isEmpty ())
|
||||
{
|
||||
boolean headingShown = false;
|
||||
for (String key : uniqueSymbols.keySet ())
|
||||
{
|
||||
List<String> usage = uniqueSymbols.get (key);
|
||||
if (usage.size () > 1)
|
||||
{
|
||||
if (!headingShown)
|
||||
{
|
||||
headingShown = true;
|
||||
heading (fullText, "Symbol Duplicate Names");
|
||||
}
|
||||
String line = usage.toString ();
|
||||
line = line.substring (1, line.length () - 1);
|
||||
fullText.append (String.format ("%-6s %s%n", key, line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (basicPreferences.listStrings && stringsLine.size () > 0)
|
||||
{
|
||||
heading (fullText, " Line String");
|
||||
@ -384,6 +370,14 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
return fullText.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getMaxDigits ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
SourceLine lastLine = sourceLines.get (sourceLines.size () - 1);
|
||||
return (lastLine.lineNumber + "").length ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void heading (StringBuilder fullText, String heading)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -407,14 +401,12 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
{
|
||||
heading (fullText, heading);
|
||||
|
||||
for (Integer line : lines.keySet ())
|
||||
for (Integer key : lines.keySet ())
|
||||
{
|
||||
String lineText = line + "";
|
||||
String list = lines.get (line).toString ();
|
||||
list = list.substring (1, list.length () - 1);
|
||||
// fullText.append (String.format (" %6s %s%n", line, list));
|
||||
String lineText = key + "";
|
||||
String line = numToString (lines.get (key));
|
||||
|
||||
for (String s : splitXref (list, 90, ' '))
|
||||
for (String s : splitXref (line, 90, ' '))
|
||||
{
|
||||
fullText.append (String.format (" %6s %s%n", lineText, s));
|
||||
lineText = "";
|
||||
@ -431,9 +423,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
|
||||
for (String target : lines.keySet ())
|
||||
{
|
||||
String line = lines.get (target).toString ();
|
||||
// String line = numToString (lines.get (target));
|
||||
line = line.substring (1, line.length () - 1);
|
||||
String line = numToString (lines.get (target));
|
||||
|
||||
for (String s : splitXref (line, 90, ' '))
|
||||
{
|
||||
@ -444,16 +434,26 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String numToString (List<Integer> numbers)
|
||||
private void showDuplicates (StringBuilder fullText, Map<String, List<String>> map,
|
||||
String heading)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (".");
|
||||
|
||||
for (int number : numbers)
|
||||
text.append (String.format ("%5d, ", number));
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
||||
return text.toString ();
|
||||
boolean headingShown = false;
|
||||
for (String key : map.keySet ())
|
||||
{
|
||||
List<String> usage = map.get (key);
|
||||
if (usage.size () > 1)
|
||||
{
|
||||
if (!headingShown)
|
||||
{
|
||||
headingShown = true;
|
||||
heading (fullText, heading + " Duplicate Names");
|
||||
}
|
||||
String line = usage.toString ();
|
||||
line = line.substring (1, line.length () - 1);
|
||||
fullText.append (String.format ("%-6s %s%n", key, line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -468,9 +468,8 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
|
||||
for (String symbol : map.keySet ())
|
||||
{
|
||||
String line = map.get (symbol).toString ();
|
||||
// String line = numToString (map.get (symbol));
|
||||
line = line.substring (1, line.length () - 1);
|
||||
String line = numToString (map.get (symbol));
|
||||
|
||||
for (String s : splitXref (line, 90, ' '))
|
||||
{
|
||||
fullText.append (String.format (format, symbol, s));
|
||||
@ -479,6 +478,22 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String numToString (List<Integer> numbers)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
String format = "%" + getMaxDigits () + "d, ";
|
||||
for (int number : numbers)
|
||||
text.append (String.format (format, number));
|
||||
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getLongestName (Map<String, List<Integer>> map)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -10,22 +10,24 @@ public class SourceLine
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
ApplesoftBasicProgram parent;
|
||||
List<SubLine> sublines = new ArrayList<> ();
|
||||
int lineNumber;
|
||||
int linePtr;
|
||||
int length;
|
||||
byte[] buffer;
|
||||
|
||||
List<SubLine> sublines = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SourceLine (ApplesoftBasicProgram parent, byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.parent = parent;
|
||||
this.buffer = buffer;
|
||||
|
||||
linePtr = ptr;
|
||||
lineNumber = Utility.unsignedShort (buffer, ptr + 2);
|
||||
|
||||
int startPtr = ptr += 4;
|
||||
int startPtr = ptr += 4; // skip link to next line and lineNumber
|
||||
boolean inString = false; // can toggle
|
||||
boolean inRemark = false; // can only go false -> true
|
||||
byte b;
|
||||
|
Loading…
x
Reference in New Issue
Block a user