mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-08 19:29:27 +00:00
Added text preferences
This commit is contained in:
parent
67349bf999
commit
92824e5db6
|
@ -9,7 +9,9 @@ import java.util.Stack;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class ApplesoftBasicProgram extends BasicProgram
|
public class ApplesoftBasicProgram extends BasicProgram
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final byte TOKEN_FOR = (byte) 0x81;
|
private static final byte TOKEN_FOR = (byte) 0x81;
|
||||||
private static final byte TOKEN_NEXT = (byte) 0x82;
|
private static final byte TOKEN_NEXT = (byte) 0x82;
|
||||||
|
@ -28,7 +30,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
private final Set<Integer> gotoLines = new HashSet<> ();
|
private final Set<Integer> gotoLines = new HashSet<> ();
|
||||||
private final Set<Integer> gosubLines = new HashSet<> ();
|
private final Set<Integer> gosubLines = new HashSet<> ();
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public ApplesoftBasicProgram (String name, byte[] buffer)
|
public ApplesoftBasicProgram (String name, byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
|
|
||||||
|
@ -50,8 +54,10 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
endPtr = ptr;
|
endPtr = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder fullText = new StringBuilder ();
|
StringBuilder fullText = new StringBuilder ();
|
||||||
Stack<String> loopVariables = new Stack<String> ();
|
Stack<String> loopVariables = new Stack<String> ();
|
||||||
|
@ -228,7 +234,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return fullText.toString ();
|
return fullText.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private List<String> splitPrint (String line)
|
private List<String> splitPrint (String line)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int first = line.indexOf ("\"") + 1;
|
int first = line.indexOf ("\"") + 1;
|
||||||
int last = line.indexOf ("\"", first + 1) - 1;
|
int last = line.indexOf ("\"", first + 1) - 1;
|
||||||
|
@ -271,7 +279,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private List<String> splitRemark (String remark, int wrapLength)
|
private List<String> splitRemark (String remark, int wrapLength)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<String> remarks = new ArrayList<> ();
|
List<String> remarks = new ArrayList<> ();
|
||||||
while (remark.length () > wrapLength)
|
while (remark.length () > wrapLength)
|
||||||
|
@ -288,7 +298,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return remarks;
|
return remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int countChars (StringBuilder text, byte ch)
|
private int countChars (StringBuilder text, byte ch)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < text.length (); i++)
|
for (int i = 0; i < text.length (); i++)
|
||||||
|
@ -297,7 +309,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getBase (SourceLine line)
|
private String getBase (SourceLine line)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (!basicPreferences.showTargets)
|
if (!basicPreferences.showTargets)
|
||||||
return String.format (" %5d", line.lineNumber);
|
return String.format (" %5d", line.lineNumber);
|
||||||
|
@ -324,7 +338,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
|
|
||||||
// Decide whether the current subline needs to be aligned on its equals sign. If so,
|
// Decide whether the current subline needs to be aligned on its equals sign. If so,
|
||||||
// and the column hasn't been calculated, read ahead to find the highest position.
|
// and the column hasn't been calculated, read ahead to find the highest position.
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int alignEqualsPosition (SubLine subline, int currentAlignPosition)
|
private int alignEqualsPosition (SubLine subline, int currentAlignPosition)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (subline.assignEqualPos > 0) // does the line have an equals sign?
|
if (subline.assignEqualPos > 0) // does the line have an equals sign?
|
||||||
{
|
{
|
||||||
|
@ -337,7 +353,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
|
|
||||||
// The IF processing is so that any assignment that is being aligned doesn't continue
|
// The IF processing is so that any assignment that is being aligned doesn't continue
|
||||||
// to the next full line (because the indentation has changed).
|
// to the next full line (because the indentation has changed).
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int findHighest (SubLine startSubline)
|
private int findHighest (SubLine startSubline)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
int highestAssign = startSubline.assignEqualPos;
|
int highestAssign = startSubline.assignEqualPos;
|
||||||
|
@ -369,8 +387,10 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return highestAssign;
|
return highestAssign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getHexDump ()
|
public String getHexDump ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (buffer.length < 2)
|
if (buffer.length < 2)
|
||||||
return super.getHexDump ();
|
return super.getHexDump ();
|
||||||
|
@ -412,14 +432,18 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return pgm.toString ();
|
return pgm.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addHeader (StringBuilder pgm)
|
private void addHeader (StringBuilder pgm)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
pgm.append ("Name : " + name + "\n");
|
pgm.append ("Name : " + name + "\n");
|
||||||
pgm.append (String.format ("Length : $%04X (%<,d)%n", buffer.length));
|
pgm.append (String.format ("Length : $%04X (%<,d)%n", buffer.length));
|
||||||
pgm.append (String.format ("Load at : $%04X (%<,d)%n%n", getLoadAddress ()));
|
pgm.append (String.format ("Load at : $%04X (%<,d)%n%n", getLoadAddress ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int getLoadAddress ()
|
private int getLoadAddress ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int programLoadAddress = 0;
|
int programLoadAddress = 0;
|
||||||
if (buffer.length > 1)
|
if (buffer.length > 1)
|
||||||
|
@ -430,7 +454,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return programLoadAddress;
|
return programLoadAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int getLineLength (int ptr)
|
private int getLineLength (int ptr)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int offset = Utility.unsignedShort (buffer, ptr);
|
int offset = Utility.unsignedShort (buffer, ptr);
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
|
@ -444,7 +470,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void popLoopVariables (Stack<String> loopVariables, SubLine subline)
|
private void popLoopVariables (Stack<String> loopVariables, SubLine subline)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (subline.nextVariables.length == 0) // naked NEXT
|
if (subline.nextVariables.length == 0) // naked NEXT
|
||||||
{
|
{
|
||||||
|
@ -459,7 +487,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private boolean sameVariable (String v1, String v2)
|
private boolean sameVariable (String v1, String v2)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (v1.equals (v2))
|
if (v1.equals (v2))
|
||||||
return true;
|
return true;
|
||||||
|
@ -469,7 +499,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private class SourceLine
|
private class SourceLine
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<SubLine> sublines = new ArrayList<> ();
|
List<SubLine> sublines = new ArrayList<> ();
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
|
@ -548,7 +580,9 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private class SubLine
|
private class SubLine
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
SourceLine parent;
|
SourceLine parent;
|
||||||
int startPtr;
|
int startPtr;
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.applefile;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.gui.BasicPreferences;
|
import com.bytezone.diskbrowser.gui.BasicPreferences;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public abstract class BasicProgram extends AbstractFile
|
public abstract class BasicProgram extends AbstractFile
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final byte ASCII_QUOTE = 0x22;
|
static final byte ASCII_QUOTE = 0x22;
|
||||||
static final byte ASCII_COLON = 0x3A;
|
static final byte ASCII_COLON = 0x3A;
|
||||||
|
@ -11,28 +13,38 @@ public abstract class BasicProgram extends AbstractFile
|
||||||
|
|
||||||
static BasicPreferences basicPreferences; // set by MenuHandler
|
static BasicPreferences basicPreferences; // set by MenuHandler
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public static void setBasicPreferences (BasicPreferences basicPreferences)
|
public static void setBasicPreferences (BasicPreferences basicPreferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
BasicProgram.basicPreferences = basicPreferences;
|
BasicProgram.basicPreferences = basicPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public BasicProgram (String name, byte[] buffer)
|
public BasicProgram (String name, byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isHighBitSet (byte value)
|
boolean isHighBitSet (byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return (value & 0x80) != 0;
|
return (value & 0x80) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isControlCharacter (byte value)
|
boolean isControlCharacter (byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int val = value & 0xFF;
|
int val = value & 0xFF;
|
||||||
return val > 0 && val < 32;
|
return val > 0 && val < 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isDigit (byte value)
|
boolean isDigit (byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return value >= 48 && value <= 57;
|
return value >= 48 && value <= 57;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,27 @@ package com.bytezone.diskbrowser.applefile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bytezone.diskbrowser.gui.TextPreferences;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class TextFile extends AbstractFile
|
public class TextFile extends AbstractFile
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private int recordLength; // prodos aux
|
static TextPreferences textPreferences; // set by MenuHandler
|
||||||
private List<TextBuffer> buffers; // only used if it is a Prodos text file
|
|
||||||
|
private int recordLength; // prodos aux
|
||||||
|
private List<TextBuffer> buffers; // only used if it is a Prodos text file
|
||||||
private int eof;
|
private int eof;
|
||||||
private boolean prodosFile;
|
private boolean prodosFile;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public static void setTextPreferences (TextPreferences textPreferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
TextFile.textPreferences = textPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public TextFile (String name, byte[] buffer)
|
public TextFile (String name, byte[] buffer)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -68,15 +78,19 @@ public class TextFile extends AbstractFile
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
text.append ("Name : " + name + "\n");
|
if (textPreferences.showHeader)
|
||||||
if (prodosFile)
|
|
||||||
{
|
{
|
||||||
text.append (String.format ("Record length : %,8d%n", recordLength));
|
text.append ("Name : " + name + "\n");
|
||||||
text.append (String.format ("End of file : %,8d%n", eof));
|
|
||||||
|
if (prodosFile)
|
||||||
|
{
|
||||||
|
text.append (String.format ("Record length : %,8d%n", recordLength));
|
||||||
|
text.append (String.format ("End of file : %,8d%n", eof));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
text.append (String.format ("End of file : %,8d%n", buffer.length));
|
||||||
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
text.append (String.format ("End of file : %,8d%n", buffer.length));
|
|
||||||
text.append ("\n");
|
|
||||||
|
|
||||||
// check whether file is spread over multiple buffers
|
// check whether file is spread over multiple buffers
|
||||||
if (buffers != null)
|
if (buffers != null)
|
||||||
|
@ -145,20 +159,25 @@ public class TextFile extends AbstractFile
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
int size = buffer.length;
|
int size = buffer.length;
|
||||||
int lastVal = 0;
|
int lastVal = 0;
|
||||||
boolean newFormat = true;
|
// boolean showAllOffsets = true;
|
||||||
boolean showAllOffsets = true;
|
|
||||||
|
|
||||||
if (newFormat)
|
if (textPreferences.showTextOffsets)
|
||||||
{
|
{
|
||||||
text.append (" Offset Text values\n");
|
text.append (" Offset Text values\n");
|
||||||
text.append ("---------- -------------------------------------------------------"
|
text.append ("---------- -------------------------------------------------------"
|
||||||
+ "-------------------\n");
|
+ "-------------------\n");
|
||||||
if (buffer.length == 0)
|
|
||||||
return text.toString ();
|
|
||||||
|
|
||||||
if (buffer[0] != 0)
|
|
||||||
text.append (String.format ("%,10d ", ptr));
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text.append (" Text values\n");
|
||||||
|
text.append ("-------------------------------------------------------"
|
||||||
|
+ "-------------------------------\n");
|
||||||
|
}
|
||||||
|
if (buffer.length == 0)
|
||||||
|
return text.toString ();
|
||||||
|
|
||||||
|
if (buffer[0] != 0 && textPreferences.showTextOffsets)
|
||||||
|
text.append (String.format ("%,10d ", ptr));
|
||||||
|
|
||||||
int gcd = 0;
|
int gcd = 0;
|
||||||
|
|
||||||
|
@ -173,19 +192,15 @@ public class TextFile extends AbstractFile
|
||||||
{
|
{
|
||||||
if (nulls > 0)
|
if (nulls > 0)
|
||||||
{
|
{
|
||||||
if (newFormat)
|
if (textPreferences.showTextOffsets)
|
||||||
text.append (String.format ("%,10d ", ptr - 1));
|
text.append (String.format ("%,10d ", ptr - 1));
|
||||||
else
|
|
||||||
text.append ("\nNew record at : " + (ptr - 1) + "\n");
|
|
||||||
nulls = 0;
|
nulls = 0;
|
||||||
|
|
||||||
gcd = gcd == 0 ? ptr - 1 : gcd (gcd, ptr - 1);
|
gcd = gcd == 0 ? ptr - 1 : gcd (gcd, ptr - 1);
|
||||||
}
|
}
|
||||||
else if (lastVal == 0x0D && newFormat)
|
else if (lastVal == 0x0D && textPreferences.showTextOffsets)
|
||||||
if (showAllOffsets)
|
text.append (String.format ("%,10d ", ptr - 1));
|
||||||
text.append (String.format ("%,10d ", ptr - 1));
|
|
||||||
else
|
|
||||||
text.append (" ");
|
|
||||||
|
|
||||||
text.append ((char) val);
|
text.append ((char) val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.bytezone.diskbrowser.applefile.Palette;
|
||||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||||
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
||||||
|
import com.bytezone.diskbrowser.applefile.TextFile;
|
||||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.SectorList;
|
import com.bytezone.diskbrowser.disk.SectorList;
|
||||||
|
@ -39,9 +40,10 @@ import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent;
|
||||||
import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
|
import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
public class DataPanel extends JTabbedPane
|
||||||
FileSelectionListener, SectorSelectionListener, FileNodeSelectionListener,
|
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
||||||
FontChangeListener, BasicPreferencesListener, AssemblerPreferencesListener
|
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
|
||||||
|
AssemblerPreferencesListener, TextPreferencesListener
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final int TEXT_WIDTH = 65;
|
private static final int TEXT_WIDTH = 65;
|
||||||
|
@ -551,6 +553,15 @@ public class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
||||||
setDataSource (currentDataSource);
|
setDataSource (currentDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void setTextPreferences (TextPreferences textPreferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (currentDataSource instanceof TextFile)
|
||||||
|
setDataSource (currentDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
class Worker extends SwingWorker<Void, Integer>
|
class Worker extends SwingWorker<Void, Integer>
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -188,6 +188,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||||
|
|
||||||
menuHandler.addBasicPreferencesListener (dataPanel);
|
menuHandler.addBasicPreferencesListener (dataPanel);
|
||||||
menuHandler.addAssemblerPreferencesListener (dataPanel);
|
menuHandler.addAssemblerPreferencesListener (dataPanel);
|
||||||
|
menuHandler.addTextPreferencesListener (dataPanel);
|
||||||
|
|
||||||
// activate the highest panel now that the listeners are ready
|
// activate the highest panel now that the listeners are ready
|
||||||
catalogPanel.activate ();
|
catalogPanel.activate ();
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.bytezone.diskbrowser.applefile.BasicProgram;
|
||||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||||
import com.bytezone.diskbrowser.applefile.Palette;
|
import com.bytezone.diskbrowser.applefile.Palette;
|
||||||
import com.bytezone.diskbrowser.applefile.PaletteFactory;
|
import com.bytezone.diskbrowser.applefile.PaletteFactory;
|
||||||
|
import com.bytezone.diskbrowser.applefile.TextFile;
|
||||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||||
import com.bytezone.diskbrowser.disk.DataDisk;
|
import com.bytezone.diskbrowser.disk.DataDisk;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
|
@ -54,7 +55,9 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
|
|
||||||
private static final String PREFS_PRODOS_SORT_DIRECTORIES = "prodosSortDirectories";
|
private static final String PREFS_PRODOS_SORT_DIRECTORIES = "prodosSortDirectories";
|
||||||
|
|
||||||
// private static final String PREFS_DEBUGGING = "debugging";
|
private static final String PREFS_TEXT_SHOW_OFFSETS = "showTextOffsets";
|
||||||
|
private static final String PREFS_TEXT_SHOW_HEADER = "showTextHeader";
|
||||||
|
|
||||||
private static final String PREFS_PALETTE = "palette";
|
private static final String PREFS_PALETTE = "palette";
|
||||||
|
|
||||||
FormattedDisk currentDisk;
|
FormattedDisk currentDisk;
|
||||||
|
@ -73,11 +76,16 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
private final List<ProdosPreferencesListener> prodosPreferencesListeners =
|
private final List<ProdosPreferencesListener> prodosPreferencesListeners =
|
||||||
new ArrayList<> ();
|
new ArrayList<> ();
|
||||||
|
|
||||||
|
private final TextPreferences textPreferences = new TextPreferences ();
|
||||||
|
private final List<TextPreferencesListener> textPreferencesListeners =
|
||||||
|
new ArrayList<> ();
|
||||||
|
|
||||||
JMenuBar menuBar = new JMenuBar ();
|
JMenuBar menuBar = new JMenuBar ();
|
||||||
JMenu fileMenu = new JMenu ("File");
|
JMenu fileMenu = new JMenu ("File");
|
||||||
JMenu formatMenu = new JMenu ("Format");
|
JMenu formatMenu = new JMenu ("Format");
|
||||||
JMenu imageMenu = new JMenu ("Images");
|
JMenu imageMenu = new JMenu ("Images");
|
||||||
JMenu applesoftMenu = new JMenu ("Applesoft");
|
JMenu applesoftMenu = new JMenu ("Applesoft");
|
||||||
|
JMenu textMenu = new JMenu ("Text");
|
||||||
JMenu assemblerMenu = new JMenu ("Assembler");
|
JMenu assemblerMenu = new JMenu ("Assembler");
|
||||||
JMenu prodosMenu = new JMenu ("Prodos");
|
JMenu prodosMenu = new JMenu ("Prodos");
|
||||||
JMenu helpMenu = new JMenu ("Help");
|
JMenu helpMenu = new JMenu ("Help");
|
||||||
|
@ -132,6 +140,10 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
// Prodos menu items
|
// Prodos menu items
|
||||||
final JMenuItem prodosSortDirectoriesItem = new JCheckBoxMenuItem ("Sort directories");
|
final JMenuItem prodosSortDirectoriesItem = new JCheckBoxMenuItem ("Sort directories");
|
||||||
|
|
||||||
|
// Text menu items
|
||||||
|
final JMenuItem showTextOffsetsItem = new JCheckBoxMenuItem ("Show offsets");
|
||||||
|
final JMenuItem showTextHeaderItem = new JCheckBoxMenuItem ("Show header");
|
||||||
|
|
||||||
ButtonGroup paletteGroup = new ButtonGroup ();
|
ButtonGroup paletteGroup = new ButtonGroup ();
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -144,6 +156,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
menuBar.add (applesoftMenu);
|
menuBar.add (applesoftMenu);
|
||||||
menuBar.add (assemblerMenu);
|
menuBar.add (assemblerMenu);
|
||||||
menuBar.add (prodosMenu);
|
menuBar.add (prodosMenu);
|
||||||
|
menuBar.add (textMenu);
|
||||||
menuBar.add (helpMenu);
|
menuBar.add (helpMenu);
|
||||||
|
|
||||||
fileMenu.add (rootItem);
|
fileMenu.add (rootItem);
|
||||||
|
@ -216,6 +229,9 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
assemblerMenu.add (showAssemblerStringsItem);
|
assemblerMenu.add (showAssemblerStringsItem);
|
||||||
assemblerMenu.add (showAssemblerHeaderItem);
|
assemblerMenu.add (showAssemblerHeaderItem);
|
||||||
|
|
||||||
|
textMenu.add (showTextOffsetsItem);
|
||||||
|
textMenu.add (showTextHeaderItem);
|
||||||
|
|
||||||
prodosMenu.add (prodosSortDirectoriesItem);
|
prodosMenu.add (prodosSortDirectoriesItem);
|
||||||
|
|
||||||
ActionListener basicPreferencesAction = new ActionListener ()
|
ActionListener basicPreferencesAction = new ActionListener ()
|
||||||
|
@ -248,6 +264,16 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ActionListener textPreferencesAction = new ActionListener ()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
{
|
||||||
|
setTextPreferences ();
|
||||||
|
notifyTextPreferencesListeners ();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
splitRemarkItem.addActionListener (basicPreferencesAction);
|
splitRemarkItem.addActionListener (basicPreferencesAction);
|
||||||
alignAssignItem.addActionListener (basicPreferencesAction);
|
alignAssignItem.addActionListener (basicPreferencesAction);
|
||||||
showBasicTargetsItem.addActionListener (basicPreferencesAction);
|
showBasicTargetsItem.addActionListener (basicPreferencesAction);
|
||||||
|
@ -261,6 +287,9 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
|
|
||||||
prodosSortDirectoriesItem.addActionListener (prodosPreferencesAction);
|
prodosSortDirectoriesItem.addActionListener (prodosPreferencesAction);
|
||||||
|
|
||||||
|
showTextOffsetsItem.addActionListener (textPreferencesAction);
|
||||||
|
showTextHeaderItem.addActionListener (textPreferencesAction);
|
||||||
|
|
||||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||||
|
|
||||||
sector256Item.setActionCommand ("256");
|
sector256Item.setActionCommand ("256");
|
||||||
|
@ -374,10 +403,33 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
listener.setProdosPreferences (prodosPreferences);
|
listener.setProdosPreferences (prodosPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void addHelpMenuAction (Action action, String functionName)
|
// ---------------------------------------------------------------------------------//
|
||||||
// {
|
private void setTextPreferences ()
|
||||||
// helpMenu.add (new JMenuItem (action));
|
// ---------------------------------------------------------------------------------//
|
||||||
// }
|
{
|
||||||
|
textPreferences.showTextOffsets = showTextOffsetsItem.isSelected ();
|
||||||
|
textPreferences.showHeader = showTextHeaderItem.isSelected ();
|
||||||
|
TextFile.setTextPreferences (textPreferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void addTextPreferencesListener (TextPreferencesListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (!textPreferencesListeners.contains (listener))
|
||||||
|
{
|
||||||
|
textPreferencesListeners.add (listener);
|
||||||
|
listener.setTextPreferences (textPreferences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void notifyTextPreferencesListeners ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
for (TextPreferencesListener listener : textPreferencesListeners)
|
||||||
|
listener.setTextPreferences (textPreferences);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addLauncherMenu ()
|
private void addLauncherMenu ()
|
||||||
|
@ -436,6 +488,9 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
|
|
||||||
prefs.putBoolean (PREFS_PRODOS_SORT_DIRECTORIES,
|
prefs.putBoolean (PREFS_PRODOS_SORT_DIRECTORIES,
|
||||||
prodosSortDirectoriesItem.isSelected ());
|
prodosSortDirectoriesItem.isSelected ());
|
||||||
|
|
||||||
|
prefs.putBoolean (PREFS_TEXT_SHOW_OFFSETS, showTextOffsetsItem.isSelected ());
|
||||||
|
prefs.putBoolean (PREFS_TEXT_SHOW_HEADER, showTextHeaderItem.isSelected ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -483,9 +538,13 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
prodosSortDirectoriesItem
|
prodosSortDirectoriesItem
|
||||||
.setSelected (prefs.getBoolean (PREFS_PRODOS_SORT_DIRECTORIES, true));
|
.setSelected (prefs.getBoolean (PREFS_PRODOS_SORT_DIRECTORIES, true));
|
||||||
|
|
||||||
|
showTextOffsetsItem.setSelected (prefs.getBoolean (PREFS_TEXT_SHOW_OFFSETS, true));
|
||||||
|
showTextHeaderItem.setSelected (prefs.getBoolean (PREFS_TEXT_SHOW_HEADER, true));
|
||||||
|
|
||||||
setBasicPreferences ();
|
setBasicPreferences ();
|
||||||
setAssemblerPreferences ();
|
setAssemblerPreferences ();
|
||||||
setProdosPreferences ();
|
setProdosPreferences ();
|
||||||
|
setTextPreferences ();
|
||||||
|
|
||||||
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
|
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
|
||||||
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();
|
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();
|
||||||
|
|
22
src/com/bytezone/diskbrowser/gui/TextPreferences.java
Normal file
22
src/com/bytezone/diskbrowser/gui/TextPreferences.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
public class TextPreferences
|
||||||
|
//-----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public boolean showTextOffsets;
|
||||||
|
public boolean showHeader = true;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
text.append (String.format ("Show offsets .......... %s%n", showTextOffsets));
|
||||||
|
text.append (String.format ("Show header ........... %s", showHeader));
|
||||||
|
|
||||||
|
return text.toString ();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
public interface TextPreferencesListener
|
||||||
|
//-----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public void setTextPreferences (TextPreferences textPreferences);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user