%f Replaced with list of selected files, may occur once.
%p Command is run once for each selected file, may occur multiple times.
- none When neither %f or %p exist, list of files is appended to command.
-
+
Use of the following to display output window for the command:
%v Display result of command in output window, must occur as first two
%w Prevent full screen from deactivating when command is executed,
must occur as the first two characters.
+ %% This will be replaced by one '%'. This is the way to escape '%'.
+
+ %d This only makes sense for external commands like copy or move as this
+ is replaced by the destination.
======== Overlay Info [section:overlay]
#include "main.h"
#include "editors.h"
+#include "debug.h"
+#include "filedata.h"
+#include "filefilter.h"
#include "utilops.h"
#include "ui_fileops.h"
#include "ui_spinner.h"
#include "ui_utildlg.h"
-#include "filedata.h"
-#include "filefilter.h"
-
#include <errno.h>
flags |= EDITOR_ERROR_EMPTY;
goto err;
}
-
+
+ /* skip leading whitespaces if any */
+ while (g_ascii_isspace(*p)) p++;
/* global flags */
while (*p == '%')
flags |= EDITOR_VERBOSE_MULTI;
p++;
break;
+ default:
+ flags |= EDITOR_ERROR_SYNTAX;
+ goto err;
}
}
+ /* skip whitespaces if any */
+ while (g_ascii_isspace(*p)) p++;
+
/* command */
while (*p)
{
case 'd':
flags |= EDITOR_DEST;
+ /* fall through */
case 'p':
flags |= EDITOR_FOR_EACH;
if (flags & EDITOR_SINGLE_COMMAND)
flags |= EDITOR_ERROR_NO_FILE;
goto err;
}
- pathl = editor_command_path_parse((FileData *)list->data, (*p == 'd') ? PATH_DEST : PATH_FILE, extensions);
+ pathl = editor_command_path_parse((FileData *)list->data,
+ (flags & EDITOR_DEST) ? PATH_DEST : PATH_FILE,
+ extensions);
if (!pathl)
{
flags |= EDITOR_ERROR_NO_FILE;
}
}
break;
+ case '%':
+ /* %% = % escaping */
+ if (output) result = g_string_append_c(result, *p);
+ break;
default:
flags |= EDITOR_ERROR_SYNTAX;
goto err;
command = g_locale_from_utf8(options->editor_command[n], -1, NULL, NULL, NULL);
error = editor_command_start(command, options->editor_name[n], list, cb, data);
g_free(command);
+
+ if (n < GQ_EDITOR_GENERIC_SLOTS && (error & EDITOR_ERROR_SYNTAX))
+ {
+ gchar *text = g_strdup_printf(_("Syntax error in the editor template \"%s\":\n%s"),
+ options->editor_name[n], options->editor_command[n]);
+
+ file_util_warning_dialog(_("Invalid editor command"), text, GTK_STOCK_DIALOG_ERROR, NULL);
+ g_free(text);
+ }
+
return error;
}