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

Add --index-info option

parent ca99c34c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ git HEAD
    * The button-options -0 through -9 are no longer supported.
      Use .config/feh/buttons instead (see feh manpage)
    * New format specifier: %S (size in kB)
    * The --index-{dim,name,size} options are no longer supported.
      Use --index-info <string> with format specifiers instead

Mon, 26 Sep 2011 09:35:41 +0200  Daniel Friesel <derf@finalrewind.org>

+4 −33
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static char *create_index_title_string(int num, int w, int h);
static char *create_index_string(feh_file *file);
static void get_index_string_dim(feh_file *file, Imlib_Font fn, int *w, int *h);
static int get_index_info_no_lines(void);

/* TODO Break this up a bit ;) */
/* TODO s/bit/lot */
@@ -92,8 +91,9 @@ void init_index_mode(void)

	/* Work out how tall the font is */
	gib_imlib_get_text_size(fn, "W", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
	get_index_string_dim(NULL, fn, &fw, &fh);
	/* For now, allow room for the right number of lines with small gaps */
	text_area_h = ((th + 2) * get_index_info_no_lines()) + 5;
	text_area_h = fh + 5;

	/* This includes the text area for index data */
	tot_thumb_h = opt.thumb_h + text_area_h;
@@ -360,7 +360,7 @@ void init_index_mode(void)
			lineno = 0;
			if (opt.index_info) {
				line = lines = feh_wrap_string(create_index_string(file),
						opt.thumb_w * 2, fn, NULL);
						opt.thumb_w * 3, fn, NULL);

				while (line) {
					gib_imlib_get_text_size(fn, (char *) line->data,
@@ -435,45 +435,16 @@ void init_index_mode(void)
	return;
}

static int get_index_info_no_lines(void)
{
	static int no_lines = 0;
	char *pos = opt.index_info;

	if (no_lines)
		return no_lines;

	if (!opt.index_info)
		return 0;

	no_lines = 1;
	while ((pos = strchr(pos, '\n'))) {
		no_lines++;
		pos++;
	}
	
	return no_lines;
}

static void get_index_string_dim(feh_file *file, Imlib_Font fn, int *fw, int *fh)
{
	int line_w, line_h;
	gib_list *line, *lines;
	static int max_w = 0, total_h = 0;
	static feh_file *last_file;

	if (last_file == file) {
		*fw = max_w;
		*fh = total_h;
		return;
	}

	last_file = file;

	if (!opt.index_info)
		return;

	line = lines = feh_wrap_string(create_index_string(file), opt.thumb_w * 2, fn, NULL);
	line = lines = feh_wrap_string(create_index_string(file), opt.thumb_w * 3, fn, NULL);

	while (line) {
		gib_imlib_get_text_size(fn, (char *) line->data,
+5 −1
Original line number Diff line number Diff line
@@ -374,6 +374,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
		{"menu-style"    , 1, 0, 204},
		{"zoom"          , 1, 0, 205},
		{"no-screen-clip", 0, 0, 206},
		{"index-info"    , 1, 0, 207},
		{"caption-path"  , 1, 0, 'K'},
		{"action1"       , 1, 0, 209},
		{"action2"       , 1, 0, 210},
@@ -650,6 +651,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
		case 206:
			opt.screen_clip = 0;
			break;
		case 207:
			opt.index_info = estrdup(optarg);
			break;
		case 'K':
			opt.caption_path = estrdup(optarg);
			break;