mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-30 18:31:20 +00:00
tidying
This commit is contained in:
parent
62bf355ca3
commit
9fece93d31
@ -13,8 +13,8 @@ import com.bytezone.diskbrowser.gui.BasicPreferences;
|
||||
public class AppleBasicFormatter extends BasicFormatter
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int LEFT_MARGIN = 5;
|
||||
private static final int RIGHT_MARGIN = 33;
|
||||
private final LineFormatter flatFormatter = new FlatLine ();
|
||||
private final LineFormatter wrapFormatter = new WrapLine ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public AppleBasicFormatter (ApplesoftBasicProgram program,
|
||||
@ -34,6 +34,8 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
int linkField;
|
||||
|
||||
StringBuilder currentLine = new StringBuilder ();
|
||||
LineFormatter formatter =
|
||||
basicPreferences.appleLineWrap ? wrapFormatter : flatFormatter;
|
||||
|
||||
while ((linkField = unsignedShort (buffer, ptr)) != 0)
|
||||
{
|
||||
@ -41,10 +43,7 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
currentLine.append (String.format (" %d ", lineNumber));
|
||||
ptr += 4;
|
||||
|
||||
if (basicPreferences.appleLineWrap)
|
||||
ptr = wrapLine (currentLine, ptr);
|
||||
else
|
||||
ptr = flatLine (currentLine, ptr);
|
||||
ptr = formatter.formatLine (currentLine, ptr);
|
||||
|
||||
if (ptr != (linkField - loadAddress))
|
||||
System.out.printf ("%s: ptr: %04X, nextLine: %04X%n", program.name,
|
||||
@ -57,8 +56,20 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int flatLine (StringBuilder currentLine, int ptr)
|
||||
interface LineFormatter
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
abstract int formatLine (StringBuilder currentLine, int ptr);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class FlatLine implements LineFormatter
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// -------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int formatLine (StringBuilder currentLine, int ptr)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
byte b;
|
||||
|
||||
@ -93,10 +104,19 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int wrapLine (StringBuilder currentLine, int ptr)
|
||||
class WrapLine implements LineFormatter
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int LEFT_MARGIN = 5;
|
||||
private static final int RIGHT_MARGIN = 33;
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int formatLine (StringBuilder currentLine, int ptr)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
byte b;
|
||||
int cursor = currentLine.length ();
|
||||
@ -138,9 +158,9 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// -------------------------------------------------------------------------------//
|
||||
private int incrementCursor (StringBuilder currentLine, int cursor, int size)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
assert size <= 9; // longest token possible (7 plus 2 spaces)
|
||||
cursor += size;
|
||||
@ -153,4 +173,5 @@ public class AppleBasicFormatter extends BasicFormatter
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.isDigit;
|
||||
import static com.bytezone.diskbrowser.utilities.Utility.isLetter;
|
||||
|
||||
import com.bytezone.diskbrowser.gui.BasicPreferences;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public abstract class BasicProgram extends AbstractFile
|
||||
@ -25,20 +21,4 @@ public abstract class BasicProgram extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isControlCharacter (byte value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int val = value & 0xFF;
|
||||
return val > 0 && val < 32;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isPossibleVariable (byte value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return isDigit (value) || isLetter (value) || value == Utility.ASCII_DOLLAR
|
||||
|| value == Utility.ASCII_PERCENT;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class SubLine implements ApplesoftConstants
|
||||
String forVariable = "";
|
||||
|
||||
int equalsPosition; // used for aligning the equals sign
|
||||
int endPosition; // not sure yet
|
||||
int endPosition; // not sure yet - possibly for aligning REMs
|
||||
|
||||
String functionArgument;
|
||||
String functionName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user