Commit f3d11d51 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add preliminary action-title support (#224)

parent dc64b30d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ For animated images, only the first frame is shown.
.
.Bl -tag -width indent
.
.It Cm -A , --action Oo Ar flag Oc Ns Ar action
.It Cm -A , --action Oo Ar flag Oc Ns Oo [ Ar title ] Oc Ns Ar action
.
Specify a shell command as an action to perform on the image.  In slideshow or
multiwindow mode, the action will be run when the action_0 key is pressed, in
@@ -154,6 +154,16 @@ is
will reload the current image instead of switching to the next one after
executing the action.
.
If
.No [ Ar title ]
is specified,
.Cm --draw-actions
will display
.Ar title
instead of
.Ar action
in the action list.
.
.Pp
.
The action will be executed by /bin/sh.  Use format specifiers to refer to
+5 −5
Original line number Diff line number Diff line
@@ -1257,9 +1257,9 @@ void feh_draw_actions(winwidget w)

	for (i = 0; i < 10; i++) {
		if (opt.actions[i]) {
			line = emalloc(strlen(opt.actions[i]) + 5);
			line = emalloc(strlen(opt.action_titles[i]) + 5);
			strcpy(line, "0: ");
			line = strcat(line, opt.actions[i]);
			line = strcat(line, opt.action_titles[i]);
			gib_imlib_get_text_size(fn, line, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
			free(line);
			if (tw > max_tw)
@@ -1289,13 +1289,13 @@ void feh_draw_actions(winwidget w)
	gib_imlib_text_draw(im, fn, NULL, 1, 1, "defined actions:", IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);

	for (i = 0; i < 10; i++) {
		if (opt.actions[i]) {
		if (opt.action_titles[i]) {
			cur_action++;
			line = emalloc(strlen(opt.actions[i]) + 5);
			line = emalloc(strlen(opt.action_titles[i]) + 5);
			sprintf(index, "%d", i);
			strcpy(line, index);
			strcat(line, ": ");
			strcat(line, opt.actions[i]);
			strcat(line, opt.action_titles[i]);

			gib_imlib_text_draw(im, fn, NULL, 2,
					(cur_action * line_th) + 2, line,
+11 −1
Original line number Diff line number Diff line
@@ -787,10 +787,20 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
static void check_options(void)
{
	int i;
	char *endptr;

	for (i = 0; i < 10; i++) {
		if (opt.actions[i] && !opt.hold_actions[i] && (opt.actions[i][0] == ';')) {
			opt.hold_actions[i] = 1;
			opt.actions[i] = &opt.actions[i][1];
			opt.actions[i] = opt.actions[i] + 1;
		}
		opt.action_titles[i] = opt.actions[i];
		if (opt.actions[i] && (opt.actions[i][0] == '[')) {
			if ((endptr = strchr(opt.actions[i], ']')) != NULL) {
				opt.action_titles[i] = opt.actions[i] + 1;
				opt.actions[i] = endptr + 1;
				*endptr = 0;
			}
		}
	}

+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ struct __fehoptions {
	char *title;
	char *thumb_title;
	char *actions[10];
	char *action_titles[10];
	char *fontpath;
	char *filelistfile;
	char *menu_font;