~kevin8t8/mutt

67acdd725d6525cc133357bcf16cd7df81c322d1 — Kevin McCarthy 8 days ago 87f5f3f
Add sidebar-first and sidebar-last functions.
5 files changed, 64 insertions(+), 1 deletions(-)

M OPS.SIDEBAR
M curs_main.c
M functions.h
M pager.c
M sidebar.c
M OPS.SIDEBAR => OPS.SIDEBAR +2 -0
@@ 1,3 1,5 @@
OP_SIDEBAR_FIRST "move the highlight to the first mailbox"
OP_SIDEBAR_LAST "move the highlight to the last mailbox"
OP_SIDEBAR_NEXT "move the highlight to next mailbox"
OP_SIDEBAR_NEXT_NEW "move the highlight to next mailbox with new mail"
OP_SIDEBAR_OPEN "open highlighted mailbox"

M curs_main.c => curs_main.c +2 -0
@@ 2575,6 2575,8 @@ int mutt_index_menu (void)
	break;

#ifdef USE_SIDEBAR
      case OP_SIDEBAR_FIRST:
      case OP_SIDEBAR_LAST:
      case OP_SIDEBAR_NEXT:
      case OP_SIDEBAR_NEXT_NEW:
      case OP_SIDEBAR_PAGE_DOWN:

M functions.h => functions.h +4 -0
@@ 183,6 183,8 @@ const struct binding_t OpMain[] = { /* map: index */
  { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },

#ifdef USE_SIDEBAR
  { "sidebar-first",		OP_SIDEBAR_FIRST,		NULL },
  { "sidebar-last",		OP_SIDEBAR_LAST,		NULL },
  { "sidebar-next",		OP_SIDEBAR_NEXT,		NULL },
  { "sidebar-next-new",		OP_SIDEBAR_NEXT_NEW,		NULL },
  { "sidebar-open",		OP_SIDEBAR_OPEN,		NULL },


@@ 308,6 310,8 @@ const struct binding_t OpPager[] = { /* map: pager */
  { "check-stats",	OP_CHECK_STATS,		NULL },

#ifdef USE_SIDEBAR
  { "sidebar-first",		OP_SIDEBAR_FIRST,		NULL },
  { "sidebar-last",		OP_SIDEBAR_LAST,		NULL },
  { "sidebar-next",		OP_SIDEBAR_NEXT,		NULL },
  { "sidebar-next-new",		OP_SIDEBAR_NEXT_NEW,		NULL },
  { "sidebar-open",		OP_SIDEBAR_OPEN,		NULL },

M pager.c => pager.c +2 -0
@@ 2908,6 2908,8 @@ search_next:
	break;

#ifdef USE_SIDEBAR
      case OP_SIDEBAR_FIRST:
      case OP_SIDEBAR_LAST:
      case OP_SIDEBAR_NEXT:
      case OP_SIDEBAR_NEXT_NEW:
      case OP_SIDEBAR_PAGE_DOWN:

M sidebar.c => sidebar.c +54 -1
@@ 52,6 52,7 @@ static int HilIndex = -1;    /* Highlighted mailbox */
static int BotIndex = -1;    /* Last mailbox visible in sidebar */

static int select_next (void);
static int select_prev (void);


/**


@@ 813,6 814,49 @@ void mutt_sb_draw (void)
}

/**
 * select_first - Selects the first unhidden mailbox
 *
 * Returns:
 *      1: Success
 *      0: Failure
 */
static int select_first (void)
{
  int orig_hil_index = HilIndex;

  if (!EntryCount || HilIndex < 0)
    return 0;

  HilIndex = 0;
  if (Entries[HilIndex]->is_hidden)
    if (!select_next ())
      HilIndex = orig_hil_index;

  return (orig_hil_index != HilIndex);
}

/**
 * select_last - Selects the last unhidden mailbox
 *
 * Returns:
 *      1: Success
 *      0: Failure
 */
static int select_last (void)
{
  int orig_hil_index = HilIndex;

  if (!EntryCount || HilIndex < 0)
    return 0;

  HilIndex = EntryCount;
  if (!select_prev ())
    HilIndex = orig_hil_index;

  return (orig_hil_index != HilIndex);
}

/**
 * select_next - Selects the next unhidden mailbox
 *
 * Returns:


@@ 989,7 1033,8 @@ static int select_page_up (void)
 * If the operation is successful, HilBuffy will be set to the new mailbox.
 * This function only *selects* the mailbox, doesn't *open* it.
 *
 * Allowed values are: OP_SIDEBAR_NEXT, OP_SIDEBAR_NEXT_NEW,
 * Allowed values are: OP_SIDEBAR_FIRST, OP_SIDEBAR_LAST,
 * OP_SIDEBAR_NEXT, OP_SIDEBAR_NEXT_NEW,
 * OP_SIDEBAR_PAGE_DOWN, OP_SIDEBAR_PAGE_UP, OP_SIDEBAR_PREV,
 * OP_SIDEBAR_PREV_NEW.
 */


@@ 1003,6 1048,14 @@ void mutt_sb_change_mailbox (int op)

  switch (op)
  {
    case OP_SIDEBAR_FIRST:
      if (! select_first ())
        return;
      break;
    case OP_SIDEBAR_LAST:
      if (! select_last ())
        return;
      break;
    case OP_SIDEBAR_NEXT:
      if (! select_next ())
        return;