The header field positions enum is now started at 0: the windows compute the relative positioning as needed. A small improvement from this is that the headers now align with the top: there isn't a gap if $help is turned off.
-- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA http://www.8t8.us/configs/gpg-key-transition-statement.txt
# HG changeset patch # User Kevin McCarthy <ke...@8t8.us> # Date 1461089793 25200 # Tue Apr 19 11:16:33 2016 -0700 # Node ID 79ba0bcaf0fd6a9a4fbb50b9359826147c2447a5 # Parent e4297dd150dbae2552c857d80d05b79d6594392f Modify the compose screen to use windows. The header field positions enum is now started at 0: the windows compute the relative positioning as needed. A small improvement from this is that the headers now align with the top: there isn't a gap if $help is turned off. diff --git a/compose.c b/compose.c --- a/compose.c +++ b/compose.c @@ -47,17 +47,17 @@ static const char* There_are_no_attachments = N_("There are no attachments."); #define CHECK_COUNT if (idxlen == 0) { mutt_error _(There_are_no_attachments); break; } enum { - HDR_FROM = 1, + HDR_FROM = 0, HDR_TO, HDR_CC, HDR_BCC, HDR_SUBJECT, HDR_REPLYTO, HDR_FCC, #ifdef MIXMASTER @@ -67,17 +67,17 @@ HDR_CRYPT, HDR_CRYPTINFO, HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ }; #define HDR_XOFFSET 10 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ -#define W (COLS - HDR_XOFFSET) +#define W (MuttIndexWindow->cols - HDR_XOFFSET) static const char * const Prompts[] = { "From: ", "To: ", "Cc: ", "Bcc: ", "Subject: ", @@ -105,17 +105,17 @@ } #include "mutt_crypt.h" static void redraw_crypt_lines (HEADER *msg) { - mvaddstr (HDR_CRYPT, 0, "Security: "); + mutt_window_mvaddstr (MuttIndexWindow, HDR_CRYPT, 0, "Security: "); if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) { addstr(_("Not supported")); return; } if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN)) @@ -139,63 +139,63 @@ else if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) addstr (_(" (S/MIME)")); } if (option (OPTCRYPTOPPORTUNISTICENCRYPT) && (msg->security & OPPENCRYPT)) addstr (_(" (OppEnc mode)")); - clrtoeol (); - move (HDR_CRYPTINFO, 0); - clrtoeol (); + mutt_window_clrtoeol (MuttIndexWindow); + mutt_window_move (MuttIndexWindow, HDR_CRYPTINFO, 0); + mutt_window_clrtoeol (MuttIndexWindow); if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP) && (msg->security & SIGN)) printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN)) { printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); } if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME) && (msg->security & ENCRYPT) && SmimeCryptAlg && *SmimeCryptAlg) { - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), + mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), NONULL(SmimeCryptAlg)); } } #ifdef MIXMASTER static void redraw_mix_line (LIST *chain) { int c; char *t; - mvaddstr (HDR_MIX, 0, " Mix: "); + mutt_window_mvaddstr (MuttIndexWindow, HDR_MIX, 0, " Mix: "); if (!chain) { addstr ("<no chain defined>"); - clrtoeol (); + mutt_window_clrtoeol (MuttIndexWindow); return; } for (c = 12; chain; chain = chain->next) { t = chain->data; if (t && t[0] == '0' && t[1] == '\0') t = "<random>"; - if (c + mutt_strlen (t) + 2 >= COLS) + if (c + mutt_strlen (t) + 2 >= MuttIndexWindow->cols) break; addstr (NONULL(t)); if (chain->next) addstr (", "); c += mutt_strlen (t) + 2; } @@ -237,54 +237,54 @@ } static void draw_envelope_addr (int line, ADDRESS *addr) { char buf[LONG_STRING]; buf[0] = 0; rfc822_write_address (buf, sizeof (buf), addr, 1); - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); + mutt_window_mvprintw (MuttIndexWindow, line, 0, TITLE_FMT, Prompts[line]); mutt_paddstr (W, buf); } static void draw_envelope (HEADER *msg, char *fcc) { draw_envelope_addr (HDR_FROM, msg->env->from); draw_envelope_addr (HDR_TO, msg->env->to); draw_envelope_addr (HDR_CC, msg->env->cc); draw_envelope_addr (HDR_BCC, msg->env->bcc); - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); + mutt_window_mvprintw (MuttIndexWindow, HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT]); mutt_paddstr (W, NONULL (msg->env->subject)); draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); + mutt_window_mvprintw (MuttIndexWindow, HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC]); mutt_paddstr (W, fcc); if (WithCrypto) redraw_crypt_lines (msg); #ifdef MIXMASTER redraw_mix_line (msg->chain); #endif SETCOLOR (MT_COLOR_STATUS); - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); - clrtoeol (); + mutt_window_mvaddstr (MuttIndexWindow, HDR_ATTACH - 1, 0, _("-- Attachments")); + mutt_window_clrtoeol (MuttIndexWindow); NORMAL_COLOR; } static int edit_address_list (int line, ADDRESS **addr) { char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ char *err = NULL; mutt_addrlist_to_local (*addr); rfc822_write_address (buf, sizeof (buf), *addr, 0); - if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) + if (mutt_get_field (Prompts[line], buf, sizeof (buf), M_ALIAS) == 0) { rfc822_free_address (addr); *addr = mutt_parse_adrlist (*addr, buf); *addr = mutt_expand_aliases (*addr); } if (option (OPTNEEDREDRAW)) { @@ -297,17 +297,17 @@ mutt_error (_("Warning: '%s' is a bad IDN."), err); mutt_refresh(); FREE (&err); } /* redraw the expanded list so the user can see the result */ buf[0] = 0; rfc822_write_address (buf, sizeof (buf), *addr, 1); - move (line, HDR_XOFFSET); + mutt_window_move (MuttIndexWindow, line, HDR_XOFFSET); mutt_paddstr (W, buf); return 0; } static int delete_attachment (MUTTMENU *menu, short *idxlen, int x) { ATTACHPTR **idx = (ATTACHPTR **) menu->data; @@ -510,25 +510,25 @@ menu = mutt_new_menu (MENU_COMPOSE); menu->offset = HDR_ATTACH; menu->max = idxlen; menu->make_entry = snd_entry; menu->tag = mutt_tag_attach; menu->data = idx; menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); - + while (loop) { switch (op = mutt_menuLoop (menu)) { case OP_REDRAW: draw_envelope (msg, fcc); menu->offset = HDR_ATTACH; - menu->pagelen = LINES - HDR_ATTACH - 2; + menu->pagelen = MuttIndexWindow->rows - HDR_ATTACH; break; case OP_COMPOSE_EDIT_FROM: menu->redraw = edit_address_list (HDR_FROM, &msg->env->from); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_TO: menu->redraw = edit_address_list (HDR_TO, &msg->env->to); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) @@ -559,35 +559,35 @@ case OP_COMPOSE_EDIT_SUBJECT: if (msg->env->subject) strfcpy (buf, msg->env->subject, sizeof (buf)); else buf[0] = 0; if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) { mutt_str_replace (&msg->env->subject, buf); - move (HDR_SUBJECT, HDR_XOFFSET); + mutt_window_move (MuttIndexWindow, HDR_SUBJECT, HDR_XOFFSET); if (msg->env->subject) mutt_paddstr (W, msg->env->subject); else - clrtoeol(); + mutt_window_clrtoeol(MuttIndexWindow); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_REPLY_TO: menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_FCC: strfcpy (buf, fcc, sizeof (buf)); if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) { strfcpy (fcc, buf, fcclen); mutt_pretty_mailbox (fcc, fcclen); - move (HDR_FCC, HDR_XOFFSET); + mutt_window_move (MuttIndexWindow, HDR_FCC, HDR_XOFFSET); mutt_paddstr (W, fcc); fccSet = 1; } MAYBE_REDRAW (menu->redraw); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_MESSAGE: if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS)) @@ -1050,17 +1050,17 @@ case OP_COMPOSE_NEW_MIME: { char type[STRING]; char *p; int itype; FILE *fp; - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); fname[0] = 0; if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE) != 0 || !fname[0]) continue; mutt_expand_path (fname, sizeof (fname)); /* Call to lookup_mime_type () ? maybe later */ type[0] = 0; @@ -1309,19 +1309,19 @@ #endif } /* Draw formatted compose status line */ if (menu->redraw & REDRAW_STATUS) { compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat)); - move(option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); + mutt_window_move (MuttStatusWindow, 0, 0); SETCOLOR (MT_COLOR_STATUS); - mutt_paddstr (COLS, buf); + mutt_paddstr (MuttStatusWindow->cols, buf); NORMAL_COLOR; menu->redraw &= ~REDRAW_STATUS; } } mutt_menuDestroy (&menu); if (idxlen)
signature.asc
Description: PGP signature