This commit is contained in:
Denis Molony 2021-01-11 12:59:01 +10:00
parent 8633d082b3
commit 486180e423

View File

@ -168,16 +168,25 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
public String getText () public String getText ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return showDebugText ? getHexText () : getProgramText (); if (showDebugText)
return getHexText ();
StringBuilder text =
basicPreferences.formatApplesoft ? getFormatted () : originalFormat ();
if (basicPreferences.showAllXref)
addXref (text);
while (text.length () > 0 && text.charAt (text.length () - 1) == '\n')
text.deleteCharAt (text.length () - 1);
return text.toString ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
private String getProgramText () private StringBuilder getFormatted ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (!basicPreferences.formatApplesoft)
return originalFormat ();
int indentSize = 2; int indentSize = 2;
boolean insertBlankLine = false; boolean insertBlankLine = false;
@ -340,14 +349,14 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
fullText.append ("\n"); fullText.append ("\n");
} }
if (basicPreferences.showAllXref) // if (basicPreferences.showAllXref)
addXref (fullText); // addXref (fullText);
//
// if (fullText.length () > 0)
// while (fullText.charAt (fullText.length () - 1) == '\n')
// fullText.deleteCharAt (fullText.length () - 1); // remove trailing newlines
if (fullText.length () > 0) return fullText;
while (fullText.charAt (fullText.length () - 1) == '\n')
fullText.deleteCharAt (fullText.length () - 1); // remove trailing newlines
return fullText.toString ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -929,7 +938,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
private String originalFormat () private StringBuilder originalFormat ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
@ -959,12 +968,6 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
text.append ("\n"); text.append ("\n");
} }
if (basicPreferences.showAllXref) return text;
addXref (text);
if (text.length () > 0)
text.deleteCharAt (text.length () - 1);
return text.toString ();
} }
} }