</sect2>
+<sect2 id="formatstrings-size">
+<title>Bytes size display</title>
+
+<para>
+Various format strings contain expandos that display the size of
+messages in bytes. This includes
+<literal>%s</literal> in <link linkend="attach-format">$attach_format</link>,
+<literal>%l</literal> in <link linkend="compose-format">$compose_format</link>,
+<literal>%s</literal> in <link linkend="folder-format">$folder_format</link>,
+<literal>%c</literal> in <link linkend="index-format">$index_format</link>,
+and %l and %L in <link linkend="status-format">$status_format</link>.
+There are four configuration variables that can be used to customize
+how the numbers are displayed.
+</para>
+
+<para>
+ <link linkend="size-show-bytes">$size_show_bytes</link>
+ will display the number of bytes when the size is < 1
+ kilobyte. When unset, kilobytes will be displayed instead.
+</para>
+
+<para>
+ <link linkend="size-show-mb">$size_show_mb</link> will display the
+ number of megabytes when the size is >= 1 megabyte. When
+ unset, kilobytes will be displayed instead (which could be a large
+ number).
+</para>
+
+<para>
+ <link linkend="size-show-fractions">$size_show_fractions</link>,
+ will display numbers with a single decimal place for values from
+ 0 to 10 kilobytes, and 1 to 10 megabytes.
+</para>
+
+<para>
+ <link linkend="size-units-on-left">$size_units_on_left</link> will
+ display the unit (<quote>K</quote> or <quote>M</quote> to the left
+ of the number, instead of the right if unset.
+</para>
+
+<para>
+ These variables also affect size display in a few other places, such
+ as progress indicators and attachment delimeters in the pager.
+</para>
+</sect2>
+
</sect1>
<sect1 id="mailto-allow">
** .dt %M .dd MIME subtype
** .dt %n .dd attachment number
** .dt %Q .dd ``Q'', if MIME part qualifies for attachment counting
- ** .dt %s .dd size
+ ** .dt %s .dd size (see $formatstrings-size)
** .dt %t .dd tagged flag
** .dt %T .dd graphic tree characters
** .dt %u .dd unlink (=to delete) flag
** .dl
** .dt %a .dd total number of attachments
** .dt %h .dd local hostname
- ** .dt %l .dd approximate size (in bytes) of the current message
+ ** .dt %l .dd approximate size (in bytes) of the current message (see $formatstrings-size)
** .dt %v .dd Mutt version string
** .de
** .pp
** .dt %m .dd number of messages in the mailbox *
** .dt %n .dd number of unread messages in the mailbox *
** .dt %N .dd N if mailbox has new mail, blank otherwise
- ** .dt %s .dd size in bytes
+ ** .dt %s .dd size in bytes (see $formatstrings-size)
** .dt %t .dd ``*'' if the file is tagged, blank otherwise
** .dt %u .dd owner name (or numeric uid, if missing)
** .dt %>X .dd right justify the rest of the string and pad with character ``X''
** .dt %A .dd reply-to address (if present; otherwise: address of author)
** .dt %b .dd filename of the original message folder (think mailbox)
** .dt %B .dd the list to which the letter was sent, or else the folder name (%b).
- ** .dt %c .dd number of characters (bytes) in the message
+ ** .dt %c .dd number of characters (bytes) in the message (see $formatstrings-size)
** .dt %C .dd current message number
** .dt %d .dd date and time of the message in the format specified by
** $$date_format converted to sender's time zone
** replacing ``%s'' with the supplied string.
** For the default value, ``joe'' would be expanded to: ``~f joe | ~s joe''.
*/
+ { "size_show_bytes", DT_BOOL, R_MENU, {.l=OPTSIZESHOWBYTES}, {.l=0} },
+ /*
+ ** .pp
+ ** If \fIset\fP, message sizes will display bytes for values less than
+ ** 1 kilobyte. See $formatstrings-size.
+ */
+ { "size_show_fractions", DT_BOOL, R_MENU, {.l=OPTSIZESHOWFRACTIONS}, {.l=1} },
+ /*
+ ** .pp
+ ** If \fIset\fP, message sizes will be displayed with a single decimal value
+ ** for sizes from 0 to 10 kilobytes and 1 to 10 megabytes.
+ ** See $formatstrings-size.
+ */
+ { "size_show_mb", DT_BOOL, R_MENU, {.l=OPTSIZESHOWMB}, {.l=1} },
+ /*
+ ** .pp
+ ** If \fIset\fP, message sizes will display megabytes for values greater than
+ ** or equal to 1 megabyte. See $formatstrings-size.
+ */
+ { "size_units_on_left", DT_BOOL, R_MENU, {.l=OPTSIZEUNITSONLEFT}, {.l=0} },
+ /*
+ ** .pp
+ ** If \fIset\fP, message sizes units will be displayed to the left of the number.
+ ** See $formatstrings-size.
+ */
{ "sleep_time", DT_NUM, R_NONE, {.p=&SleepTime}, {.l=1} },
/*
** .pp
** .dt %f .dd the full pathname of the current mailbox
** .dt %F .dd number of flagged messages *
** .dt %h .dd local hostname
- ** .dt %l .dd size (in bytes) of the current mailbox *
+ ** .dt %l .dd size (in bytes) of the current mailbox (see $formatstrings-size) *
** .dt %L .dd size (in bytes) of the messages shown
- ** (i.e., which match the current limit) *
+ ** (i.e., which match the current limit) (see $formatstrings-size) *
** .dt %m .dd the number of messages in the mailbox *
** .dt %M .dd the number of messages shown (i.e., which match the current limit) *
** .dt %n .dd number of new messages in the mailbox *
void mutt_pretty_size (char *s, size_t len, LOFF_T n)
{
- if (n == 0)
- strfcpy (s, "0K", len);
- /* Change in format released in 1.10.0, but reverted after feedback:
- * if (n < 1000)
- * snprintf (s, len, "%d", (int)n);
- */
- else if (n < 10189) /* 0.1K - 9.9K */
- snprintf (s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0);
- else if (n < 1023949) /* 10K - 999K */
+ if (option (OPTSIZESHOWBYTES) && (n < 1024))
+ snprintf (s, len, "%d", (int)n);
+ else if (n == 0)
+ strfcpy (s,
+ option (OPTSIZEUNITSONLEFT) ? "K0" : "0K",
+ len);
+ else if (option (OPTSIZESHOWFRACTIONS) && (n < 10189)) /* 0.1K - 9.9K */
+ {
+ snprintf (s, len,
+ option (OPTSIZEUNITSONLEFT) ? "K%3.1f" : "%3.1fK",
+ (n < 103) ? 0.1 : n / 1024.0);
+ }
+ else if (!option (OPTSIZESHOWMB) || (n < 1023949)) /* 10K - 999K */
{
/* 51 is magic which causes 10189/10240 to be rounded up to 10 */
- snprintf (s, len, OFF_T_FMT "K", (n + 51) / 1024);
+ snprintf (s, len,
+ option (OPTSIZEUNITSONLEFT) ? ("K" OFF_T_FMT) : (OFF_T_FMT "K"),
+ (n + 51) / 1024);
+ }
+ else if (option (OPTSIZESHOWFRACTIONS) && (n < 10433332)) /* 1.0M - 9.9M */
+ {
+ snprintf (s, len,
+ option (OPTSIZEUNITSONLEFT) ? "M%3.1f" : "%3.1fM",
+ n / 1048576.0);
}
- else if (n < 10433332) /* 1.0M - 9.9M */
- snprintf (s, len, "%3.1fM", n / 1048576.0);
else /* 10M+ */
{
/* (10433332 + 52428) / 1048576 = 10 */
- snprintf (s, len, OFF_T_FMT "M", (n + 52428) / 1048576);
+ snprintf (s, len,
+ option (OPTSIZEUNITSONLEFT) ? ("M" OFF_T_FMT) : (OFF_T_FMT "M"),
+ (n + 52428) / 1048576);
}
}