From 486180e4231b7a456f59151c0f2a673b3006aae2 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Mon, 11 Jan 2021 12:59:01 +1000 Subject: [PATCH] tidying --- .../applefile/ApplesoftBasicProgram.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/com/bytezone/diskbrowser/applefile/ApplesoftBasicProgram.java b/src/com/bytezone/diskbrowser/applefile/ApplesoftBasicProgram.java index e63edd1..09438c8 100644 --- a/src/com/bytezone/diskbrowser/applefile/ApplesoftBasicProgram.java +++ b/src/com/bytezone/diskbrowser/applefile/ApplesoftBasicProgram.java @@ -168,16 +168,25 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons 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; boolean insertBlankLine = false; @@ -340,14 +349,14 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons fullText.append ("\n"); } - if (basicPreferences.showAllXref) - addXref (fullText); + // if (basicPreferences.showAllXref) + // 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) - while (fullText.charAt (fullText.length () - 1) == '\n') - fullText.deleteCharAt (fullText.length () - 1); // remove trailing newlines - - return fullText.toString (); + return fullText; } // ---------------------------------------------------------------------------------// @@ -929,7 +938,7 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons } // ---------------------------------------------------------------------------------// - private String originalFormat () + private StringBuilder originalFormat () // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); @@ -959,12 +968,6 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons text.append ("\n"); } - if (basicPreferences.showAllXref) - addXref (text); - - if (text.length () > 0) - text.deleteCharAt (text.length () - 1); - - return text.toString (); + return text; } } \ No newline at end of file