imv
imv copied to clipboard
Multiline overlay text
It would be convenient to keep external tools' formatting in overlay_text option. So that overlay_text = $(jhead $imv_current_file) gives multiline output as jhead does itself. Or to add support of some "formatting characters" such as "\n". Translation 0xA into '0x5C6E' of jhead's output I would do by an external program.
Thanks for great software!
Should be an easy enough change to the imv_canvas_printf
function. I don't have the same coding time to devote to imv that I used to, but I'm happy to accept a patch for this.
It's actually wordexp
that splits the overlay text according to shell input-field-separator (IFS) rules, not Pango.
Doing putenv("IFS=");
right before the line
https://github.com/eXeC64/imv/blob/eeaf5e3cb983befd20bc5d706f5b8e7cd321decf/src/imv.c#L1947
preserves the newlines in overlay text.
The manual for wordexp says that setting IFS
is the only way to control this behavior. This seems like a dirty solution to me: setting IFS
to an empty string will break many user shell commands. For example:
$ echo $(echo 'a b') # prints 1 space, “a” and “b” are distinct arguments
a b
$ export IFS=
$ echo $(echo 'a b') # prints 4 spaces, “a b” is treated as one argument
a b
So setting IFS
doesn't seem acceptable to me, and I don't see a cleaner way to keep newlines while still using wordexp.
@eXeC64, would it make sense to add another shell expansion mechanism for overlay_text
? We can keep it compatible with the current wordexp-based one or not.
One thing we could do is let the user run a shell command and use its output as overlay text. Interface-wise, we could trigger this by a special prefix in overlay_text
parameter. For example, overlay_text = hello $(echo world)
will trigger the current wordexp expansion, while overlay_text = sh:echo hello world
will run echo hello world
and use its output as overlay.
We could also use some library that implements wordexp functionality in a cleaner way. Quick googling didin't give me any though.
Let me know what you think.