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

Allow multiline theme definitions in .fehrc

parent b54e5c96
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ git HEAD
      toggle fullscreen, should you really need it.
    * --font now sets the global default font (for action/filename display etc.)
    * Rename --screen-clip 0 to --no-screen-clip
    * Allow multiline theme definitions (via backslash, like in the shell)

Thu Jun 10 12:12:04 CEST 2010

+3 −0
Original line number Diff line number Diff line
@@ -552,6 +552,9 @@ Now just run
.Qq imagemap *.jpg
to use these options.
.Pp
Note that you can split a theme over several lines by placing a backslash at
the end of a line, like in the shell.
.Pp
You can combine these themes with commandline options.  An example .fehrc is
provided with a couple of cool example themes.
.
+38 −8
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ static void feh_load_options_for_theme(char *theme)
	char *home;
	char *rcpath = NULL;
	char s[1024], s1[1024], s2[1024];
	int cont = 0;
	int bspos;

	if (opt.rcfile) {
		if ((fp = fopen(opt.rcfile, "r")) == NULL) {
@@ -176,13 +178,39 @@ static void feh_load_options_for_theme(char *theme)
	for (; fgets(s, sizeof(s), fp);) {
		s1[0] = '\0';
		s2[0] = '\0';

		if (cont) {
			sscanf(s, " %[^\n]\n", (char *) &s2);
			if (!*s2)
				break;
			D(5, ("Got continued options %s\n", s2));
		} else {
			sscanf(s, "%s %[^\n]\n", (char *) &s1, (char *) &s2);
		if (!(*s1) || (!*s2) || (*s1 == '\n') || (*s1 == '#'))
			if (!(*s1) || (!*s2) || (*s1 == '\n') || (*s1 == '#')) {
				cont = 0;
				continue;
			}
			D(5, ("Got theme/options pair %s/%s\n", s1, s2));
		if (!strcmp(s1, theme)) {
		}

		if (!strcmp(s1, theme) || cont) {

			bspos = strlen(s2)-1;

			if (s2[bspos] == '\\') {
				D(5, ("Continued line\n"));
				s2[bspos] = '\0';
				cont = 1;
				/* A trailing whitespace confuses the option parser */
				if (bspos && (s2[bspos-1] == ' '))
					s2[bspos-1] = '\0';
			} else
				cont = 0;

			D(4, ("A match. Using options %s\n", s2));
			feh_parse_options_from_string(s2);

			if (!cont)
				break;
		}
	}
@@ -1182,8 +1210,10 @@ static void feh_create_default_config(char *rcfile)
"# Set the default feh options to be recursive and verbose\n"
"# feh -rV\n"
"\n"
"# Multiple options can of course be used. They should all be on one line\n"
"# imagemap -rV --quiet -W 400 -H 300 --thumb-width 40 --thumb-height 30\n"
"# Multiple options can of course be used. If they are not in one line,\n"
"# the lines after the theme name must start with a tab character. Like:\n"
"# imagemap -rV --quiet -W 400 -H 300 \\\n"
"#          --thumb-width 40 --thumb-height 30\n"
"\n"
"# ====================\n"
"# A few default themes\n"