mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-13 06:29:31 +00:00
wrap DATA lines
This commit is contained in:
parent
54d04ea575
commit
e2e4b554e7
|
@ -15,6 +15,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
{
|
||||
private static final byte TOKEN_FOR = (byte) 0x81;
|
||||
private static final byte TOKEN_NEXT = (byte) 0x82;
|
||||
private static final byte TOKEN_DATA = (byte) 0x83;
|
||||
private static final byte TOKEN_INPUT = (byte) 0x84;
|
||||
private static final byte TOKEN_LET = (byte) 0xAA;
|
||||
private static final byte TOKEN_GOTO = (byte) 0xAB;
|
||||
|
@ -131,23 +132,16 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
|
||||
// Check for a wrappable REM statement
|
||||
// (see SEA BATTLE on DISK283.DSK)
|
||||
if (subline.is (TOKEN_REM) && lineText.length () > basicPreferences.wrapRemAt + 4)
|
||||
if (subline.is (TOKEN_REM) && lineText.length () > basicPreferences.wrapRemAt)
|
||||
{
|
||||
String copy = lineText.substring (4);
|
||||
text.append ("REM ");
|
||||
int inset = text.length () + 1;
|
||||
List<String> remarks = splitRemark (copy, basicPreferences.wrapRemAt);
|
||||
boolean first = true;
|
||||
for (String remark : remarks)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
text.append (remark);
|
||||
}
|
||||
else
|
||||
text.append ("\n ".substring (0, inset) + remark);
|
||||
}
|
||||
List<String> lines = splitLine (lineText, basicPreferences.wrapRemAt, ' ');
|
||||
addSplitLines (lines, text);
|
||||
}
|
||||
else if (subline.is (TOKEN_DATA)
|
||||
&& lineText.length () > basicPreferences.wrapDataAt)
|
||||
{
|
||||
List<String> lines = splitLine (lineText, basicPreferences.wrapDataAt, ',');
|
||||
addSplitLines (lines, text);
|
||||
}
|
||||
else
|
||||
text.append (lineText);
|
||||
|
@ -279,24 +273,47 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private List<String> splitRemark (String remark, int wrapLength)
|
||||
private List<String> splitLine (String line, int wrapLength, char breakChar)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int firstSpace = 0;
|
||||
while (firstSpace < line.length () && line.charAt (firstSpace) != ' ')
|
||||
++firstSpace;
|
||||
|
||||
List<String> remarks = new ArrayList<> ();
|
||||
while (remark.length () > wrapLength)
|
||||
while (line.length () > wrapLength)
|
||||
{
|
||||
int max = Math.min (wrapLength, remark.length () - 1);
|
||||
while (max > 0 && remark.charAt (max) != ' ')
|
||||
int max = Math.min (wrapLength, line.length () - 1);
|
||||
while (max > 0 && line.charAt (max) != breakChar)
|
||||
--max;
|
||||
if (max == 0)
|
||||
break;
|
||||
remarks.add (remark.substring (0, max));
|
||||
remark = remark.substring (max);
|
||||
remarks.add (line.substring (0, max + 1));
|
||||
line = " ".substring (0, firstSpace + 1) + line.substring (max + 1);
|
||||
}
|
||||
remarks.add (remark);
|
||||
remarks.add (line);
|
||||
return remarks;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addSplitLines (List<String> lines, StringBuilder text)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int inset = text.length () + 1;
|
||||
boolean first = true;
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
text.append (line);
|
||||
}
|
||||
else
|
||||
text.append ("\n ".substring (0, inset) + line);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int countChars (StringBuilder text, byte ch)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -18,7 +18,6 @@ import com.bytezone.diskbrowser.applefile.MerlinSource;
|
|||
import com.bytezone.diskbrowser.applefile.OriginalHiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.PrintShopGraphic;
|
||||
import com.bytezone.diskbrowser.applefile.ShapeTable;
|
||||
import com.bytezone.diskbrowser.applefile.SimpleText2;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
|
@ -81,7 +80,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
fileType = FileType.AA;
|
||||
// else if ((type == 0x40)) // Lisa
|
||||
else
|
||||
fileType = FileType.BB;
|
||||
fileType = FileType.Binary;
|
||||
// else
|
||||
// {
|
||||
// System.out.println ("Unknown file type : " + type);
|
||||
|
@ -250,6 +249,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
|
||||
case Binary: // binary file
|
||||
case Relocatable: // relocatable binary file
|
||||
case BB:
|
||||
int loadAddress = Utility.unsignedShort (buffer, 0);
|
||||
reportedLength = Utility.unsignedShort (buffer, 2);
|
||||
if (reportedLength == 0)
|
||||
|
@ -330,13 +330,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
appleFile = new DefaultAppleFile (name, buffer);
|
||||
break;
|
||||
|
||||
case BB: // Lisa
|
||||
loadAddress = Utility.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = Utility.intValue (buffer[2], buffer[3]);
|
||||
exactBuffer = new byte[Math.min (buffer.length - 4, reportedLength)];
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
|
||||
appleFile = new SimpleText2 (name, exactBuffer, loadAddress);
|
||||
break;
|
||||
// case BB: // Lisa
|
||||
// loadAddress = Utility.intValue (buffer[0], buffer[1]);
|
||||
// appleFile = new SimpleText2 (name, getExactBuffer (buffer), loadAddress);
|
||||
// break;
|
||||
|
||||
default:
|
||||
System.out.println ("Unknown file type : " + fileType);
|
||||
|
|
|
@ -13,6 +13,7 @@ public class BasicPreferences
|
|||
public boolean showThen = true;
|
||||
public int wrapPrintAt = 0;
|
||||
public int wrapRemAt = 60;
|
||||
public int wrapDataAt = 60;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
|
@ -28,7 +29,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 ("Show caret ............ %s%n", showCaret));
|
||||
text.append (String.format ("Show THEN ............. %s", showThen));
|
||||
text.append (String.format ("Show THEN ............. %s%n", showThen));
|
||||
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 DATA at ......... %d", wrapDataAt));
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user