mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-01 03:41:29 +00:00
shortuts
This commit is contained in:
parent
85f0f17e61
commit
42524619af
|
@ -41,11 +41,11 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
final List<Integer> stringsLine = new ArrayList<> ();
|
final List<Integer> stringsLine = new ArrayList<> ();
|
||||||
final List<String> stringsText = new ArrayList<> ();
|
final List<String> stringsText = new ArrayList<> ();
|
||||||
|
|
||||||
String formatLeft;
|
private final String formatLeft;
|
||||||
String formatLineNumber;
|
private final String formatLineNumber;
|
||||||
String formatRight;
|
private final String formatRight;
|
||||||
String formatCall;
|
final String formatCall;
|
||||||
int maxDigits;
|
private final int maxDigits;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public ApplesoftBasicProgram (String name, byte[] buffer)
|
public ApplesoftBasicProgram (String name, byte[] buffer)
|
||||||
|
@ -77,15 +77,15 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
for (String symbol : subline.getFunctions ())
|
for (String symbol : subline.getFunctions ())
|
||||||
checkFunction (symbol, line.lineNumber);
|
checkFunction (symbol, line.lineNumber);
|
||||||
for (int targetLine : subline.getGosubLines ())
|
for (int targetLine : subline.getGosubLines ())
|
||||||
addXref (line.lineNumber, targetLine, gosubLines);
|
addNumberInt (line.lineNumber, targetLine, gosubLines);
|
||||||
for (int targetLine : subline.getGotoLines ())
|
for (int targetLine : subline.getGotoLines ())
|
||||||
addXref (line.lineNumber, targetLine, gotoLines);
|
addNumberInt (line.lineNumber, targetLine, gotoLines);
|
||||||
for (int num : subline.getConstantsInt ())
|
for (int num : subline.getConstantsInt ())
|
||||||
addNumberInt (line.lineNumber, num, constantsInt);
|
addNumberInt (line.lineNumber, num, constantsInt);
|
||||||
for (float num : subline.getConstantsFloat ())
|
for (float num : subline.getConstantsFloat ())
|
||||||
addNumberFloat (line.lineNumber, num, constantsFloat);
|
addNumberFloat (line.lineNumber, num, constantsFloat);
|
||||||
if (subline.callTarget != null)
|
if (subline.callTarget != null)
|
||||||
addXref (line.lineNumber, subline.callTarget, callLines);
|
addString (line.lineNumber, subline.callTarget, callLines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endPtr = ptr;
|
endPtr = ptr;
|
||||||
|
@ -146,53 +146,40 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addXref (int sourceLine, int targetLine, Map<Integer, List<Integer>> map)
|
private void addNumberInt (int sourceLine, Integer key, Map<Integer, List<Integer>> map)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<Integer> lines = map.get (targetLine);
|
List<Integer> lines = map.get (key);
|
||||||
if (lines == null)
|
if (lines == null)
|
||||||
{
|
{
|
||||||
lines = new ArrayList<> ();
|
lines = new ArrayList<> ();
|
||||||
map.put (targetLine, lines);
|
map.put (key, lines);
|
||||||
}
|
}
|
||||||
lines.add (sourceLine);
|
lines.add (sourceLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addNumberInt (int sourceLine, Integer num, Map<Integer, List<Integer>> map)
|
private void addNumberFloat (int sourceLine, Float key, Map<Float, List<Integer>> map)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<Integer> lines = map.get (num);
|
List<Integer> lines = map.get (key);
|
||||||
if (lines == null)
|
if (lines == null)
|
||||||
{
|
{
|
||||||
lines = new ArrayList<> ();
|
lines = new ArrayList<> ();
|
||||||
map.put (num, lines);
|
map.put (key, lines);
|
||||||
}
|
}
|
||||||
lines.add (sourceLine);
|
lines.add (sourceLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addNumberFloat (int sourceLine, Float num, Map<Float, List<Integer>> map)
|
private void addString (int sourceLine, String key, Map<String, List<Integer>> map)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<Integer> lines = map.get (num);
|
List<Integer> lines = map.get (key);
|
||||||
if (lines == null)
|
if (lines == null)
|
||||||
{
|
{
|
||||||
lines = new ArrayList<> ();
|
lines = new ArrayList<> ();
|
||||||
map.put (num, lines);
|
map.put (key, lines);
|
||||||
}
|
|
||||||
lines.add (sourceLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
private void addXref (int sourceLine, String target, Map<String, List<Integer>> map)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
List<Integer> lines = map.get (target);
|
|
||||||
if (lines == null)
|
|
||||||
{
|
|
||||||
lines = new ArrayList<> ();
|
|
||||||
map.put (target, lines);
|
|
||||||
}
|
}
|
||||||
lines.add (sourceLine);
|
lines.add (sourceLine);
|
||||||
}
|
}
|
||||||
|
@ -371,10 +358,10 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
|
|
||||||
// Check for a wrappable PRINT or INPUT statement
|
// Check for a wrappable PRINT or INPUT statement
|
||||||
// (see FROM MACHINE LANGUAGE TO BASIC on DOSToolkit2eB.dsk)
|
// (see FROM MACHINE LANGUAGE TO BASIC on DOSToolkit2eB.dsk)
|
||||||
if (basicPreferences.wrapPrintAt > 0
|
if (basicPreferences.wrapPrintAt > 0 // not currently used
|
||||||
&& (subline.is (TOKEN_PRINT) || subline.is (TOKEN_INPUT))
|
&& (subline.is (TOKEN_PRINT) || subline.is (TOKEN_INPUT))
|
||||||
&& countChars (text, Utility.ASCII_QUOTE) == 2 // just start and end quotes
|
&& countChars (text, Utility.ASCII_QUOTE) == 2 // just start and end quotes
|
||||||
&& countChars (text, Utility.ASCII_CARET) == 0) // no control characters
|
&& countChars (text, Utility.ASCII_CARET) == 0) // no control characters
|
||||||
wrapPrint (fullText, text, lineText);
|
wrapPrint (fullText, text, lineText);
|
||||||
else
|
else
|
||||||
fullText.append (text + "\n");
|
fullText.append (text + "\n");
|
||||||
|
@ -404,7 +391,8 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
insertBlankLine = false;
|
insertBlankLine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset alignment value if we just left an IF - the indentation will be different now
|
// Reset alignment value if we just left an IF
|
||||||
|
// - the indentation will be different now
|
||||||
if (ifIndent > 0)
|
if (ifIndent > 0)
|
||||||
alignEqualsPos = 0;
|
alignEqualsPos = 0;
|
||||||
}
|
}
|
||||||
|
@ -425,40 +413,52 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
private void addXref (StringBuilder fullText)
|
private void addXref (StringBuilder fullText)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (basicPreferences.showSymbols && !symbolLines.isEmpty ())
|
if (basicPreferences.showSymbols)
|
||||||
showSymbolsLeft (fullText, symbolLines, "Var");
|
{
|
||||||
|
if (!symbolLines.isEmpty ())
|
||||||
|
showSymbolsLeft (fullText, symbolLines, "Var");
|
||||||
|
|
||||||
if (basicPreferences.showSymbols && !arrayLines.isEmpty ())
|
if (!arrayLines.isEmpty ())
|
||||||
showSymbolsLeft (fullText, arrayLines, "Array");
|
showSymbolsLeft (fullText, arrayLines, "Array");
|
||||||
|
}
|
||||||
|
|
||||||
if (basicPreferences.showDuplicateSymbols && !uniqueSymbols.isEmpty ())
|
if (basicPreferences.showDuplicateSymbols)
|
||||||
showDuplicates (fullText, uniqueSymbols, "Var");
|
{
|
||||||
|
if (!uniqueSymbols.isEmpty ())
|
||||||
|
showDuplicates (fullText, uniqueSymbols, "Var");
|
||||||
|
|
||||||
if (basicPreferences.showDuplicateSymbols && !uniqueArrays.isEmpty ())
|
if (!uniqueArrays.isEmpty ())
|
||||||
showDuplicates (fullText, uniqueArrays, "Array");
|
showDuplicates (fullText, uniqueArrays, "Array");
|
||||||
|
}
|
||||||
|
|
||||||
if (basicPreferences.showFunctions && !functionLines.isEmpty ())
|
if (basicPreferences.showFunctions && !functionLines.isEmpty ())
|
||||||
showSymbolsLeft (fullText, functionLines, "Fnction");
|
showSymbolsLeft (fullText, functionLines, "Fnction");
|
||||||
|
|
||||||
if (basicPreferences.showConstants && !constantsInt.isEmpty ())
|
if (basicPreferences.showConstants)
|
||||||
showSymbolsRightInt (fullText, constantsInt, "Integer");
|
|
||||||
|
|
||||||
if (basicPreferences.showConstants && !constantsFloat.isEmpty ())
|
|
||||||
showSymbolsRightFloat (fullText, constantsFloat, "Float");
|
|
||||||
|
|
||||||
if (basicPreferences.showConstants && stringsLine.size () > 0)
|
|
||||||
{
|
{
|
||||||
heading (fullText, formatRight, "Line", "String");
|
if (!constantsInt.isEmpty ())
|
||||||
for (int i = 0; i < stringsLine.size (); i++)
|
showSymbolsRightInt (fullText, constantsInt, "Integer");
|
||||||
fullText.append (String.format (formatRight + "%s%n", stringsLine.get (i),
|
|
||||||
stringsText.get (i)));
|
if (!constantsFloat.isEmpty ())
|
||||||
|
showSymbolsRightFloat (fullText, constantsFloat, "Float");
|
||||||
|
|
||||||
|
if (stringsLine.size () > 0)
|
||||||
|
{
|
||||||
|
heading (fullText, formatRight, "Line", "String");
|
||||||
|
for (int i = 0; i < stringsLine.size (); i++)
|
||||||
|
fullText.append (String.format (formatRight + "%s%n", stringsLine.get (i),
|
||||||
|
stringsText.get (i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basicPreferences.showXref && !gosubLines.isEmpty ())
|
if (basicPreferences.showXref)
|
||||||
showSymbolsRight (fullText, gosubLines, "GOSUB");
|
{
|
||||||
|
if (!gosubLines.isEmpty ())
|
||||||
|
showSymbolsRight (fullText, gosubLines, "GOSUB");
|
||||||
|
|
||||||
if (basicPreferences.showXref && !gotoLines.isEmpty ())
|
if (!gotoLines.isEmpty ())
|
||||||
showSymbolsRight (fullText, gotoLines, "GOTO");
|
showSymbolsRight (fullText, gotoLines, "GOTO");
|
||||||
|
}
|
||||||
|
|
||||||
if (basicPreferences.showCalls && !callLines.isEmpty ())
|
if (basicPreferences.showCalls && !callLines.isEmpty ())
|
||||||
showSymbolsLeft (fullText, callLines, "CALL");
|
showSymbolsLeft (fullText, callLines, "CALL");
|
||||||
|
@ -643,23 +643,23 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
else
|
else
|
||||||
fullText.append (text + "\n");
|
fullText.append (text + "\n");
|
||||||
}
|
}
|
||||||
else // old method
|
// else // old method
|
||||||
{
|
// {
|
||||||
int first = text.indexOf ("\"") + 1;
|
// int first = text.indexOf ("\"") + 1;
|
||||||
int last = text.indexOf ("\"", first + 1) - 1;
|
// int last = text.indexOf ("\"", first + 1) - 1;
|
||||||
if ((last - first) > basicPreferences.wrapPrintAt)
|
// if ((last - first) > basicPreferences.wrapPrintAt)
|
||||||
{
|
// {
|
||||||
int ptr = first + basicPreferences.wrapPrintAt;
|
// int ptr = first + basicPreferences.wrapPrintAt;
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
fullText.append (text.substring (0, ptr)
|
// fullText.append (text.substring (0, ptr)
|
||||||
+ "\n ".substring (0, first + 1));
|
// + "\n ".substring (0, first + 1));
|
||||||
text.delete (0, ptr);
|
// text.delete (0, ptr);
|
||||||
ptr = basicPreferences.wrapPrintAt;
|
// ptr = basicPreferences.wrapPrintAt;
|
||||||
} while (text.length () > basicPreferences.wrapPrintAt);
|
// } while (text.length () > basicPreferences.wrapPrintAt);
|
||||||
}
|
// }
|
||||||
fullText.append (text + "\n");
|
// fullText.append (text + "\n");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -323,14 +323,14 @@ public class SubLine implements ApplesoftConstants
|
||||||
{
|
{
|
||||||
b = (byte) chunk.charAt (0);
|
b = (byte) chunk.charAt (0);
|
||||||
if (Utility.isDigit (b) || b == Utility.ASCII_MINUS || b == Utility.ASCII_DOT)
|
if (Utility.isDigit (b) || b == Utility.ASCII_MINUS || b == Utility.ASCII_DOT)
|
||||||
{
|
|
||||||
addNumber (chunk);
|
addNumber (chunk);
|
||||||
}
|
else if (Utility.isLetter (b)) // quoted strings are already handled
|
||||||
else if (Utility.isLetter (b))
|
|
||||||
{
|
{
|
||||||
parent.parent.stringsText.add (chunk);
|
parent.parent.stringsText.add (chunk);
|
||||||
parent.parent.stringsLine.add (parent.lineNumber);
|
parent.parent.stringsLine.add (parent.lineNumber);
|
||||||
}
|
}
|
||||||
|
else if (b != Utility.ASCII_QUOTE)
|
||||||
|
System.out.println ("Unknown data: " + chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.gui;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
@ -375,6 +376,11 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
|
|
||||||
saveDiskItem.setAction (saveTempFileAction);
|
saveDiskItem.setAction (saveTempFileAction);
|
||||||
saveSectorsItem.setAction (saveSectorsAction);
|
saveSectorsItem.setAction (saveSectorsAction);
|
||||||
|
|
||||||
|
KeyStroke keyStroke1 = KeyStroke.getKeyStroke (KeyEvent.VK_S, KeyEvent.ALT_DOWN_MASK);
|
||||||
|
showAllFormatItem.setAccelerator (keyStroke1);
|
||||||
|
KeyStroke keyStroke2 = KeyStroke.getKeyStroke (KeyEvent.VK_L, KeyEvent.ALT_DOWN_MASK);
|
||||||
|
showAllXrefItem.setAccelerator (keyStroke2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user