</screen>
</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">
WHERE bool C_SidebarVisible; ///< Config: (sidebar) Show the sidebar
WHERE bool C_SidebarOnRight; ///< Config: (sidebar) Display the sidebar on the right
#endif
+WHERE bool C_SizeShowBytes; ///< Config: Show smaller sizes in bytes
+WHERE bool C_SizeShowFractions; ///< Config: Show size fractions with a single decimal place
+WHERE bool C_SizeShowMb; ///< Config: Show sizes in megabytes for sizes greater than 1 megabyte
+WHERE bool C_SizeUnitsOnLeft; ///< Config: Show the units as a prefix to the size
WHERE bool C_StatusOnTop; ///< Config: Display the status bar at the top
WHERE bool C_Suspend; ///< Config: Allow the user to suspend NeoMutt using '^Z'
WHERE bool C_TextFlowed; ///< Config: Generate 'format=flowed' messages
** .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 Graphic tree characters
** .dt %t .dd Tagged flag
** .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 NeoMutt 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 %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 Current message number
- ** .dt %c .dd Number of characters (bytes) in the message
+ ** .dt %c .dd Number of characters (bytes) in the message (see $formatstrings-size)
** .dt %D .dd Date and time of message using $date_format and local timezone
** .dt %d .dd Date and time of message using $date_format and sender's timezone
** .dt %e .dd Current message number in thread
** 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, &C_SizeShowBytes, false },
+ /*
+ ** .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, &C_SizeShowFractions, true },
+ /*
+ ** .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, &C_SizeShowMb, true },
+ /*
+ ** .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, &C_SizeUnitsOnLeft, false },
+ /*
+ ** .pp
+ ** If \fIset\fP, message sizes units will be displayed to the left of the number.
+ ** See $formatstrings-size.
+ */
{ "skip_quoted_offset", DT_NUMBER|DT_NOT_NEGATIVE, &C_SkipQuotedOffset, 0 },
/*
** .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 *
return src;
}
-/**
- * mutt_str_pretty_size - Display an abbreviated size, like 3.4K
- * @param buf Buffer for the result
- * @param buflen Length of the buffer
- * @param num Number to abbreviate
- */
-void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
-{
- if (!buf || (buflen == 0))
- return;
-
- if (num < 1000)
- {
- snprintf(buf, buflen, "%dB", (int) num);
- }
- else if (num < 10189) /* 0.1K - 9.9K */
- {
- snprintf(buf, buflen, "%3.1fK", num / 1024.0);
- }
- else if (num < 1023949) /* 10K - 999K */
- {
- /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
- snprintf(buf, buflen, "%zuK", (num + 51) / 1024);
- }
- else if (num < 10433332) /* 1.0M - 9.9M */
- {
- snprintf(buf, buflen, "%3.1fM", num / 1048576.0);
- }
- else /* 10M+ */
- {
- /* (10433332 + 52428) / 1048576 = 10 */
- snprintf(buf, buflen, "%zuM", (num + 52428) / 1048576);
- }
-}
-
/**
* mutt_str_getenv - Get an environment variable
* @param name Environment variable to get
size_t mutt_str_lws_len(const char *s, size_t n);
size_t mutt_str_lws_rlen(const char *s, size_t n);
const char *mutt_str_next_word(const char *s);
-void mutt_str_pretty_size(char *buf, size_t buflen, size_t num);
int mutt_str_remall_strcasestr(char *str, const char *target);
void mutt_str_remove_trailing_ws(char *s);
void mutt_str_replace(char **p, const char *s);
mutt_buffer_addch(buf, *path);
}
}
+
+/**
+ * mutt_str_pretty_size - Display an abbreviated size, like 3.4K
+ * @param buf Buffer for the result
+ * @param buflen Length of the buffer
+ * @param num Number to abbreviate
+ */
+void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
+{
+ if (!buf || (buflen == 0))
+ return;
+
+ if (C_SizeShowBytes && (num < 1024))
+ {
+ snprintf(buf, buflen, "%d", (int) num);
+ }
+ else if (num == 0)
+ {
+ mutt_str_strfcpy(buf, C_SizeUnitsOnLeft ? "K0" : "0K", buflen);
+ }
+ else if (C_SizeShowFractions && (num < 10189)) /* 0.1K - 9.9K */
+ {
+ snprintf(buf, buflen, C_SizeUnitsOnLeft ? "K%3.1f" : "%3.1fK",
+ (num < 103) ? 0.1 : (num / 1024.0));
+ }
+ else if (!C_SizeShowMb || (num < 1023949)) /* 10K - 999K */
+ {
+ /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
+ snprintf(buf, buflen, C_SizeUnitsOnLeft ? ("K%zu") : ("%zuK"), (num + 51) / 1024);
+ }
+ else if (C_SizeShowFractions && (num < 10433332)) /* 1.0M - 9.9M */
+ {
+ snprintf(buf, buflen, C_SizeUnitsOnLeft ? "M%3.1f" : "%3.1fM", num / 1048576.0);
+ }
+ else /* 10M+ */
+ {
+ /* (10433332 + 52428) / 1048576 = 10 */
+ snprintf(buf, buflen, C_SizeUnitsOnLeft ? ("M%zu") : ("%zuM"), (num + 52428) / 1048576);
+ }
+}
int mutt_save_confirm(const char *s, struct stat *st);
void mutt_save_path(char *d, size_t dsize, const struct Address *a);
void mutt_sleep(short s);
+void mutt_str_pretty_size(char *buf, size_t buflen, size_t num);
#define mutt_mktemp(buf, buflen) mutt_mktemp_pfx_sfx(buf, buflen, "neomutt", NULL)
#define mutt_mktemp_pfx_sfx(buf, buflen, prefix, suffix) mutt_mktemp_full(buf, buflen, prefix, suffix, __FILE__, __LINE__)
#include "curs_lib.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
+#include "muttlib.h"
#include "options.h"
/* These Config Variables are only used in progress.c */