mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-14 12:29:34 +00:00
tidying
This commit is contained in:
parent
903ec192e2
commit
e3eb32d493
|
@ -328,9 +328,6 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
// Add the current text, then reset it
|
// Add the current text, then reset it
|
||||||
String lineText = subline.getAlignedText (alignEqualsPos);
|
String lineText = subline.getAlignedText (alignEqualsPos);
|
||||||
|
|
||||||
// if (subline.is (TOKEN_REM) && basicPreferences.deleteExtraRemSpace)
|
|
||||||
// lineText = lineText.replaceFirst ("REM ", "REM ");
|
|
||||||
|
|
||||||
if (subline.is (TOKEN_DATA) && basicPreferences.deleteExtraDataSpace)
|
if (subline.is (TOKEN_DATA) && basicPreferences.deleteExtraDataSpace)
|
||||||
lineText = lineText.replaceFirst ("DATA ", "DATA ");
|
lineText = lineText.replaceFirst ("DATA ", "DATA ");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,18 @@
|
||||||
package com.bytezone.diskbrowser.applefile;
|
package com.bytezone.diskbrowser.applefile;
|
||||||
|
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_BACKSPACE;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_COLON;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_COMMA;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_CR;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_DOLLAR;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_LEFT_BRACKET;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_LF;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_MINUS;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_PERCENT;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_QUOTE;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.ASCII_RIGHT_BRACKET;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.getIndent;
|
||||||
|
import static com.bytezone.diskbrowser.utilities.Utility.isControlCharacter;
|
||||||
import static com.bytezone.diskbrowser.utilities.Utility.isDigit;
|
import static com.bytezone.diskbrowser.utilities.Utility.isDigit;
|
||||||
import static com.bytezone.diskbrowser.utilities.Utility.isHighBitSet;
|
import static com.bytezone.diskbrowser.utilities.Utility.isHighBitSet;
|
||||||
import static com.bytezone.diskbrowser.utilities.Utility.isLetter;
|
import static com.bytezone.diskbrowser.utilities.Utility.isLetter;
|
||||||
|
@ -9,8 +22,7 @@ import static com.bytezone.diskbrowser.utilities.Utility.isPossibleVariable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class SubLine implements ApplesoftConstants
|
public class SubLine implements ApplesoftConstants
|
||||||
|
@ -121,7 +133,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
|
|
||||||
if (inQuote)
|
if (inQuote)
|
||||||
{
|
{
|
||||||
if (b == Utility.ASCII_QUOTE) // ignore strings
|
if (b == ASCII_QUOTE) // ignore strings
|
||||||
{
|
{
|
||||||
inQuote = false;
|
inQuote = false;
|
||||||
addString (stringPtr, ptr);
|
addString (stringPtr, ptr);
|
||||||
|
@ -129,7 +141,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b == Utility.ASCII_QUOTE)
|
if (b == ASCII_QUOTE)
|
||||||
{
|
{
|
||||||
inQuote = true;
|
inQuote = true;
|
||||||
stringPtr = ptr;
|
stringPtr = ptr;
|
||||||
|
@ -144,8 +156,8 @@ public class SubLine implements ApplesoftConstants
|
||||||
var += (char) b;
|
var += (char) b;
|
||||||
|
|
||||||
// allow for PRINT A$B$
|
// allow for PRINT A$B$
|
||||||
if ((b == Utility.ASCII_DOLLAR || b == Utility.ASCII_PERCENT) // var name end
|
if ((b == ASCII_DOLLAR || b == ASCII_PERCENT) // var name end
|
||||||
&& buffer[ptr] != Utility.ASCII_LEFT_BRACKET) // not an array
|
&& buffer[ptr] != ASCII_LEFT_BRACKET) // not an array
|
||||||
{
|
{
|
||||||
checkVar (var, b);
|
checkVar (var, b);
|
||||||
var = "";
|
var = "";
|
||||||
|
@ -175,7 +187,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
private boolean isEndOfLine (byte b)
|
private boolean isEndOfLine (byte b)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return b == 0 || b == Utility.ASCII_COLON;
|
return b == 0 || b == ASCII_COLON;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -189,7 +201,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
private void checkFunction (String var, byte terminator)
|
private void checkFunction (String var, byte terminator)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert terminator == Utility.ASCII_LEFT_BRACKET;
|
assert terminator == ASCII_LEFT_BRACKET;
|
||||||
|
|
||||||
if (!functions.contains (var))
|
if (!functions.contains (var))
|
||||||
functions.add (var);
|
functions.add (var);
|
||||||
|
@ -213,7 +225,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
if (is (TOKEN_DEF) && (var.equals (functionName) || var.equals (functionArgument)))
|
if (is (TOKEN_DEF) && (var.equals (functionName) || var.equals (functionArgument)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (terminator == Utility.ASCII_LEFT_BRACKET)
|
if (terminator == ASCII_LEFT_BRACKET)
|
||||||
{
|
{
|
||||||
if (!arrays.contains (var))
|
if (!arrays.contains (var))
|
||||||
arrays.add (var);
|
arrays.add (var);
|
||||||
|
@ -261,8 +273,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
case TOKEN_ON:
|
case TOKEN_ON:
|
||||||
p = startPtr + 1;
|
p = startPtr + 1;
|
||||||
int max = startPtr + length - 1;
|
int max = startPtr + length - 1;
|
||||||
while (p < max && buffer[p] != ApplesoftConstants.TOKEN_GOTO
|
while (p < max && buffer[p] != TOKEN_GOTO && buffer[p] != TOKEN_GOSUB)
|
||||||
&& buffer[p] != ApplesoftConstants.TOKEN_GOSUB)
|
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
switch (buffer[p++])
|
switch (buffer[p++])
|
||||||
|
@ -283,7 +294,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKEN_ONERR:
|
case TOKEN_ONERR:
|
||||||
if (buffer[startPtr + 1] == ApplesoftConstants.TOKEN_GOTO)
|
if (buffer[startPtr + 1] == TOKEN_GOTO)
|
||||||
{
|
{
|
||||||
targetLine = getLineNumber (buffer, startPtr + 2);
|
targetLine = getLineNumber (buffer, startPtr + 2);
|
||||||
addXref (targetLine, gotoLines);
|
addXref (targetLine, gotoLines);
|
||||||
|
@ -298,9 +309,8 @@ public class SubLine implements ApplesoftConstants
|
||||||
byte[] lineBuffer = getBuffer ();
|
byte[] lineBuffer = getBuffer ();
|
||||||
assert lineBuffer[0] == TOKEN_FN;
|
assert lineBuffer[0] == TOKEN_FN;
|
||||||
|
|
||||||
int leftBracket = getPosition (lineBuffer, 1, Utility.ASCII_LEFT_BRACKET);
|
int leftBracket = getPosition (lineBuffer, 1, ASCII_LEFT_BRACKET);
|
||||||
int rightBracket =
|
int rightBracket = getPosition (lineBuffer, leftBracket + 1, ASCII_RIGHT_BRACKET);
|
||||||
getPosition (lineBuffer, leftBracket + 1, Utility.ASCII_RIGHT_BRACKET);
|
|
||||||
|
|
||||||
functionName = new String (lineBuffer, 1, leftBracket - 1);
|
functionName = new String (lineBuffer, 1, leftBracket - 1);
|
||||||
functionArgument =
|
functionArgument =
|
||||||
|
@ -316,7 +326,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
if (chunk.isEmpty ())
|
if (chunk.isEmpty ())
|
||||||
continue;
|
continue;
|
||||||
b = (byte) chunk.charAt (0);
|
b = (byte) chunk.charAt (0);
|
||||||
if (isPossibleNumber (b) || b == Utility.ASCII_MINUS)
|
if (isPossibleNumber (b) || b == ASCII_MINUS)
|
||||||
{
|
{
|
||||||
if (!addNumber (chunk))
|
if (!addNumber (chunk))
|
||||||
stringsText.add (chunk);
|
stringsText.add (chunk);
|
||||||
|
@ -369,7 +379,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
byte b = buffer[ptr++];
|
byte b = buffer[ptr++];
|
||||||
if (isToken (b))
|
if (isToken (b))
|
||||||
text.append (tokens[b & 0x7F]);
|
text.append (tokens[b & 0x7F]);
|
||||||
else if (b == Utility.ASCII_COMMA) // end of call target
|
else if (b == ASCII_COMMA) // end of call target
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
text.append ((char) b);
|
text.append ((char) b);
|
||||||
|
@ -404,7 +414,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
List<Integer> lineNumbers = new ArrayList<> ();
|
List<Integer> lineNumbers = new ArrayList<> ();
|
||||||
int start = ptr;
|
int start = ptr;
|
||||||
|
|
||||||
while (ptr < buffer.length && buffer[ptr] != 0 && buffer[ptr] != Utility.ASCII_COLON)
|
while (ptr < buffer.length && buffer[ptr] != 0 && buffer[ptr] != ASCII_COLON)
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
String s = new String (buffer, start, ptr - start);
|
String s = new String (buffer, start, ptr - start);
|
||||||
|
@ -554,17 +564,17 @@ public class SubLine implements ApplesoftConstants
|
||||||
{
|
{
|
||||||
switch (buffer[ptr])
|
switch (buffer[ptr])
|
||||||
{
|
{
|
||||||
case Utility.ASCII_BACKSPACE:
|
case ASCII_BACKSPACE:
|
||||||
if (text.length () > 0)
|
if (text.length () > 0)
|
||||||
text.deleteCharAt (text.length () - 1);
|
text.deleteCharAt (text.length () - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Utility.ASCII_CR:
|
case ASCII_CR:
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Utility.ASCII_LF:
|
case ASCII_LF:
|
||||||
int indent = Utility.getIndent (text);
|
int indent = getIndent (text);
|
||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
for (int i = 0; i < indent; i++)
|
for (int i = 0; i < indent; i++)
|
||||||
text.append (" ");
|
text.append (" ");
|
||||||
|
@ -583,7 +593,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
while (ptr < max)
|
while (ptr < max)
|
||||||
if (buffer[ptr++] == Utility.ASCII_BACKSPACE)
|
if (buffer[ptr++] == ASCII_BACKSPACE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -608,7 +618,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int len = length - 1;
|
int len = length - 1;
|
||||||
if (buffer[startPtr + len] == Utility.ASCII_COLON || buffer[startPtr + len] == 0)
|
if (buffer[startPtr + len] == ASCII_COLON || buffer[startPtr + len] == 0)
|
||||||
len--;
|
len--;
|
||||||
byte[] buffer2 = new byte[len];
|
byte[] buffer2 = new byte[len];
|
||||||
System.arraycopy (buffer, startPtr + 1, buffer2, 0, buffer2.length);
|
System.arraycopy (buffer, startPtr + 1, buffer2, 0, buffer2.length);
|
||||||
|
@ -704,10 +714,10 @@ public class SubLine implements ApplesoftConstants
|
||||||
if (b != TOKEN_THEN || ApplesoftBasicProgram.basicPreferences.showThen)
|
if (b != TOKEN_THEN || ApplesoftBasicProgram.basicPreferences.showThen)
|
||||||
line.append (ApplesoftConstants.tokens[val] + " ");
|
line.append (ApplesoftConstants.tokens[val] + " ");
|
||||||
}
|
}
|
||||||
else if (Utility.isControlCharacter (b))
|
// else if (Utility.isControlCharacter (b))
|
||||||
line.append (ApplesoftBasicProgram.basicPreferences.showCaret
|
// line.append (ApplesoftBasicProgram.basicPreferences.showCaret
|
||||||
? "^" + (char) (b + 64) : "?");
|
// ? "^" + (char) (b + 64) : "?");
|
||||||
else
|
else if (!isControlCharacter (b))
|
||||||
line.append ((char) b);
|
line.append ((char) b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,22 +10,19 @@ public class BasicPreferences
|
||||||
public boolean appleLineWrap = false;
|
public boolean appleLineWrap = false;
|
||||||
public boolean splitRem = false;
|
public boolean splitRem = false;
|
||||||
public boolean alignAssign = true;
|
public boolean alignAssign = true;
|
||||||
// public boolean showTargets = true;
|
|
||||||
// public boolean onlyShowTargetLineNumbers = true;
|
|
||||||
public boolean showCaret = false;
|
public boolean showCaret = false;
|
||||||
public boolean showThen = true;
|
public boolean showThen = true;
|
||||||
public boolean blankAfterReturn = false;
|
public boolean blankAfterReturn = false;
|
||||||
public boolean formatRem = false;
|
public boolean formatRem = false;
|
||||||
// public boolean deleteExtraRemSpace = false;
|
|
||||||
public boolean deleteExtraDataSpace = false;
|
public boolean deleteExtraDataSpace = false;
|
||||||
public boolean showXref = false;
|
public boolean showXref = false;
|
||||||
public boolean showCalls = false;
|
public boolean showCalls = false;
|
||||||
public boolean showSymbols = false;
|
public boolean showSymbols = false;
|
||||||
public boolean showConstants = false;
|
public boolean showConstants = false;
|
||||||
// public boolean listStrings = false;
|
|
||||||
public boolean showFunctions = false;
|
public boolean showFunctions = false;
|
||||||
public boolean showDuplicateSymbols = false;
|
public boolean showDuplicateSymbols = false;
|
||||||
public boolean splitDim = false;
|
public boolean splitDim = false;
|
||||||
|
|
||||||
public int wrapPrintAt = 0;
|
public int wrapPrintAt = 0;
|
||||||
public int wrapRemAt = 80;
|
public int wrapRemAt = 80;
|
||||||
public int wrapDataAt = 80;
|
public int wrapDataAt = 80;
|
||||||
|
@ -39,9 +36,6 @@ public class BasicPreferences
|
||||||
|
|
||||||
text.append (String.format ("Split REM ................ %s%n", splitRem));
|
text.append (String.format ("Split REM ................ %s%n", splitRem));
|
||||||
text.append (String.format ("Align assign ............. %s%n", alignAssign));
|
text.append (String.format ("Align assign ............. %s%n", alignAssign));
|
||||||
// text.append (String.format ("Show targets ............. %s%n", showTargets));
|
|
||||||
// text.append (
|
|
||||||
// String.format ("Only target lines ........ %s%n", onlyShowTargetLineNumbers));
|
|
||||||
text.append (String.format ("Show header .............. %s%n", showHeader));
|
text.append (String.format ("Show header .............. %s%n", showHeader));
|
||||||
text.append (String.format ("Format applesoft ......... %s%n", formatApplesoft));
|
text.append (String.format ("Format applesoft ......... %s%n", formatApplesoft));
|
||||||
text.append (String.format ("Show All Xref ............ %s%n", showAllXref));
|
text.append (String.format ("Show All Xref ............ %s%n", showAllXref));
|
||||||
|
@ -54,10 +48,8 @@ public class BasicPreferences
|
||||||
text.append (String.format ("Show constants ........... %s%n", showConstants));
|
text.append (String.format ("Show constants ........... %s%n", showConstants));
|
||||||
text.append (String.format ("Show functions ........... %s%n", showFunctions));
|
text.append (String.format ("Show functions ........... %s%n", showFunctions));
|
||||||
text.append (String.format ("Show duplicate symbols ... %s%n", showDuplicateSymbols));
|
text.append (String.format ("Show duplicate symbols ... %s%n", showDuplicateSymbols));
|
||||||
// text.append (String.format ("List strings ............. %s%n", listStrings));
|
|
||||||
text.append (String.format ("Blank after RETURN ....... %s%n", blankAfterReturn));
|
text.append (String.format ("Blank after RETURN ....... %s%n", blankAfterReturn));
|
||||||
text.append (String.format ("Format REM ............... %s%n", formatRem));
|
text.append (String.format ("Format REM ............... %s%n", formatRem));
|
||||||
// text.append (String.format ("Delete extra REM space ... %s%n", deleteExtraRemSpace));
|
|
||||||
text.append (String.format ("Delete extra DATA space .. %s%n", deleteExtraDataSpace));
|
text.append (String.format ("Delete extra DATA space .. %s%n", deleteExtraDataSpace));
|
||||||
text.append (String.format ("Wrap PRINT at ............ %d%n", wrapPrintAt));
|
text.append (String.format ("Wrap PRINT at ............ %d%n", wrapPrintAt));
|
||||||
text.append (String.format ("Wrap REM at .............. %d%n", wrapRemAt));
|
text.append (String.format ("Wrap REM at .............. %d%n", wrapRemAt));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user