wrap print lines at 80 columns

This commit is contained in:
Denis Molony 2021-05-06 18:14:40 +10:00
parent 76b2d4a291
commit d6d0b1672e
7 changed files with 30 additions and 29 deletions

View File

@ -21,6 +21,8 @@ public class UserBasicFormatter extends BasicFormatter
private static final int INDENT_SIZE = 2;
private static final String EIGHT_SPACES = " ";
private static final String FOUR_SPACES = " ";
private static boolean FORCE = true;
private static boolean NO_FORCE = false;
// ---------------------------------------------------------------------------------//
public UserBasicFormatter (ApplesoftBasicProgram program,
@ -112,13 +114,22 @@ public class UserBasicFormatter extends BasicFormatter
int inset = Math.max (text.length (), getIndent (fullText)) + 1;
if (subline.is (TOKEN_REM) && lineText.length () > basicPreferences.wrapRemAt)
{
List<String> lines = splitLine (lineText, basicPreferences.wrapRemAt, ' ');
List<String> lines =
splitLine (lineText, basicPreferences.wrapRemAt, ' ', FORCE);
addSplitLines (lines, text, inset);
}
else if (subline.is (TOKEN_DATA)
&& lineText.length () > basicPreferences.wrapDataAt)
{
List<String> lines = splitLine (lineText, basicPreferences.wrapDataAt, ',');
List<String> lines =
splitLine (lineText, basicPreferences.wrapDataAt, ',', FORCE);
addSplitLines (lines, text, inset);
}
else if (subline.is (TOKEN_PRINT)
&& lineText.length () > basicPreferences.wrapPrintAt)
{
List<String> lines =
splitLine (lineText, basicPreferences.wrapDataAt, ';', NO_FORCE);
addSplitLines (lines, text, inset);
}
else if (subline.is (TOKEN_DIM) && basicPreferences.splitDim)
@ -162,7 +173,8 @@ public class UserBasicFormatter extends BasicFormatter
}
// ---------------------------------------------------------------------------------//
private List<String> splitLine (String line, int wrapLength, char breakChar)
private List<String> splitLine (String line, int wrapLength, char breakChar,
boolean force)
// ---------------------------------------------------------------------------------//
{
int spaceAt = 0;
@ -182,9 +194,10 @@ public class UserBasicFormatter extends BasicFormatter
break;
lines.add (line.substring (0, breakAt + 1)); // keep breakChar at end
line = indent + line.substring (breakAt + 1);
line = indent + line.substring (breakAt + 1).trim ();
}
if (force)
while (line.length () > wrapLength) // no breakChars found
{
lines.add (line.substring (0, wrapLength));

View File

@ -114,7 +114,6 @@ public class AppleDisk implements Disk
if ("2mg".equalsIgnoreCase (suffix) || "2IMG".equals (prefix))
{
// System.out.println ("checking 2mg");
if ("2IMG".equals (prefix))
{
Prefix2mg prefix2mg = new Prefix2mg (buffer);

View File

@ -51,19 +51,6 @@ public class DiskFactory
// ---------------------------------------------------------------------------------//
public static FormattedDisk createDisk (String pathName)
// ---------------------------------------------------------------------------------//
{
FormattedDisk disk = create (pathName);
// if (disk.getDisk ().getInterleave () > 0)
// {
// System.out.println (disk);
// System.out.println ();
// }
return disk;
}
// ---------------------------------------------------------------------------------//
private static FormattedDisk create (String pathName)
// ---------------------------------------------------------------------------------//
{
if (debug)
System.out.println ("\nFactory : " + pathName);

View File

@ -82,6 +82,3 @@ public interface FormattedDisk
public String getName ();
}
// getFileTypeList ()
// getFiles (FileType type)

View File

@ -26,7 +26,7 @@ public class BasicPreferences
public boolean showConstants = false;
public boolean showDuplicateSymbols = false;
public int wrapPrintAt = 0;
public int wrapPrintAt = 80;
public int wrapRemAt = 80;
public int wrapDataAt = 80;

View File

@ -6,7 +6,10 @@ import java.time.LocalDateTime;
public class Binary2Header
// -----------------------------------------------------------------------------------//
{
static String[] osTypes = { "Prodos", "DOS 3.3", "Pascal", "CPM", "MS-DOS" };
static String[] osTypes =
{ "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal", "Macintosh MFS",
"Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
"ISO 9660 (CD-ROM)", "AppleShare" };
int accessCode;
int fileType;

View File

@ -29,6 +29,8 @@ class MasterHeader
{
if (Utility.isMagic (buffer, ptr, NuFile))
break;
// internet.shk has 0x2000 bytes of text at the start
// if (Utility.isMagic (buffer, 0x2000, NuFile))
// {
// System.out.println ("found it");