diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-09-30 02:33:43 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-09-30 02:33:43 +0200 |
commit | a5f36f763cb8f66b1c658057f7af1ee6d7f246b7 (patch) | |
tree | b50456d2b89566764dc208f1b116641cbb9c15d1 | |
parent | ca99c34c74999682dc6ce70d7455ba2ff778b1f8 (diff) | |
download | feh-a5f36f763cb8f66b1c658057f7af1ee6d7f246b7.zip |
Add --index-info option
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/index.c | 37 | ||||
-rw-r--r-- | src/options.c | 6 |
3 files changed, 11 insertions, 34 deletions
@@ -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> diff --git a/src/index.c b/src/index.c index d194cf6..3ac5997 100644 --- a/src/index.c +++ b/src/index.c @@ -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, diff --git a/src/options.c b/src/options.c index 6f44607..4b29d35 100644 --- a/src/options.c +++ b/src/options.c @@ -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}, @@ -427,7 +428,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) break; case 'I': opt.index = 1; - opt.index_info = estrdup("%n \n %S \n %wx%h"); + opt.index_info = estrdup("%n\n%S\n%wx%h"); opt.index_show_name = 1; opt.index_show_size = 1; opt.index_show_dim = 1; @@ -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; |