changeset: 6648:391492f27fef
user: Kevin McCarthy <[email protected]>
date: Tue May 10 09:42:27 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/391492f27fef
Set COLUMNS to MuttIndexWindow->cols in mutt_create_filter_fd. (closes #3837)
This allows filters to automatically (or via a command line argument)
adjust to the width of the pager/index. This is even more important
with the sidebar, since the width of the pager is smaller than the
terminal width.
Thanks to Vincent Lefèvre for his helpful information and suggestions,
and to Richard Russon for the initial patches.
diffs (53 lines):
diff -r d18cd04e3f5a -r 391492f27fef doc/manual.xml.head
--- a/doc/manual.xml.head Mon May 09 14:06:59 2016 -0700
+++ b/doc/manual.xml.head Tue May 10 09:42:27 2016 -0700
@@ -6773,6 +6773,17 @@
</para>
<para>
+Mutt will set the <literal>COLUMNS</literal> environment variable to
+the width of the pager. Some programs make use of this environment
+variable automatically. Others provide a command line argument that
+can use this to set the output width:
+</para>
+
+<screen>
+text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput
+</screen>
+
+<para>
Note that when using the built-in pager, <emphasis>only</emphasis>
entries with this flag will be considered a handler for a MIME type
— all other entries will be ignored.
diff -r d18cd04e3f5a -r 391492f27fef filter.c
--- a/filter.c Mon May 09 14:06:59 2016 -0700
+++ b/filter.c Tue May 10 09:42:27 2016 -0700
@@ -21,6 +21,7 @@
#endif
#include "mutt.h"
+#include "mutt_curses.h"
#include <unistd.h>
#include <stdlib.h>
@@ -34,6 +35,7 @@
int fdin, int fdout, int fderr)
{
int pin[2], pout[2], perr[2], thepid;
+ char columns[11];
if (in)
{
@@ -117,6 +119,12 @@
close (fderr);
}
+ if (MuttIndexWindow && (MuttIndexWindow->cols > 0))
+ {
+ snprintf (columns, sizeof (columns), "%d", MuttIndexWindow->cols);
+ setenv ("COLUMNS", columns, 1);
+ }
+
execl (EXECSHELL, "sh", "-c", cmd, NULL);
_exit (127);
}