split applesoft options into two groups

This commit is contained in:
Denis Molony 2021-01-11 12:01:01 +10:00
parent 18289f382c
commit 4cf1c43fee
4 changed files with 78 additions and 60 deletions

View File

@ -340,6 +340,20 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
fullText.append ("\n");
}
if (basicPreferences.showAllXref)
addXref (fullText);
if (fullText.length () > 0)
while (fullText.charAt (fullText.length () - 1) == '\n')
fullText.deleteCharAt (fullText.length () - 1); // remove trailing newlines
return fullText.toString ();
}
// ---------------------------------------------------------------------------------//
private void addXref (StringBuilder fullText)
// ---------------------------------------------------------------------------------//
{
if (basicPreferences.showSymbols && !symbolLines.isEmpty ())
showSymbolsLeft (fullText, symbolLines, "Var");
@ -374,12 +388,6 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
if (basicPreferences.showCalls && !callLines.isEmpty ())
showSymbolsLeft (fullText, callLines, "CALL");
if (fullText.length () > 0)
while (fullText.charAt (fullText.length () - 1) == '\n')
fullText.deleteCharAt (fullText.length () - 1); // remove trailing newlines
return fullText.toString ();
}
// ---------------------------------------------------------------------------------//
@ -951,6 +959,9 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
text.append ("\n");
}
if (basicPreferences.showAllXref)
addXref (text);
if (text.length () > 0)
text.deleteCharAt (text.length () - 1);

View File

@ -63,6 +63,7 @@ public class SubLine implements ApplesoftConstants
boolean inQuote = false;
boolean inFunction = false;
boolean inDefine = false;
// int functionParens = 0;
int max = startPtr + length - 1;
if (buffer[max] == 0)
@ -74,41 +75,38 @@ public class SubLine implements ApplesoftConstants
{
byte b = buffer[ptr++];
if (inDefine) // ignore the name and argument
{
if (b == TOKEN_EQUALS)
inDefine = false;
continue;
}
if (b == TOKEN_DEF)
{
inDefine = true;
continue;
}
if (inDefine) // ignore the name and argument
{
if (b == TOKEN_EQUALS)
inDefine = false;
continue;
}
if (inQuote && b != Utility.ASCII_QUOTE)
continue;
if (inFunction && b == Utility.ASCII_RIGHT_BRACKET)
{
inFunction = false;
continue;
}
if (b == TOKEN_FN)
{
assert !inDefine;
inFunction = true;
continue;
}
if (Utility.isPossibleVariable (b))
if (inQuote && b != Utility.ASCII_QUOTE) // ignore strings
continue;
if (Utility.isPossibleVariable (b)) // A-Z 0-9
var += (char) b;
else
{
if (inFunction)
{
checkFunction (var, b);
inFunction = false;
}
else
checkVar (var, b);
var = "";
@ -548,11 +546,11 @@ public class SubLine implements ApplesoftConstants
if (line.length () > 0 && line.charAt (line.length () - 1) != ' ')
line.append (' ');
int val = b & 0x7F;
if (val < ApplesoftConstants.tokens.length)
{
// if (val < ApplesoftConstants.tokens.length)
// {
if (b != TOKEN_THEN || ApplesoftBasicProgram.basicPreferences.showThen)
line.append (ApplesoftConstants.tokens[val] + " ");
}
// }
}
else if (Utility.isControlCharacter (b))
line.append (ApplesoftBasicProgram.basicPreferences.showCaret

View File

@ -6,6 +6,7 @@ public class BasicPreferences
{
public boolean showHeader = true;
public boolean formatApplesoft = true;
public boolean showAllXref = true;
public boolean splitRem = false;
public boolean alignAssign = true;
public boolean showTargets = true;
@ -41,9 +42,10 @@ public class BasicPreferences
String.format ("Only target lines ........ %s%n", onlyShowTargetLineNumbers));
text.append (String.format ("Show header .............. %s%n", showHeader));
text.append (String.format ("Format applesoft ......... %s%n", formatApplesoft));
text.append (String.format ("Show All Xref ............ %s%n", showAllXref));
text.append (String.format ("Show caret ............... %s%n", showCaret));
text.append (String.format ("Show THEN ................ %s%n", showThen));
text.append (String.format ("Show Xref ................ %s%n", showXref));
text.append (String.format ("Show GOTO/GOSUB .......... %s%n", showXref));
text.append (String.format ("Show CALL ................ %s%n", showCalls));
text.append (String.format ("Show symbols ............. %s%n", showSymbols));
text.append (String.format ("Show constants ........... %s%n", showConstants));

View File

@ -45,6 +45,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
private static final String PREFS_SHOW_HEADER = "showHeader";
private static final String PREFS_FORMAT_APPLESOFT = "formatApplesoft";
private static final String PREFS_SHOW_ALL_XREF = "showAllXref";
private static final String PREFS_SPLIT_REMARKS = "splitRemarks";
private static final String PREFS_SPLIT_DIM = "splitDim";
private static final String PREFS_ALIGN_ASSIGN = "alignAssign";
@ -94,7 +95,8 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
private final List<TextPreferencesListener> textPreferencesListeners =
new ArrayList<> ();
private List<JCheckBoxMenuItem> applesoftMenuItems;
private List<JCheckBoxMenuItem> applesoftFormatItems;
private List<JCheckBoxMenuItem> applesoftXrefItems;
JMenuBar menuBar = new JMenuBar ();
JMenu fileMenu = new JMenu ("File");
@ -142,6 +144,8 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
// Applesoft menu items
final JMenuItem showHeaderItem = new JCheckBoxMenuItem ("Show header");
final JMenuItem showFormatApplesoftItem = new JCheckBoxMenuItem ("Format Applesoft");
final JMenuItem showAllXrefItem = new JCheckBoxMenuItem ("Show XREF");
final JMenuItem splitRemarkItem = new JCheckBoxMenuItem ("Split remarks");
final JMenuItem splitDimItem = new JCheckBoxMenuItem ("Split DIM");
final JMenuItem alignAssignItem = new JCheckBoxMenuItem ("Align consecutive assign");
@ -150,6 +154,11 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
new JCheckBoxMenuItem ("Only show target line numbers");
final JMenuItem showCaretItem = new JCheckBoxMenuItem ("Show caret");
final JMenuItem showThenItem = new JCheckBoxMenuItem ("Show THEN after IF");
final JMenuItem blankAfterReturn = new JCheckBoxMenuItem ("Blank line after RETURN");
final JMenuItem deleteExtraRemSpace = new JCheckBoxMenuItem ("Delete extra REM space");
final JMenuItem deleteExtraDataSpace =
new JCheckBoxMenuItem ("Delete extra DATA space");
final JMenuItem showXrefItem = new JCheckBoxMenuItem ("List GOSUB/GOTO");
final JMenuItem showCallsItem = new JCheckBoxMenuItem ("List CALLs");
final JMenuItem showSymbolsItem = new JCheckBoxMenuItem ("List variables");
@ -158,10 +167,6 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
final JMenuItem showDuplicateSymbolsItem =
new JCheckBoxMenuItem ("List duplicate variables");
final JMenuItem listStringsItem = new JCheckBoxMenuItem ("List strings");
final JMenuItem blankAfterReturn = new JCheckBoxMenuItem ("Blank line after RETURN");
final JMenuItem deleteExtraRemSpace = new JCheckBoxMenuItem ("Delete extra REM space");
final JMenuItem deleteExtraDataSpace =
new JCheckBoxMenuItem ("Delete extra DATA space");
// Assembler menu items
final JMenuItem showAssemblerTargetsItem = new JCheckBoxMenuItem ("Show targets");
@ -252,6 +257,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
applesoftMenu.add (showHeaderItem);
applesoftMenu.add (showFormatApplesoftItem);
applesoftMenu.add (showAllXrefItem);
applesoftMenu.addSeparator ();
applesoftMenu.add (splitRemarkItem);
applesoftMenu.add (splitDimItem);
@ -281,10 +287,12 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
prodosMenu.add (prodosSortDirectoriesItem);
applesoftMenuItems = new ArrayList (Arrays.asList (splitRemarkItem, splitDimItem,
applesoftFormatItems = new ArrayList (Arrays.asList (splitRemarkItem, splitDimItem,
alignAssignItem, showBasicTargetsItem, onlyShowTargetLinesItem, showCaretItem,
showThenItem, blankAfterReturn, deleteExtraRemSpace, deleteExtraDataSpace,
showXrefItem, showCallsItem, showSymbolsItem, showFunctionsItem,
showThenItem, blankAfterReturn, deleteExtraRemSpace, deleteExtraDataSpace));
applesoftXrefItems = new ArrayList (
Arrays.asList (showXrefItem, showCallsItem, showSymbolsItem, showFunctionsItem,
showConstantsItem, listStringsItem, showDuplicateSymbolsItem));
ActionListener basicPreferencesAction = new ActionListener ()
@ -329,24 +337,10 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
showHeaderItem.addActionListener (basicPreferencesAction);
showFormatApplesoftItem.addActionListener (basicPreferencesAction);
// splitRemarkItem.addActionListener (basicPreferencesAction);
// splitDimItem.addActionListener (basicPreferencesAction);
// alignAssignItem.addActionListener (basicPreferencesAction);
// showBasicTargetsItem.addActionListener (basicPreferencesAction);
// onlyShowTargetLinesItem.addActionListener (basicPreferencesAction);
// showCaretItem.addActionListener (basicPreferencesAction);
// showThenItem.addActionListener (basicPreferencesAction);
// showXrefItem.addActionListener (basicPreferencesAction);
// showCallsItem.addActionListener (basicPreferencesAction);
// showSymbolsItem.addActionListener (basicPreferencesAction);
// showFunctionsItem.addActionListener (basicPreferencesAction);
// showConstantsItem.addActionListener (basicPreferencesAction);
// showDuplicateSymbolsItem.addActionListener (basicPreferencesAction);
// listStringsItem.addActionListener (basicPreferencesAction);
// blankAfterReturn.addActionListener (basicPreferencesAction);
// deleteExtraRemSpace.addActionListener (basicPreferencesAction);
// deleteExtraDataSpace.addActionListener (basicPreferencesAction);
for (JMenuItem item : applesoftMenuItems)
showAllXrefItem.addActionListener (basicPreferencesAction);
for (JMenuItem item : applesoftFormatItems)
item.addActionListener (basicPreferencesAction);
for (JMenuItem item : applesoftXrefItems)
item.addActionListener (basicPreferencesAction);
showAssemblerTargetsItem.addActionListener (assemblerPreferencesAction);
@ -384,10 +378,18 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
}
// ---------------------------------------------------------------------------------//
private void enableApplesoftMenuItems (boolean value)
private void enableApplesoftFormatItems (boolean value)
// ---------------------------------------------------------------------------------//
{
for (JMenuItem item : applesoftMenuItems)
for (JMenuItem item : applesoftFormatItems)
item.setEnabled (value);
}
// ---------------------------------------------------------------------------------//
private void enableAllXrefItems (boolean value)
// ---------------------------------------------------------------------------------//
{
for (JMenuItem item : applesoftXrefItems)
item.setEnabled (value);
}
@ -397,6 +399,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
{
basicPreferences.showHeader = showHeaderItem.isSelected ();
basicPreferences.formatApplesoft = showFormatApplesoftItem.isSelected ();
basicPreferences.showAllXref = showAllXrefItem.isSelected ();
basicPreferences.splitRem = splitRemarkItem.isSelected ();
basicPreferences.splitDim = splitDimItem.isSelected ();
@ -415,9 +418,11 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
basicPreferences.deleteExtraDataSpace = deleteExtraDataSpace.isSelected ();
basicPreferences.showTargets = showBasicTargetsItem.isSelected ();
basicPreferences.onlyShowTargetLineNumbers = onlyShowTargetLinesItem.isSelected ();
BasicProgram.setBasicPreferences (basicPreferences);
enableApplesoftMenuItems (basicPreferences.formatApplesoft);
enableApplesoftFormatItems (basicPreferences.formatApplesoft);
enableAllXrefItems (basicPreferences.showAllXref);
}
// ---------------------------------------------------------------------------------//
@ -565,6 +570,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
prefs.putBoolean (PREFS_SHOW_HEADER, showHeaderItem.isSelected ());
prefs.putBoolean (PREFS_FORMAT_APPLESOFT, showFormatApplesoftItem.isSelected ());
prefs.putBoolean (PREFS_SHOW_ALL_XREF, showAllXrefItem.isSelected ());
prefs.putBoolean (PREFS_SPLIT_REMARKS, splitRemarkItem.isSelected ());
prefs.putBoolean (PREFS_SPLIT_DIM, splitDimItem.isSelected ());
@ -625,6 +631,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
showHeaderItem.setSelected (prefs.getBoolean (PREFS_SHOW_HEADER, true));
showFormatApplesoftItem.setSelected (prefs.getBoolean (PREFS_FORMAT_APPLESOFT, true));
showAllXrefItem.setSelected (prefs.getBoolean (PREFS_SHOW_ALL_XREF, true));
splitRemarkItem.setSelected (prefs.getBoolean (PREFS_SPLIT_REMARKS, false));
splitDimItem.setSelected (prefs.getBoolean (PREFS_SPLIT_DIM, false));