Mercurial > geeqie.yaz
changeset 669:dd5d7fe9458f
Improve editors a bit:
- allow whitespaces before and after %v, %V, %w
- allow % escaping using %% (mandatory to use shell commands than contain % characters)
- display a dialog on execution if a syntax error is detected (only for generic editors)
- update README editors section
author | zas_ |
---|---|
date | Fri, 16 May 2008 08:37:07 +0000 |
parents | a074514d418e |
children | a484500de88d |
files | README src/editors.c |
diffstat | 2 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/README Wed May 14 18:12:11 2008 +0000 +++ b/README Fri May 16 08:37:07 2008 +0000 @@ -392,8 +392,7 @@ %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 @@ -406,6 +405,10 @@ %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]
--- a/src/editors.c Wed May 14 18:12:11 2008 +0000 +++ b/src/editors.c Fri May 16 08:37:07 2008 +0000 @@ -14,14 +14,14 @@ #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> @@ -392,7 +392,9 @@ flags |= EDITOR_ERROR_EMPTY; goto err; } - + + /* skip leading whitespaces if any */ + while (g_ascii_isspace(*p)) p++; /* global flags */ while (*p == '%') @@ -411,9 +413,15 @@ 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) @@ -450,6 +458,7 @@ { case 'd': flags |= EDITOR_DEST; + /* fall through */ case 'p': flags |= EDITOR_FOR_EACH; if (flags & EDITOR_SINGLE_COMMAND) @@ -465,7 +474,9 @@ 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; @@ -515,6 +526,10 @@ } } break; + case '%': + /* %% = % escaping */ + if (output) result = g_string_append_c(result, *p); + break; default: flags |= EDITOR_ERROR_SYNTAX; goto err; @@ -798,6 +813,16 @@ 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; }