示例#1
0
文件: signal.c 项目: 0xAX/muttx
static void sighandler(int sig)
{
	int save_errno = errno;

	switch(sig)
	{
	case SIGTSTP: /* user requested a suspend */
		if (!bit_val(options, OPTSUSPEND))
			break;
		IsEndwin = isendwin();
		curs_set(1);
		if (!IsEndwin)
			endwin();
		kill(0, SIGSTOP);

	case SIGCONT:
		if (!IsEndwin)
			refresh();
		mutt_curs_set(-1);
		break;

	case SIGWINCH:
		SigWinch = 1;
		break;

	case SIGINT:
		SigInt = 1;
		break;

	}
	errno = save_errno;
}
示例#2
0
文件: curs_lib.c 项目: darnir/neomutt
/**
 * mutt_query_exit - Ask the user if they want to leave NeoMutt
 *
 * This function is called when the user presses the abort key.
 */
void mutt_query_exit(void)
{
  mutt_flushinp();
  curs_set(1);
  if (C_Timeout)
    mutt_getch_timeout(-1); /* restore blocking operation */
  if (mutt_yesorno(_("Exit NeoMutt?"), MUTT_YES) == MUTT_YES)
  {
    mutt_exit(1);
  }
  mutt_clear_error();
  mutt_curs_set(-1);
  SigInt = 0;
}
示例#3
0
CORE_SIGTYPE sigs_sighandler (int sig)
{
  int save_errno = errno;

  switch (sig) {
  case SIGTSTP:                /* user requested a suspend */
#if 0
    if (!option (OPTSUSPEND))
      break;
    IsEndwin = isendwin ();
    curs_set (1);
    if (!IsEndwin)
      endwin ();
#endif
    kill (0, SIGSTOP);

  case SIGCONT:
#if 0
    if (!IsEndwin)
      refresh ();
    mutt_curs_set (-1);
#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
    /* We don't receive SIGWINCH when suspended; however, no harm is done by
     * just assuming we received one, and triggering the 'resize' anyway. */
    SigWinch = 1;
#endif
#endif
    break;

#if 0
#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
  case SIGWINCH:
    SigWinch = 1;
    break;
#endif
#endif

  case SIGINT:
#if 0
    SigInt = 1;
#endif
    break;

  case SIGALRM:
    break;

  }
  errno = save_errno;
}
/* this function is called when the user presses the abort key */
void mutt_query_exit (void)
{
  mutt_flushinp ();
  curs_set (1);
  if (Timeout)
    timeout (-1); /* restore blocking operation */
  if (mutt_yesorno (_("Exit Mutt?"), 1) == 1)
  {
    endwin ();
    exit (0);
  }
  mutt_clear_error();
  mutt_curs_set (-1);
  SigInt = 0;
}
示例#5
0
int mutt_menuLoop (MUTTMENU * menu)
{
  int i = OP_NULL;

  FOREVER {
    if (option (OPTMENUCALLER)) {
      unset_option (OPTMENUCALLER);
      return OP_NULL;
    }


    mutt_curs_set (0);

#ifdef USE_IMAP
    imap_keepalive ();
#endif

    if (menu_redraw (menu) == OP_REDRAW)
      return OP_REDRAW;

    menu->oldcurrent = menu->current;

    if (option (OPTARROWCURSOR))
      move (menu->current - menu->top + menu->offset, SW + 2);
    else if (option (OPTBRAILLEFRIENDLY))
      move (menu->current - menu->top + menu->offset, SW);
    else
      move (menu->current - menu->top + menu->offset, COLS - 1);

    mutt_refresh ();


    /* try to catch dialog keys before ops */
    if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
      return i;

    i = km_dokey (menu->menu);
    if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) {
      if (menu->tagged) {
        mvaddstr (LINES - 1, 0, "Tag-");
        clrtoeol ();
        i = km_dokey (menu->menu);
        menu->tagprefix = 1;
        CLEARLINE (LINES - 1);
      }
      else if (i == OP_TAG_PREFIX) {
        mutt_error _("No tagged entries.");

        i = -1;
      }
      else {                    /* None tagged, OP_TAG_PREFIX_COND */

        event_t tmp;

        while (UngetCount > 0) {
          tmp = mutt_getch ();
          if (tmp.op == OP_END_COND)
            break;
        }
        mutt_message _("Nothing to do.");

        i = -1;
      }
    }
    else if (menu->tagged && option (OPTAUTOTAG))
      menu->tagprefix = 1;
    else
      menu->tagprefix = 0;

    mutt_curs_set (1);

#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
    if (SigWinch) {
      mutt_resize_screen ();
      menu->redraw = REDRAW_FULL;
      SigWinch = 0;
      clearok (stdscr, TRUE);   /*force complete redraw */
    }
#endif

    if (i == -1)
      continue;

    if (!menu->dialog)
      mutt_clear_error ();

    /* Convert menubar movement to scrolling */
    if (menu->dialog)
      i = menu_dialog_translate_op (i);

    switch (i) {
    case OP_NEXT_ENTRY:
      menu_next_entry (menu);
      break;
    case OP_PREV_ENTRY:
      menu_prev_entry (menu);
      break;
    case OP_HALF_DOWN:
      menu_half_down (menu);
      break;
    case OP_HALF_UP:
      menu_half_up (menu);
      break;
    case OP_NEXT_PAGE:
      menu_next_page (menu);
      break;
    case OP_PREV_PAGE:
      menu_prev_page (menu);
      break;
    case OP_NEXT_LINE:
      menu_next_line (menu);
      break;
    case OP_PREV_LINE:
      menu_prev_line (menu);
      break;
    case OP_FIRST_ENTRY:
      menu_first_entry (menu);
      break;
    case OP_LAST_ENTRY:
      menu_last_entry (menu);
      break;
    case OP_TOP_PAGE:
      menu_top_page (menu);
      break;
    case OP_MIDDLE_PAGE:
      menu_middle_page (menu);
      break;
    case OP_BOTTOM_PAGE:
      menu_bottom_page (menu);
      break;
    case OP_CURRENT_TOP:
      menu_current_top (menu);
      break;
    case OP_CURRENT_MIDDLE:
      menu_current_middle (menu);
      break;
    case OP_CURRENT_BOTTOM:
      menu_current_bottom (menu);
      break;
    case OP_SEARCH:
    case OP_SEARCH_REVERSE:
    case OP_SEARCH_NEXT:
    case OP_SEARCH_OPPOSITE:
      if (menu->search && !menu->dialog) {      /* Searching dialogs won't work */
        menu->oldcurrent = menu->current;
        if ((menu->current = menu_search (menu, i)) != -1)
          menu->redraw = REDRAW_MOTION;
        else
          menu->current = menu->oldcurrent;
      }
      else
        mutt_error _("Search is not implemented for this menu.");
      break;

    case OP_JUMP:
      if (menu->dialog)
        mutt_error (_("Jumping is not implemented for dialogs."));

      else
        menu_jump (menu);
      break;

    case OP_ENTER_COMMAND:
      CurrentMenu = menu->menu;
      mutt_enter_command ();
      if (option (OPTFORCEREDRAWINDEX)) {
        menu->redraw = REDRAW_FULL;
        unset_option (OPTFORCEREDRAWINDEX);
        unset_option (OPTFORCEREDRAWPAGER);
      }
      break;

    case OP_TAG:
      if (menu->tag && !menu->dialog) {
        if (menu->tagprefix && !option (OPTAUTOTAG)) {
          for (i = 0; i < menu->max; i++)
            menu->tagged += menu->tag (menu, i, 0);
          menu->redraw = REDRAW_INDEX;
        }
        else if (menu->max) {
          int i = menu->tag (menu, menu->current, -1);

          menu->tagged += i;
          if (i && option (OPTRESOLVE) && menu->current < menu->max - 1) {
            menu->current++;
            menu->redraw = REDRAW_MOTION_RESYNCH;
          }
          else
            menu->redraw = REDRAW_CURRENT;
        }
        else
          mutt_error _("No entries.");
      }
      else
        mutt_error _("Tagging is not supported.");
      break;

    case OP_SHELL_ESCAPE:
      mutt_shell_escape ();
      MAYBE_REDRAW (menu->redraw);
      break;

    case OP_WHAT_KEY:
      mutt_what_key ();
      break;

    case OP_REBUILD_CACHE:
      mx_rebuild_cache ();
      break;

    case OP_REDRAW:
      clearok (stdscr, TRUE);
      menu->redraw = REDRAW_FULL;
      break;

    case OP_HELP:
      mutt_help (menu->menu);
      menu->redraw = REDRAW_FULL;
      break;

    case OP_NULL:
      km_error_key (menu->menu);
      break;

    case OP_END_COND:
      break;

    default:
      return (i);
    }
  }
  /* not reached */
}