* @param t1 Text part 1
* @param t2 Text part 2
* @param t3 Text part 3
+ * @param wraplen Width to wrap to
*
* Assemble the three columns of text.
*
* * 0 : Non-macro
* * -1 : Macro with no description
*/
-static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2, const char *t3)
+static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2,
+ const char *t3, int wraplen)
{
int col;
int col_b;
fputs(t1, fp);
/* don't try to press string into one line with less than 40 characters. */
- bool split = (MuttIndexWindow->cols < 40);
+ bool split = (wraplen < 40);
if (split)
{
col = 0;
}
else
{
- const int col_a =
- (MuttIndexWindow->cols > 83) ? (MuttIndexWindow->cols - 32) >> 2 : 12;
- col_b = (MuttIndexWindow->cols > 49) ? (MuttIndexWindow->cols - 10) >> 1 : 19;
+ const int col_a = (wraplen > 83) ? (wraplen - 32) >> 2 : 12;
+ col_b = (wraplen > 49) ? (wraplen - 10) >> 1 : 19;
col = pad(fp, mutt_strwidth(t1), col_a);
}
{
while (*t3)
{
- int n = MuttIndexWindow->cols - col;
+ int n = wraplen - col;
if (ismacro >= 0)
{
}
else
{
- n += col - MuttIndexWindow->cols;
+ n += col - wraplen;
if (C_Markers)
n++;
}
/**
* dump_menu - Write all the key bindings to a file
- * @param fp File to write to
- * @param menu Current Menu, e.g. #MENU_PAGER
+ * @param fp File to write to
+ * @param menu Current Menu, e.g. #MENU_PAGER
+ * @param wraplen Width to wrap to
*/
-static void dump_menu(FILE *fp, enum MenuType menu)
+static void dump_menu(FILE *fp, enum MenuType menu, int wraplen)
{
struct Keymap *map = NULL;
const struct Binding *b = NULL;
if (map->op == OP_MACRO)
{
if (map->desc)
- format_line(fp, 1, buf, map->macro, map->desc);
+ format_line(fp, 1, buf, map->macro, map->desc, wraplen);
else
- format_line(fp, -1, buf, "macro", map->macro);
+ format_line(fp, -1, buf, "macro", map->macro, wraplen);
}
else
{
b = help_lookup_function(map->op, menu);
format_line(fp, 0, buf, b ? b->name : "UNKNOWN",
- b ? _(HelpStrings[b->op]) : _("ERROR: please report this bug"));
+ b ? _(HelpStrings[b->op]) : _("ERROR: please report this bug"), wraplen);
}
}
}
/**
* dump_unbound - Write out all the operations with no key bindings
- * @param fp File to write to
- * @param funcs All the bindings for the current menu
- * @param map First key map to consider
- * @param aux Second key map to consider
+ * @param fp File to write to
+ * @param funcs All the bindings for the current menu
+ * @param map First key map to consider
+ * @param aux Second key map to consider
+ * @param wraplen Width to wrap to
*/
static void dump_unbound(FILE *fp, const struct Binding *funcs,
- struct Keymap *map, struct Keymap *aux)
+ struct Keymap *map, struct Keymap *aux, int wraplen)
{
for (int i = 0; funcs[i].name; i++)
{
if (!is_bound(map, funcs[i].op) && (!aux || !is_bound(aux, funcs[i].op)))
- format_line(fp, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]));
+ format_line(fp, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]), wraplen);
}
}
/**
* mutt_help - Display the help menu
- * @param menu Current Menu
+ * @param menu Current Menu
+ * @param wraplen Width to wrap to
*/
-void mutt_help(enum MenuType menu)
+void mutt_help(enum MenuType menu, int wraplen)
{
char buf[128];
FILE *fp = NULL;
goto cleanup;
}
- dump_menu(fp, menu);
+ dump_menu(fp, menu, wraplen);
if ((menu != MENU_EDITOR) && (menu != MENU_PAGER))
{
fprintf(fp, "\n%s\n\n", _("Generic bindings:"));
- dump_menu(fp, MENU_GENERIC);
+ dump_menu(fp, MENU_GENERIC, wraplen);
}
fprintf(fp, "\n%s\n\n", _("Unbound functions:"));
if (funcs)
- dump_unbound(fp, funcs, Keymaps[menu], NULL);
+ dump_unbound(fp, funcs, Keymaps[menu], NULL, wraplen);
if (menu != MENU_PAGER)
- dump_unbound(fp, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
+ dump_unbound(fp, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu], wraplen);
mutt_file_fclose(&fp);