// the counter added to the default linked id prefix
private int defaultLinkedIdCounter = 0;
+ // the linked id prefix used for --opennew files
+ protected static final String OPENNEWLINKEDIDPREFIX = "OPENNEW:";
+
+ // the counter added to the default linked id prefix
+ private int opennewLinkedIdCounter = 0;
+
// the linked id used to increment the idCounter (and use the incremented
// value)
private static final String INCREMENTAUTOCOUNTERLINKEDID = "{++n}";
private void parse(List<String> args)
{
int argIndex = 0;
- boolean initialFilenameArgs = true;
+ boolean openEachInitialFilenames = true;
for (int i = 0; i < args.size(); i++)
{
String arg = args.get(i);
+ Console.debug("##### Looking at arg '" + arg + "'");
+
// If the first arguments do not start with "--" or "-" or is "open" and
// is a filename that exists it is probably a file/list of files to open
// so we fake an Arg.OPEN argument and when adding files only add the
// single arg[i] and increment the defaultLinkedIdCounter so that each of
// these files is opened separately.
- if (initialFilenameArgs && !arg.startsWith(DOUBLEDASH)
+ if (openEachInitialFilenames && !arg.startsWith(DOUBLEDASH)
&& !arg.startsWith("-") && new File(arg).exists())
{
- arg = DOUBLEDASH + Arg.OPEN.getName();
- Console.debug("Adding argument '" + args.get(i)
- + "' as a file to be opened");
+ arg = DOUBLEDASH + Arg.OPENNEW.getName();
}
else
{
- initialFilenameArgs = false;
+ openEachInitialFilenames = false;
}
String argName = null;
{
// if this is the first argument with a file list at the start of
// the args we add filenames from index i instead of i+1
- // and assume they should be opened separately
- if (initialFilenameArgs)
- {
- val = args.get(i);
- defaultLinkedIdCounter++;
- }
- else
- {
- vals = getShellGlobbedFilenameValues(a, args, i + 1);
- }
+ vals = getShellGlobbedFilenameValues(a, args,
+ openEachInitialFilenames ? i : i + 1);
}
else
{
.append(Integer.toString(defaultLinkedIdCounter))
.toString();
boolean usingDefaultLinkedId = false;
- if (a.hasOption(Opt.LINKED))
+ if (a == Arg.OPENNEW)
+ {
+ linkedId = new StringBuilder(OPENNEWLINKEDIDPREFIX)
+ .append(Integer.toString(opennewLinkedIdCounter))
+ .toString();
+ opennewLinkedIdCounter++;
+ }
+ else if (a.hasOption(Opt.LINKED))
{
if (linkedId == null)
{
continue;
}
+ boolean argIndexIncremented = false;
ArgValues avs = avm.getOrCreateArgValues(a);
- if (avs == null)
- {
- avs = new ArgValues(a);
- }
- boolean argIndexIncremented = false;
// store appropriate value
if (a.hasOption(Opt.STRING))
{
// store in appropriate place
if (a.hasOption(Opt.LINKED))
{
- // allow a default linked id for single usage
- if (linkedId == null)
- linkedId = defaultLinkedId;
// store the order of linkedIds
if (linkedOrder == null)
linkedOrder = new ArrayList<>();