From 1e212f65c87fd634c738b4c79e1ffed5c29b039d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 4 Apr 2018 08:35:11 +0200 Subject: Add %g and %Z format specifiers (closes #391) --- man/feh.pre | 13 +++++++++++-- src/slideshow.c | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/man/feh.pre b/man/feh.pre index eb31f37..cc67b25 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -1014,6 +1014,10 @@ Image path/filename Escaped image path/filename .Pq for use in shell commands . +.It %g +. +w,h window dimensions in pixels (mnemonic: geometry) +. .It %h . Image height @@ -1048,8 +1052,9 @@ Number of image pixels . .It \&%P . -Number of image pixels +Number of image pixels in human-readable format with k/M .Pq kilopixels / megapixels +suffix . .It %r . @@ -1087,7 +1092,11 @@ Process ID . .It %z . -current image zoom +Current image zoom, rounded to two decimal places +. +.It %Z +. +Current image zoom, higher precision . .It %% . diff --git a/src/slideshow.c b/src/slideshow.c index effdcaf..7bad2c9 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -468,6 +468,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid) if (file) strncat(ret, shell_escape(file->filename), sizeof(ret) - strlen(ret) - 1); break; + case 'g': + if (winwid) { + snprintf(buf, sizeof(buf), "%d,%d", winwid->w, winwid->h); + strncat(ret, buf, sizeof(ret) - strlen(ret) - 1); + } + break; case 'h': if (file && (file->info || !feh_file_info_load(file, NULL))) { snprintf(buf, sizeof(buf), "%d", file->info->height); @@ -564,6 +570,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid) strncat(ret, "1.00", sizeof(ret) - strlen(ret) - 1); } break; + case 'Z': + if (winwid) { + snprintf(buf, sizeof(buf), "%f", winwid->zoom); + strncat(ret, buf, sizeof(ret) - strlen(ret) - 1); + } + break; case '%': strncat(ret, "%", sizeof(ret) - strlen(ret) - 1); break; -- cgit v1.2.3