"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.1/src/options_menu.c" (12 Oct 2016, 105665 Bytes) of package /linux/misc/tin-2.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "options_menu.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.4.0_vs_2.4.1.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : options_menu.c
    4  *  Author    : Michael Bienia <michael@vorlon.ping.de>
    5  *  Created   : 2004-09-05
    6  *  Updated   : 2016-04-27
    7  *  Notes     : Split from config.c
    8  *
    9  * Copyright (c) 2004-2017 Michael Bienia <michael@vorlon.ping.de>
   10  * All rights reserved.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. The name of the author may not be used to endorse or promote
   21  *    products derived from this software without specific prior written
   22  *    permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   28  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   30  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   32  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   35  */
   36 
   37 
   38 #ifndef TIN_H
   39 #   include "tin.h"
   40 #endif /* !TIN_H */
   41 #ifndef TINCFG_H
   42 #   include "tincfg.h"
   43 #endif /* !TINCFG_H */
   44 #ifndef TCURSES_H
   45 #   include "tcurses.h"
   46 #endif /* !TCURSES_H */
   47 
   48 
   49 #define option_lines_per_page (cLINES - INDEX_TOP - 3)
   50 
   51 #define UPDATE_INT_ATTRIBUTES(option) do { \
   52         scopes[0].attribute->option = tinrc.option; \
   53         changed |= MISC_OPTS; \
   54     } while (0)
   55 
   56 #define CAO(A, O) A ## O
   57 #define SET_NUM_ATTRIBUTE(option) do { \
   58         curr_scope->attribute->option = CAO(tinrc.attrib_, option); \
   59         curr_scope->state->option = TRUE; \
   60         changed |= MISC_OPTS; \
   61     } while (0)
   62 #define SET_STRING_ATTRIBUTE(opt) do { \
   63         if (!strlen(CAO(tinrc.attrib_, opt))) { \
   64             reset_state(option); \
   65             redraw_screen(option); \
   66         } else { \
   67             FreeIfNeeded(curr_scope->attribute->opt); \
   68             curr_scope->state->opt = TRUE; \
   69             curr_scope->attribute->opt = my_strdup(CAO(tinrc.attrib_, opt)); \
   70         } \
   71         changed |= MISC_OPTS; \
   72     } while (0)
   73 
   74 static enum option_enum first_option_on_screen, last_option_on_screen, last_opt;
   75 
   76 /*
   77  * local prototypes
   78  */
   79 static enum option_enum get_first_opt(void);
   80 static enum option_enum move_cursor(enum option_enum cur_option, t_bool down);
   81 static enum option_enum next_option(enum option_enum option, t_bool incl_titles);
   82 static enum option_enum opt_scroll_down(enum option_enum option);
   83 static enum option_enum opt_scroll_up(enum option_enum option);
   84 static enum option_enum prev_option(enum option_enum option, t_bool incl_titles);
   85 static enum option_enum set_option_num(int num);
   86 static int add_new_scope(void);
   87 static int find_scope(const char *scope);
   88 static int get_option_num(enum option_enum option);
   89 static int move_scope(int curr_pos);
   90 static t_bool check_state(enum option_enum option);
   91 static t_bool delete_scope(int curr_pos);
   92 static t_bool option_is_title(enum option_enum option);
   93 static t_bool option_on_page(enum option_enum option);
   94 static t_bool rename_scope(struct t_scope *scope);
   95 static t_bool scope_is_empty(void);
   96 static t_function option_left(void);
   97 static t_function option_right(void);
   98 static t_function scope_left(void);
   99 static t_function scope_right(void);
  100 static void build_scope_line(int i);
  101 static void do_delete_scope(int curr_pos);
  102 static void do_move_scope(int from, int to);
  103 static void draw_scope_arrow(void);
  104 static void free_scopes_and_attributes(void);
  105 static void highlight_option(enum option_enum option);
  106 static void initialize_attributes(void);
  107 static void print_any_option(enum option_enum option);
  108 static void redraw_screen(enum option_enum option);
  109 static void repaint_option(enum option_enum option);
  110 static void reset_state(enum option_enum option);
  111 static void scope_page(enum context level);
  112 static void set_first_option_on_screen(enum option_enum last_option);
  113 static void set_last_opt(void);
  114 static void set_last_option_on_screen(enum option_enum first_option);
  115 static void show_config_page(void);
  116 static void show_scope_page(void);
  117 static void unhighlight_option(enum option_enum option);
  118 #ifdef USE_CURSES
  119     static void do_scroll(int jump);
  120 #endif /* USE_CURSES */
  121 
  122 static t_menu scopemenu = { 0, 0, 0, show_scope_page, draw_scope_arrow, build_scope_line };
  123 static struct t_scope *curr_scope = NULL;
  124 
  125 /*
  126  * returns the row on the screen of an option
  127  * note: option should be on this page
  128  */
  129 int
  130 option_row(
  131     enum option_enum option)
  132 {
  133     int i = 0;
  134     enum option_enum j = first_option_on_screen;
  135 
  136     while (j < option) {
  137         if (option_is_visible(j))
  138             i++;
  139         j++;
  140     }
  141 
  142     return INDEX_TOP + i;
  143 }
  144 
  145 
  146 /*
  147  * returns the number of an option
  148  */
  149 static int
  150 get_option_num(
  151     enum option_enum option)
  152 {
  153     enum option_enum i;
  154     int result = 0;
  155 
  156     for (i = 0; i < option && result < (int) last_opt; i = next_option(i, FALSE))
  157         result++;
  158 
  159     return result;
  160 }
  161 
  162 
  163 /*
  164  * returns the option with the given number
  165  */
  166 static enum option_enum
  167 set_option_num(
  168     int num)
  169 {
  170     enum option_enum result = 0;
  171 
  172     while (num > 0 && result < last_opt) {
  173         result = next_option(result, FALSE);
  174         num--;
  175     }
  176     return result;
  177 }
  178 
  179 
  180 /*
  181  * returns TRUE if an option is visible in the menu
  182  */
  183 t_bool
  184 option_is_visible(
  185     enum option_enum option)
  186 {
  187     switch (option) {
  188 #ifdef HAVE_COLOR
  189         case OPT_COL_BACK:
  190         case OPT_COL_FROM:
  191         case OPT_COL_HEAD:
  192         case OPT_COL_HELP:
  193         case OPT_COL_INVERS_BG:
  194         case OPT_COL_INVERS_FG:
  195         case OPT_COL_MESSAGE:
  196         case OPT_COL_MINIHELP:
  197         case OPT_COL_NEWSHEADERS:
  198         case OPT_COL_NORMAL:
  199         case OPT_COL_QUOTE:
  200         case OPT_COL_QUOTE2:
  201         case OPT_COL_QUOTE3:
  202         case OPT_COL_EXTQUOTE:
  203         case OPT_COL_RESPONSE:
  204         case OPT_COL_SIGNATURE:
  205         case OPT_COL_SUBJECT:
  206         case OPT_COL_TEXT:
  207         case OPT_COL_TITLE:
  208         case OPT_COL_URLS:
  209         case OPT_QUOTE_REGEX:
  210         case OPT_QUOTE_REGEX2:
  211         case OPT_QUOTE_REGEX3:
  212         case OPT_EXTQUOTE_HANDLING:
  213             return curr_scope ? FALSE : tinrc.use_color;
  214 
  215         case OPT_COL_MARKSTAR:
  216         case OPT_COL_MARKDASH:
  217         case OPT_COL_MARKSLASH:
  218         case OPT_COL_MARKSTROKE:
  219             return curr_scope ? FALSE : (tinrc.word_highlight && tinrc.use_color);
  220 
  221         case OPT_COL_VERBATIM:
  222             return curr_scope ? FALSE : (tinrc.verbatim_handling && tinrc.use_color);
  223 
  224         case OPT_EXTQUOTE_REGEX:
  225             return curr_scope ? FALSE : (tinrc.extquote_handling && tinrc.use_color);
  226 #endif /* HAVE_COLOR */
  227 
  228         case OPT_WORD_H_DISPLAY_MARKS:
  229         case OPT_SLASHES_REGEX:
  230         case OPT_STARS_REGEX:
  231         case OPT_STROKES_REGEX:
  232         case OPT_UNDERSCORES_REGEX:
  233             return curr_scope ? FALSE : tinrc.word_highlight;
  234 
  235         case OPT_MONO_MARKSTAR:
  236         case OPT_MONO_MARKDASH:
  237         case OPT_MONO_MARKSLASH:
  238         case OPT_MONO_MARKSTROKE:
  239 #ifdef HAVE_COLOR
  240             return curr_scope ? FALSE : (tinrc.word_highlight && !tinrc.use_color);
  241 #else
  242             return curr_scope ? FALSE : tinrc.word_highlight;
  243 #endif /* HAVE_COLOR */
  244 
  245 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  246         case OPT_UTF8_GRAPHICS:
  247             return curr_scope ? FALSE : IS_LOCAL_CHARSET("UTF-8");
  248 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  249 
  250         case OPT_VERBATIM_BEGIN_REGEX:
  251         case OPT_VERBATIM_END_REGEX:
  252             return curr_scope ? FALSE : tinrc.verbatim_handling;
  253 
  254 #ifndef USE_CURSES
  255         case OPT_STRIP_BLANKS:
  256 #endif /* !USE_CURSES */
  257         case OPT_GETART_LIMIT_OPTIONS:
  258             return curr_scope ? FALSE : TRUE;
  259 
  260 #ifdef HAVE_COLOR
  261         case OPT_COLOR_OPTIONS:
  262             return curr_scope ? tinrc.use_color : TRUE;
  263 #endif /* HAVE_COLOR */
  264 
  265         case OPT_DISPLAY_OPTIONS:
  266         case OPT_FILTERING_OPTIONS:
  267         case OPT_SAVING_OPTIONS:
  268         case OPT_POSTING_OPTIONS:
  269         case OPT_EXPERT_OPTIONS:
  270             return TRUE;
  271 
  272         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
  273         case OPT_ATTRIB_ADVERTISING:
  274         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
  275         case OPT_ATTRIB_ASK_FOR_METAMAIL:
  276         case OPT_ATTRIB_AUTO_CC_BCC:
  277         case OPT_ATTRIB_AUTO_LIST_THREAD:
  278         case OPT_ATTRIB_AUTO_SAVE:
  279         case OPT_ATTRIB_AUTO_SELECT:
  280         case OPT_ATTRIB_BATCH_SAVE:
  281         case OPT_ATTRIB_DATE_FORMAT:
  282         case OPT_ATTRIB_DELETE_TMP_FILES:
  283         case OPT_ATTRIB_EDITOR_FORMAT:
  284         case OPT_ATTRIB_FCC:
  285         case OPT_ATTRIB_FOLLOWUP_TO:
  286         case OPT_ATTRIB_FROM:
  287         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
  288         case OPT_ATTRIB_GROUP_FORMAT:
  289 #ifdef HAVE_ISPELL
  290         case OPT_ATTRIB_ISPELL:
  291 #endif /* HAVE_ISPELL */
  292         case OPT_ATTRIB_MAILDIR:
  293         case OPT_ATTRIB_MAIL_8BIT_HEADER:
  294         case OPT_ATTRIB_MAIL_MIME_ENCODING:
  295         case OPT_ATTRIB_MAILING_LIST:
  296         case OPT_ATTRIB_MARK_IGNORE_TAGS:
  297         case OPT_ATTRIB_MARK_SAVED_READ:
  298         case OPT_ATTRIB_MIME_FORWARD:
  299         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
  300         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
  301         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
  302         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
  303         case OPT_ATTRIB_ORGANIZATION:
  304         case OPT_ATTRIB_POST_8BIT_HEADER:
  305         case OPT_ATTRIB_POST_MIME_ENCODING:
  306         case OPT_ATTRIB_POST_PROCESS_VIEW:
  307         case OPT_ATTRIB_POS_FIRST_UNREAD:
  308         case OPT_ATTRIB_QUICK_KILL_HEADER:
  309         case OPT_ATTRIB_QUICK_KILL_SCOPE:
  310         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
  311         case OPT_ATTRIB_QUICK_KILL_CASE:
  312         case OPT_ATTRIB_QUICK_SELECT_HEADER:
  313         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
  314         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
  315         case OPT_ATTRIB_QUICK_SELECT_CASE:
  316 #ifndef DISABLE_PRINTING
  317         case OPT_ATTRIB_PRINT_HEADER:
  318 #endif /* !DISABLE_PRINTING */
  319         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
  320         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
  321         case OPT_ATTRIB_QUOTE_CHARS:
  322         case OPT_ATTRIB_SAVEDIR:
  323         case OPT_ATTRIB_SAVEFILE:
  324         case OPT_ATTRIB_SHOW_AUTHOR:
  325         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
  326         case OPT_ATTRIB_SHOW_SIGNATURES:
  327         case OPT_ATTRIB_SIGDASHES:
  328         case OPT_ATTRIB_SIGFILE:
  329         case OPT_ATTRIB_SIGNATURE_REPOST:
  330         case OPT_ATTRIB_START_EDITOR_OFFSET:
  331         case OPT_ATTRIB_THREAD_ARTICLES:
  332         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
  333         case OPT_ATTRIB_THREAD_FORMAT:
  334         case OPT_ATTRIB_THREAD_PERC:
  335         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
  336         case OPT_ATTRIB_TEX2ISO_CONV:
  337         case OPT_ATTRIB_SORT_THREADS_TYPE:
  338 #ifdef CHARSET_CONVERSION
  339         case OPT_ATTRIB_MM_NETWORK_CHARSET:
  340         case OPT_ATTRIB_UNDECLARED_CHARSET:
  341 #endif /* CHARSET_CONVERSION */
  342         case OPT_ATTRIB_VERBATIM_HANDLING:
  343         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
  344         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
  345         case OPT_ATTRIB_POST_PROCESS_TYPE:
  346         case OPT_ATTRIB_X_BODY:
  347         case OPT_ATTRIB_X_COMMENT_TO:
  348         case OPT_ATTRIB_X_HEADERS:
  349             return curr_scope ? TRUE : FALSE;
  350 
  351 #ifdef HAVE_COLOR
  352         case OPT_ATTRIB_EXTQUOTE_HANDLING:
  353             return curr_scope ? tinrc.use_color : FALSE;
  354 #endif /* HAVE_COLOR */
  355 
  356         default:
  357             return curr_scope ? FALSE : TRUE;
  358     }
  359 }
  360 
  361 
  362 /*
  363  * returns TRUE if option is OPT_TITLE else FALSE
  364  */
  365 static t_bool
  366 option_is_title(
  367     enum option_enum option)
  368 {
  369     return option_table[option].var_type == OPT_TITLE;
  370 }
  371 
  372 
  373 /*
  374  * returns TRUE if option is on the current page else FALSE
  375  */
  376 static t_bool
  377 option_on_page(
  378     enum option_enum option)
  379 {
  380     return ((option >= first_option_on_screen) && (option <= last_option_on_screen));
  381 }
  382 
  383 
  384 char *
  385 fmt_option_prompt(
  386     char *dst,
  387     size_t len,
  388     t_bool editing,
  389     enum option_enum option)
  390 {
  391     char *buf;
  392     size_t option_width = MAX(35, cCOLS / 2 - 9);
  393 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  394     wchar_t *wbuf, *wbuf2;
  395 
  396     /* convert the option text to wchar_t */
  397     wbuf = char2wchar_t(_(option_table[option].txt->opt));
  398 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  399 
  400     if (!option_is_title(option)) {
  401         char flag;
  402         int num = get_option_num(option);
  403 
  404         flag = (curr_scope && check_state(option)) ? '+' : ' ';
  405 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  406         if (wbuf != NULL) {
  407             wbuf2 = wstrunc(wbuf, option_width);
  408             if ((buf = wchar_t2char(wbuf2)) == NULL) {
  409                 /* conversion failed, truncate original string */
  410                 buf = strunc(_(option_table[option].txt->opt), option_width);
  411                 snprintf(dst, len, "%s %c%3d %-*.*s: ", editing ? "->" : "  ", flag, num, (int) option_width, (int) option_width, buf);
  412             } else
  413                 snprintf(dst, len, "%s %c%3d %-*.*s: ", editing ? "->" : "  ", flag, num,
  414                     (int) (strlen(buf) + option_width - wcswidth(wbuf2, option_width + 1)),
  415                     (int) (strlen(buf) + option_width - wcswidth(wbuf2, option_width + 1)), buf);
  416             free(wbuf2);
  417         } else
  418 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  419         {
  420             /* truncate original string */
  421             buf = strunc(_(option_table[option].txt->opt), option_width);
  422             snprintf(dst, len, "%s %c%3d %-*.*s: ", editing ? "->" : "  ", flag, num, (int) option_width, (int) option_width, buf);
  423         }
  424     } else {
  425 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  426         if (wbuf != NULL) {
  427             wbuf2 = wstrunc(wbuf, cCOLS - 3);
  428             if ((buf = wchar_t2char(wbuf2)) == NULL)    /* conversion failed, truncate original string */
  429                 buf = strunc(_(option_table[option].txt->opt), cCOLS - 3);
  430             free(wbuf2);
  431         } else
  432 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  433             buf = strunc(_(option_table[option].txt->opt), cCOLS - 3);  /* truncate original string */
  434         snprintf(dst, len, "  %s", buf);
  435     }
  436 
  437 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  438     FreeIfNeeded(wbuf);
  439 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  440     FreeIfNeeded(buf);
  441     return dst;
  442 }
  443 
  444 
  445 static void
  446 print_any_option(
  447     enum option_enum option)
  448 {
  449     constext **list;
  450     char temp[LEN], *ptr, *ptr2;
  451     int row = option_row(option);
  452     size_t len = sizeof(temp) - 1;
  453 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE) && defined(USE_CURSES)
  454     char *buf;
  455 #endif /* MULTIBYTE_ABLE && !NO_LOCALE && USE_CURSES */
  456 
  457     MoveCursor(row, 0);
  458 
  459     ptr = fmt_option_prompt(temp, len, FALSE, option);
  460     ptr += strlen(temp);
  461     len -= strlen(temp);
  462 
  463     switch (option_table[option].var_type) {
  464         case OPT_ON_OFF:
  465             /* %-3s to match the length of OFF */
  466             snprintf(ptr, len, "%-3s", print_boolean(*OPT_ON_OFF_list[option_table[option].var_index]));
  467             break;
  468 
  469         case OPT_LIST:
  470             list = option_table[option].opt_list;
  471             ptr2 = my_strdup(list[*(option_table[option].variable) + ((strcasecmp(_(list[0]), _(txt_default)) == 0) ? 1 : 0)]);
  472             strncpy(ptr, _(ptr2), len);
  473             free(ptr2);
  474             break;
  475 
  476         case OPT_STRING:
  477             strncpy(ptr, OPT_STRING_list[option_table[option].var_index], len);
  478             break;
  479 
  480         case OPT_NUM:
  481             snprintf(ptr, len, "%d", *(option_table[option].variable));
  482             break;
  483 
  484         case OPT_CHAR:
  485             snprintf(ptr, len, "%c", *OPT_CHAR_list[option_table[option].var_index]);
  486             break;
  487 
  488         default:
  489             break;
  490     }
  491 #ifdef USE_CURSES
  492 #   if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  493     if ((buf = spart(temp, cCOLS - 1, FALSE)) != NULL) {
  494         my_printf("%s", buf);
  495         free(buf);
  496     } else
  497 #   endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  498         my_printf("%.*s", cCOLS - 1, temp);
  499     {
  500         int y, x;
  501 
  502         getyx(stdscr, y, x);
  503         if (x < cCOLS)
  504             clrtoeol();
  505     }
  506 #else
  507     my_printf("%.*s", cCOLS - 1, temp);
  508     /* draw_arrow_mark() will read this back for repainting */
  509     if (tinrc.strip_blanks)
  510         strncpy(screen[row - INDEX_TOP].col, temp, cCOLS - 1);
  511     else
  512         snprintf(screen[row - INDEX_TOP].col, cCOLS, "%-*s", cCOLS - 1, temp);
  513 #endif /* USE_CURSES */
  514 }
  515 
  516 
  517 static void
  518 repaint_option(
  519     enum option_enum option)
  520 {
  521     if (option_on_page(option))
  522         print_any_option(option);
  523 }
  524 
  525 
  526 #ifdef USE_CURSES
  527 static void
  528 do_scroll(
  529     int jump)
  530 {
  531     scrollok(stdscr, TRUE);
  532     MoveCursor(INDEX_TOP, 0);
  533     SetScrollRegion(INDEX_TOP, INDEX_TOP + option_lines_per_page - 1);
  534     ScrollScreen(jump);
  535     SetScrollRegion(0, LINES - 1);
  536     scrollok(stdscr, FALSE);
  537 }
  538 #endif /* USE_CURSES */
  539 
  540 
  541 /*
  542  * returns the option after moving 'move' positions up or down
  543  * updates also first_option_on_screen and last_option_on screen accordingly
  544  */
  545 static enum option_enum
  546 move_cursor(
  547     enum option_enum cur_option,
  548     t_bool down)
  549 {
  550     enum option_enum old_option = cur_option;
  551 
  552     if (down) {     /* move down */
  553         do {
  554             cur_option = next_option(cur_option, TRUE);
  555             if (cur_option > last_option_on_screen) {
  556                 /* move the markers one option down */
  557                 last_option_on_screen = cur_option;
  558                 first_option_on_screen = next_option(first_option_on_screen, TRUE);
  559 #ifdef USE_CURSES
  560                 do_scroll(1);
  561                 print_any_option(cur_option);
  562 #else
  563                 show_config_page();
  564 #endif /* USE_CURSES */
  565             } else if (cur_option < first_option_on_screen) {
  566                 /* wrap around: set to begin of option list */
  567                 first_option_on_screen = cur_option;
  568                 set_last_option_on_screen(cur_option);
  569                 show_config_page();
  570             }
  571         } while (option_is_title(cur_option) && old_option != cur_option);
  572     } else {        /* move up */
  573         do {
  574             cur_option = prev_option(cur_option, TRUE);
  575             if (cur_option < first_option_on_screen) {
  576                 /* move the markers one option up */
  577                 first_option_on_screen = cur_option;
  578                 set_last_option_on_screen(cur_option);
  579 #ifdef USE_CURSES
  580                 do_scroll(-1);
  581                 print_any_option(cur_option);
  582 #else
  583                 show_config_page();
  584 #endif /* USE_CURSES */
  585             } else if (cur_option > last_option_on_screen) {
  586                 /* wrap around: set to end of option list */
  587                 last_option_on_screen = cur_option;
  588                 set_first_option_on_screen(cur_option);
  589                 show_config_page();
  590             }
  591         } while (option_is_title(cur_option) && old_option != cur_option);
  592     }
  593     return cur_option;
  594 }
  595 
  596 
  597 /*
  598  * scroll the screen one line down
  599  * the selected option is only moved if it is scrolled off the screen
  600  */
  601 static enum option_enum
  602 opt_scroll_down(
  603     enum option_enum option)
  604 {
  605     if (last_option_on_screen < last_opt) {
  606         first_option_on_screen = next_option(first_option_on_screen, TRUE);
  607         set_last_option_on_screen(first_option_on_screen);
  608 #ifdef USE_CURSES
  609         do_scroll(1);
  610         print_any_option(last_option_on_screen);
  611         stow_cursor();
  612 #else
  613         show_config_page();
  614 #endif /* USE_CURSES */
  615         if (option < first_option_on_screen) {
  616             option = first_option_on_screen;
  617             if (option_is_title(option))
  618                 option = next_option(option, FALSE);
  619 #ifdef USE_CURSES
  620             highlight_option(option);
  621 #endif /* USE_CURSES */
  622         }
  623 #ifndef USE_CURSES
  624         /* in the !USE_CURSES case we must always highlight the option */
  625         highlight_option(option);
  626 #endif /* !USE_CURSES */
  627     }
  628     return option;
  629 }
  630 
  631 
  632 /*
  633  * scroll the screen one line up
  634  * the selected option is only moved if it is scrolled off the screen
  635  */
  636 static enum option_enum
  637 opt_scroll_up(
  638     enum option_enum option)
  639 {
  640     if (first_option_on_screen > 0) {
  641         first_option_on_screen = prev_option(first_option_on_screen, TRUE);
  642         set_last_option_on_screen(first_option_on_screen);
  643 #ifdef USE_CURSES
  644         do_scroll(-1);
  645         print_any_option(first_option_on_screen);
  646         stow_cursor();
  647 #else
  648         show_config_page();
  649 #endif /* USE_CURSES */
  650         if (option > last_option_on_screen) {
  651             option = last_option_on_screen;
  652             if (option_is_title(option))
  653                 option = prev_option(option, FALSE);
  654 #ifdef USE_CURSES
  655             highlight_option(option);
  656 #endif /* USE_CURSES */
  657         }
  658 #ifndef USE_CURSES
  659         /* in the !USE_CURSES case we must always highlight the option */
  660         highlight_option(option);
  661 #endif /* !USE_CURSES */
  662     }
  663     return option;
  664 }
  665 
  666 
  667 /*
  668  * returns the next visible option
  669  * if 'incl_titles' is TRUE titles are also returned else they are skipped
  670  */
  671 static enum option_enum
  672 next_option(
  673     enum option_enum option,
  674     t_bool incl_titles)
  675 {
  676     do {
  677         option++;
  678         if (option > last_opt)
  679             option = 0;
  680     } while (!(option_is_visible(option) && (incl_titles || !option_is_title(option))));
  681 
  682     return option;
  683 }
  684 
  685 
  686 /*
  687  * returns the previous visible option
  688  * if 'incl_titles' is TRUE titles are also returned else they are skipped
  689  */
  690 static enum option_enum
  691 prev_option(
  692     enum option_enum option,
  693     t_bool incl_titles)
  694 {
  695     do {
  696         if (option == 0)
  697             option = last_opt;
  698         else
  699             option--;
  700     } while (!(option_is_visible(option) && (incl_titles || !option_is_title(option))));
  701 
  702     return option;
  703 }
  704 
  705 
  706 /*
  707  * set first_option_on_screen in such way that 'last_option' will be
  708  * the last option on the screen
  709  */
  710 static void
  711 set_first_option_on_screen(
  712     enum option_enum last_option)
  713 {
  714     int i;
  715 
  716     first_option_on_screen = last_option;
  717     for (i = 1; i < option_lines_per_page && first_option_on_screen > 0; i++)
  718         first_option_on_screen = prev_option(first_option_on_screen, TRUE);
  719 
  720     /*
  721      * make sure that the first page is used completely
  722      */
  723     if (first_option_on_screen == 0)
  724         set_last_option_on_screen(0);
  725 }
  726 
  727 
  728 /*
  729  * set last_option_on_screen in such way that 'first_option' will be
  730  * the first option on the screen
  731  */
  732 static void
  733 set_last_option_on_screen(
  734     enum option_enum first_option)
  735 {
  736     int i;
  737 
  738     last_option_on_screen = first_option;
  739     /*
  740      * on last page, there need not be option_lines_per_page options
  741      */
  742     for (i = 1; i < option_lines_per_page && last_option_on_screen < last_opt; i++)
  743         last_option_on_screen = next_option(last_option_on_screen, TRUE);
  744 }
  745 
  746 
  747 static void
  748 highlight_option(
  749     enum option_enum option)
  750 {
  751     refresh_config_page(option); /* to keep refresh_config_page():last_option up-to-date */
  752     draw_arrow_mark(option_row(option));
  753     info_message("%s", _(option_table[option].txt->opt));
  754 }
  755 
  756 
  757 static void
  758 unhighlight_option(
  759     enum option_enum option)
  760 {
  761     /* Astonishing hack */
  762     t_menu *savemenu = currmenu;
  763     t_menu cfgmenu = { 0, 1, 0, NULL, NULL, NULL };
  764 
  765     currmenu = &cfgmenu;
  766     currmenu->curr = option_row(option) - INDEX_TOP;
  767     erase_arrow();
  768     currmenu = savemenu;
  769     clear_message();
  770 }
  771 
  772 
  773 /*
  774  * Refresh the config page which holds the actual option. If act_option is
  775  * smaller zero fall back on the last given option (first option if there was
  776  * no last option) and refresh the screen.
  777  */
  778 void
  779 refresh_config_page(
  780     enum option_enum act_option)
  781 {
  782     static enum option_enum last_option = 0;
  783     /* t_bool force_redraw = FALSE; */
  784 
  785     if (act_option == SIGNAL_HANDLER) { /* called by signal handler */
  786         /* force_redraw = TRUE; */
  787         act_option = last_option;
  788         set_last_option_on_screen(first_option_on_screen); /* terminal size may have changed */
  789         if (!option_on_page(last_option)) {
  790             last_option_on_screen = last_option;
  791             set_first_option_on_screen(last_option);
  792         }
  793         redraw_screen(last_option);
  794     }
  795     last_option = act_option;
  796 }
  797 
  798 
  799 static void
  800 redraw_screen(
  801     enum option_enum option)
  802 {
  803     show_config_page();
  804     highlight_option(option);
  805 }
  806 
  807 
  808 /*
  809  * show_menu_help
  810  */
  811 void
  812 show_menu_help(
  813     const char *help_message)
  814 {
  815     MoveCursor(cLINES - 2, 0);
  816     CleartoEOLN();
  817     center_line(cLINES - 2, FALSE, _(help_message));
  818 }
  819 
  820 
  821 /*
  822  * display current configuration page
  823  */
  824 static void
  825 show_config_page(
  826     void)
  827 {
  828     enum option_enum i;
  829 
  830     signal_context = curr_scope ? cAttrib : cConfig;
  831     mark_offset = 0;
  832 
  833     ClearScreen();
  834     center_line(0, TRUE, curr_scope ? curr_scope->scope : _(txt_options_menu));
  835 
  836     for (i = first_option_on_screen; i <= last_option_on_screen; i++) {
  837         while (!option_is_visible(i))
  838             i++;
  839         if (i > last_opt)
  840             break;
  841         print_any_option(i);
  842     }
  843 
  844     show_menu_help(txt_select_config_file_option);
  845     my_flush();
  846     stow_cursor();
  847 }
  848 
  849 
  850 /*
  851  * Check if score_kill is <= score_limit_kill and if score_select >= score_limit_select
  852  */
  853 void
  854 check_score_defaults(
  855     void)
  856 {
  857     if (tinrc.score_kill > tinrc.score_limit_kill)
  858         tinrc.score_kill = tinrc.score_limit_kill;
  859 
  860     if (tinrc.score_select < tinrc.score_limit_select)
  861         tinrc.score_select = tinrc.score_limit_select;
  862 }
  863 
  864 
  865 static t_function
  866 option_left(
  867     void)
  868 {
  869     return GLOBAL_QUIT;
  870 }
  871 
  872 
  873 static t_function
  874 option_right(
  875     void)
  876 {
  877     return CONFIG_SELECT;
  878 }
  879 
  880 
  881 /*
  882  * set last_opt to the last visible option
  883  */
  884 static void
  885 set_last_opt(
  886     void)
  887 {
  888     enum option_enum i;
  889 
  890     for (i = 0; i <= LAST_OPT; i++) {
  891         if (option_is_visible(i))
  892             last_opt = i;
  893     }
  894 }
  895 
  896 
  897 /*
  898  * returns the first visible option
  899  */
  900 static enum option_enum
  901 get_first_opt(
  902     void)
  903 {
  904     enum option_enum i;
  905 
  906     for (i = 0; i <= last_opt; i++) {
  907         if (option_is_visible(i) && !option_is_title(i))
  908             break;
  909     }
  910     return i;
  911 }
  912 
  913 
  914 /*
  915  * options menu so that the user can dynamically change parameters
  916  */
  917 void
  918 config_page(
  919     const char *grpname,
  920     enum context level)
  921 {
  922     char key[MAXKEYLEN];
  923     enum option_enum option, old_option;
  924     enum {
  925         NOT_CHANGED         = 0,
  926         MISC_OPTS           = 1 << 0,
  927         DISPLAY_OPTS        = 1 << 1,
  928         SCORE_OPTS          = 1 << 2,
  929         SHOW_AUTHOR         = 1 << 3,
  930         SHOW_ONLY_UNREAD    = 1 << 4,
  931         SORT_OPTS           = 1 << 5,
  932         THREAD_ARTS         = 1 << 6,
  933         THREAD_SCORE        = 1 << 7
  934     } changed = NOT_CHANGED;
  935     int i, scope_idx = 0;
  936     t_bool change_option = FALSE;
  937     t_function func;
  938 #ifdef CHARSET_CONVERSION
  939     t_bool is_7bit;
  940 #endif /* CHARSET_CONVERSION */
  941     unsigned old_show_author = 0, old_show_unread = 0, old_thread_arts = 0;
  942 
  943     if (curr_scope)
  944         initialize_attributes();
  945     if (grpname && curr_group) {
  946         /*
  947          * These things can be toggled by the user,
  948          * keep a copy of the current value to restore
  949          * the state if necessary
  950          */
  951         old_show_author = curr_group->attribute->show_author;
  952         old_show_unread = curr_group->attribute->show_only_unread_arts;
  953         old_thread_arts = curr_group->attribute->thread_articles;
  954     }
  955     set_last_opt();
  956     option = get_first_opt();
  957     first_option_on_screen = 0;
  958     set_last_option_on_screen(0);
  959 
  960     redraw_screen(option);
  961     set_xclick_off();
  962 
  963     forever {
  964         switch ((func = handle_keypad(option_left, option_right, NULL, option_menu_keys))) {
  965             case GLOBAL_QUIT:
  966                 if (grpname) {
  967                     if (curr_scope && scope_is_empty()) {
  968                         /*
  969                          * Called via TAB from Config 'M'enu and all attributes
  970                          * have default values -> delete scope
  971                          */
  972                         do_delete_scope(scope_idx);
  973                         curr_scope = NULL;
  974                     }
  975                     if (changed) {
  976                         /*
  977                          * At least one option or attribute has changed,
  978                          * write config files
  979                          */
  980                         write_config_file(local_config_file);
  981                         write_attributes_file(local_attributes_file);
  982                     }
  983                 }
  984                 /* FALLTHROUGH */
  985             case CONFIG_NO_SAVE:
  986                 if (grpname && curr_scope) {
  987                     /*
  988                      * Called via TAB from Config 'M'enu,
  989                      * delete scope if all attributes have default values
  990                      */
  991                     if (scope_is_empty())
  992                         do_delete_scope(scope_idx);
  993                     curr_scope = NULL;
  994                 }
  995                 assign_attributes_to_groups();
  996                 if (grpname && curr_group) {
  997                     /*
  998                      * These things can be toggled by the user,
  999                      * restore the cached state if no changes were made
 1000                      */
 1001                     if (!(changed & SHOW_AUTHOR))
 1002                         curr_group->attribute->show_author = old_show_author;
 1003                     if (!(changed & SHOW_ONLY_UNREAD))
 1004                         curr_group->attribute->show_only_unread_arts = old_show_unread;
 1005                     if (!(changed & THREAD_ARTS))
 1006                         curr_group->attribute->thread_articles = old_thread_arts;
 1007 
 1008                     if (changed) {
 1009                         t_bool filtered = FALSE;
 1010                         t_bool old_keep_in_base = TRUE;
 1011 
 1012                         /*
 1013                          * recook if an article is open
 1014                          */
 1015                         if (changed & DISPLAY_OPTS) {
 1016                             if (pgart.raw)
 1017                                 resize_article(TRUE, &pgart);
 1018                         }
 1019                         /*
 1020                          * Clear art->keep_in_base if switching to !show_only_unread_arts
 1021                          */
 1022                         if ((changed & SHOW_ONLY_UNREAD) && !curr_group->attribute->show_only_unread_arts) {
 1023                             for_each_art(i)
 1024                                 arts[i].keep_in_base = FALSE;
 1025                         }
 1026 
 1027                         if (changed & SCORE_OPTS) {
 1028                             unfilter_articles(curr_group);
 1029                             read_filter_file(filter_file);
 1030                             filtered = filter_articles(curr_group);
 1031                         }
 1032                         /*
 1033                          * If the sorting/threading strategy of threads or filter options have
 1034                          * changed, fix things so that resorting will occur
 1035                          *
 1036                          * If show_only_unread_arts or the scoring of a thread has changed,
 1037                          * resort base[] (find_base() is called inside make_threads() too, so
 1038                          * do this only if make_threads() was not called before)
 1039                          *
 1040                          * If we were called from page level, keep the current article in
 1041                          * base[]. This prevents that find_base() removes the current article
 1042                          * after switching to show_only_unread.
 1043                          */
 1044                         if (level == cPage) {
 1045                             old_keep_in_base = arts[this_resp].keep_in_base;
 1046                             arts[this_resp].keep_in_base = TRUE;
 1047                         }
 1048                         if (changed & (THREAD_ARTS | SORT_OPTS))
 1049                             make_threads(curr_group, TRUE);
 1050                         else if (filtered)
 1051                             make_threads(curr_group, FALSE);
 1052                         else if (changed & (SHOW_ONLY_UNREAD | THREAD_SCORE))
 1053                             find_base(curr_group);
 1054 
 1055                         if (level == cPage)
 1056                             arts[this_resp].keep_in_base = old_keep_in_base;
 1057                     }
 1058                 }
 1059                 clear_note_area();
 1060                 return;
 1061 
 1062             case GLOBAL_HELP:
 1063                 if (curr_scope)
 1064                     show_help_page(ATTRIB_LEVEL, _(txt_attrib_menu_com));
 1065                 else
 1066                     show_help_page(CONFIG_LEVEL, _(txt_options_menu_com));
 1067                 redraw_screen(option);
 1068                 break;
 1069 
 1070             case GLOBAL_LINE_UP:
 1071                 unhighlight_option(option);
 1072                 option = move_cursor(option, FALSE);
 1073                 highlight_option(option);
 1074                 break;
 1075 
 1076             case GLOBAL_LINE_DOWN:
 1077                 unhighlight_option(option);
 1078                 option = move_cursor(option, TRUE);
 1079                 highlight_option(option);
 1080                 break;
 1081 
 1082             case GLOBAL_FIRST_PAGE:
 1083                 unhighlight_option(option);
 1084                 option = get_first_opt();
 1085                 first_option_on_screen = 0;
 1086                 set_last_option_on_screen(0);
 1087                 redraw_screen(option);
 1088                 /* highlight_option(option); is already done by redraw_screen() */
 1089                 break;
 1090 
 1091             case GLOBAL_LAST_PAGE:
 1092                 unhighlight_option(option);
 1093                 option = last_opt;
 1094                 last_option_on_screen = last_opt;
 1095                 set_first_option_on_screen(last_opt);
 1096                 redraw_screen(option);
 1097                 /* highlight_option(option); is already done by redraw_screen() */
 1098                 break;
 1099 
 1100             case GLOBAL_PAGE_UP:
 1101                 unhighlight_option(option);
 1102                 if (option != first_option_on_screen && !(option_is_title(first_option_on_screen) && option == next_option(first_option_on_screen, FALSE))) {
 1103                     option = first_option_on_screen;
 1104                     if (option_is_title(option))
 1105                         option = next_option(option, FALSE);
 1106                     highlight_option(option);
 1107                     break;
 1108                 } else if (tinrc.scroll_lines == -2 && first_option_on_screen != 0) {
 1109                     i = option_lines_per_page / 2;
 1110 
 1111                     for (; i > 0; i--) {
 1112                         last_option_on_screen = prev_option(last_option_on_screen, TRUE);
 1113                         if (last_option_on_screen == last_opt)  /* end on wrap around */
 1114                             break;
 1115                     }
 1116                 } else
 1117                     last_option_on_screen = prev_option(first_option_on_screen, TRUE);
 1118 
 1119                 set_first_option_on_screen(last_option_on_screen);
 1120                 if (last_option_on_screen == last_opt)
 1121                     option = last_option_on_screen;
 1122                 else
 1123                     option = first_option_on_screen;
 1124                 if (option_is_title(option))
 1125                     option = next_option(option, FALSE);
 1126                 redraw_screen(option);
 1127                 /* highlight_option(option); is already done by redraw_screen() */
 1128                 break;
 1129 
 1130             case GLOBAL_PAGE_DOWN:
 1131                 unhighlight_option(option);
 1132                 if (option == last_opt) {
 1133                     /* wrap around */
 1134                     first_option_on_screen = 0;
 1135                     option = 0;
 1136                 } else {
 1137                     enum option_enum old_first = first_option_on_screen;
 1138 
 1139                     if (tinrc.scroll_lines == -2) {
 1140                         i = option_lines_per_page / 2;
 1141 
 1142                         for (; i > 0; i--) {
 1143                             first_option_on_screen = next_option(first_option_on_screen, TRUE);
 1144                             if (first_option_on_screen == 0)    /* end on wrap_around */
 1145                                 break;
 1146                         }
 1147                     } else
 1148                         first_option_on_screen = next_option(last_option_on_screen, TRUE);
 1149 
 1150                     if (first_option_on_screen == 0) {
 1151                         first_option_on_screen = old_first;
 1152                         option = last_opt;
 1153                         highlight_option(option);
 1154                         break;
 1155                     } else
 1156                         option = first_option_on_screen;
 1157                 }
 1158 
 1159                 set_last_option_on_screen(first_option_on_screen);
 1160                 if (option_is_title(option))
 1161                     option = next_option(option, FALSE);
 1162                 redraw_screen(option);
 1163                 /* highlight_option(option); is already done by redraw_screen() */
 1164                 break;
 1165 
 1166             case GLOBAL_SCROLL_UP:
 1167                 option = opt_scroll_up(option);
 1168                 break;
 1169 
 1170             case GLOBAL_SCROLL_DOWN:
 1171                 option = opt_scroll_down(option);
 1172                 break;
 1173 
 1174             case DIGIT_1:
 1175             case DIGIT_2:
 1176             case DIGIT_3:
 1177             case DIGIT_4:
 1178             case DIGIT_5:
 1179             case DIGIT_6:
 1180             case DIGIT_7:
 1181             case DIGIT_8:
 1182             case DIGIT_9:
 1183                 unhighlight_option(option);
 1184                 option = set_option_num(prompt_num(func_to_key(func, option_menu_keys), _(txt_enter_option_num)));
 1185                 if (!option_on_page(option)) {
 1186                     first_option_on_screen = option;
 1187                     set_last_option_on_screen(option);
 1188                     redraw_screen(option);
 1189                 } else
 1190                     highlight_option(option);
 1191                 break;
 1192 
 1193 #ifndef NO_SHELL_ESCAPE
 1194             case GLOBAL_SHELL_ESCAPE:
 1195                 shell_escape();
 1196                 redraw_screen(option);
 1197                 break;
 1198 #endif /* !NO_SHELL_ESCAPE */
 1199 
 1200             case GLOBAL_SEARCH_SUBJECT_FORWARD:
 1201             case GLOBAL_SEARCH_SUBJECT_BACKWARD:
 1202             case GLOBAL_SEARCH_REPEAT:
 1203                 if (func == GLOBAL_SEARCH_REPEAT && last_search != GLOBAL_SEARCH_SUBJECT_FORWARD && last_search != GLOBAL_SEARCH_SUBJECT_BACKWARD)
 1204                     info_message(_(txt_no_prev_search));
 1205                 else {
 1206                     old_option = option;
 1207                     option = search_config((func == GLOBAL_SEARCH_SUBJECT_FORWARD), (func == GLOBAL_SEARCH_REPEAT), option, last_opt);
 1208                     if (option != old_option) {
 1209                         unhighlight_option(old_option);
 1210                         if (!option_on_page(option)) {
 1211                             first_option_on_screen = option;
 1212                             set_last_option_on_screen(option);
 1213                             redraw_screen(option);
 1214                         } else
 1215                             highlight_option(option);
 1216                     }
 1217                 }
 1218                 break;
 1219 
 1220             case CONFIG_SCOPE_MENU:
 1221                 if (!curr_scope) {
 1222                     scope_page(level);
 1223                     set_last_opt();
 1224                     option = get_first_opt();
 1225                     first_option_on_screen = 0;
 1226                     set_last_option_on_screen(0);
 1227                     redraw_screen(option);
 1228                 }
 1229                 break;
 1230 
 1231             case CONFIG_RESET_ATTRIB:
 1232                 if (curr_scope) {
 1233                     if (curr_scope->global)
 1234                         info_message(_(txt_scope_operation_not_allowed));
 1235                     else if (check_state(option)) {
 1236                         reset_state(option);
 1237                         changed |= MISC_OPTS;
 1238                         redraw_screen(option);
 1239                     }
 1240                 }
 1241                 break;
 1242 
 1243             case CONFIG_SELECT:
 1244                 if (curr_scope && curr_scope->global)
 1245                     info_message(_(txt_scope_operation_not_allowed));
 1246                 else
 1247                     change_option = TRUE;
 1248                 break;
 1249 
 1250             case CONFIG_TOGGLE_ATTRIB:
 1251                 if (grpname) {
 1252                     if (curr_scope) {
 1253                         if (scope_is_empty()) {
 1254                             do_delete_scope(scope_idx);
 1255                             scope_idx = 0;
 1256                         }
 1257                         curr_scope = NULL;
 1258                     } else {
 1259                         if (!(scope_idx = find_scope(grpname)))
 1260                             scope_idx = add_scope(grpname);
 1261                         if (scope_idx) {
 1262                             curr_scope = &scopes[scope_idx];
 1263                             initialize_attributes();
 1264                         }
 1265                     }
 1266                     set_last_opt();
 1267                     option = get_first_opt();
 1268                     first_option_on_screen = 0;
 1269                     set_last_option_on_screen(0);
 1270                     redraw_screen(option);
 1271                 }
 1272                 break;
 1273 
 1274             case GLOBAL_REDRAW_SCREEN:
 1275                 my_retouch();
 1276                 set_xclick_off();
 1277                 set_last_option_on_screen(first_option_on_screen);
 1278                 redraw_screen(option);
 1279                 break;
 1280 
 1281             case GLOBAL_VERSION:
 1282                 info_message(cvers);
 1283                 break;
 1284 
 1285             default:
 1286                 info_message(_(txt_bad_command), printascii(key, func_to_key(GLOBAL_HELP, option_menu_keys)));
 1287                 break;
 1288         } /* switch (ch) */
 1289 
 1290         if (change_option) {
 1291             switch (option_table[option].var_type) {
 1292                 case OPT_ON_OFF:
 1293                     switch (option) {
 1294                         case OPT_ABBREVIATE_GROUPNAME:
 1295                         case OPT_AUTO_RECONNECT:
 1296                         case OPT_CACHE_OVERVIEW_FILES:
 1297                         case OPT_CATCHUP_READ_GROUPS:
 1298                         case OPT_FORCE_SCREEN_REDRAW:
 1299                         case OPT_KEEP_DEAD_ARTICLES:
 1300                         case OPT_SHOW_ONLY_UNREAD_GROUPS:
 1301                         case OPT_STRIP_NEWSRC:
 1302 #if defined(HAVE_ICONV_OPEN_TRANSLIT) && defined(CHARSET_CONVERSION)
 1303                         case OPT_TRANSLIT:
 1304 #endif /* HAVE_ICONV_OPEN_TRANSLIT && CHARSET_CONVERSION */
 1305                         case OPT_UNLINK_ARTICLE:
 1306 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1307                         case OPT_UTF8_GRAPHICS:
 1308 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1309                         case OPT_URL_HIGHLIGHT:
 1310 #ifdef HAVE_KEYPAD
 1311                         case OPT_USE_KEYPAD:
 1312 #endif /* HAVE_KEYPAD */
 1313                         case OPT_USE_MOUSE:
 1314                             if (prompt_option_on_off(option))
 1315                                 changed |= MISC_OPTS;
 1316                             break;
 1317 
 1318                         case OPT_ADD_POSTED_TO_FILTER:
 1319                             if (prompt_option_on_off(option))
 1320                                 UPDATE_INT_ATTRIBUTES(add_posted_to_filter);
 1321                             break;
 1322 
 1323                         case OPT_ADVERTISING:
 1324                             if (prompt_option_on_off(option))
 1325                                 UPDATE_INT_ATTRIBUTES(advertising);
 1326                             break;
 1327 
 1328                         case OPT_ALTERNATIVE_HANDLING:
 1329                             if (prompt_option_on_off(option))
 1330                                 UPDATE_INT_ATTRIBUTES(alternative_handling);
 1331                             break;
 1332 
 1333                         case OPT_ASK_FOR_METAMAIL:
 1334                             if (prompt_option_on_off(option))
 1335                                 UPDATE_INT_ATTRIBUTES(ask_for_metamail);
 1336                             break;
 1337 
 1338                         case OPT_AUTO_LIST_THREAD:
 1339                             if (prompt_option_on_off(option))
 1340                                 UPDATE_INT_ATTRIBUTES(auto_list_thread);
 1341                             break;
 1342 
 1343                         case OPT_AUTO_SAVE:
 1344                             if (prompt_option_on_off(option))
 1345                                 UPDATE_INT_ATTRIBUTES(auto_save);
 1346                             break;
 1347 
 1348                         case OPT_BATCH_SAVE:
 1349                             if (prompt_option_on_off(option))
 1350                                 UPDATE_INT_ATTRIBUTES(batch_save);
 1351                             break;
 1352 
 1353 #ifdef HAVE_COLOR
 1354                         case OPT_EXTQUOTE_HANDLING:
 1355                             /*
 1356                              * option toggles visibility of other
 1357                              * options -> needs redraw_screen()
 1358                              */
 1359                             if (prompt_option_on_off(option)) {
 1360                                 UPDATE_INT_ATTRIBUTES(extquote_handling);
 1361                                 set_last_option_on_screen(first_option_on_screen);
 1362                                 redraw_screen(option);
 1363                                 changed |= DISPLAY_OPTS;
 1364                             }
 1365                             break;
 1366 #endif /* HAVE_COLOR */
 1367 
 1368                         case OPT_GROUP_CATCHUP_ON_EXIT:
 1369                             if (prompt_option_on_off(option))
 1370                                 UPDATE_INT_ATTRIBUTES(group_catchup_on_exit);
 1371                             break;
 1372 
 1373                         case OPT_MARK_IGNORE_TAGS:
 1374                             if (prompt_option_on_off(option))
 1375                                 UPDATE_INT_ATTRIBUTES(mark_ignore_tags);
 1376                             break;
 1377 
 1378                         case OPT_MARK_SAVED_READ:
 1379                             if (prompt_option_on_off(option))
 1380                                 UPDATE_INT_ATTRIBUTES(mark_saved_read);
 1381                             break;
 1382 
 1383                         case OPT_POST_PROCESS_VIEW:
 1384                             if (prompt_option_on_off(option))
 1385                                 UPDATE_INT_ATTRIBUTES(post_process_view);
 1386                             break;
 1387 
 1388                         case OPT_POS_FIRST_UNREAD:
 1389                             if (prompt_option_on_off(option))
 1390                                 UPDATE_INT_ATTRIBUTES(pos_first_unread);
 1391                             break;
 1392 
 1393 #ifndef DISABLE_PRINTING
 1394                         case OPT_PRINT_HEADER:
 1395                             if (prompt_option_on_off(option))
 1396                                 UPDATE_INT_ATTRIBUTES(print_header);
 1397                             break;
 1398 #endif /* !DISABLE_PRINTING */
 1399 
 1400                         case OPT_PROCESS_ONLY_UNREAD:
 1401                             if (prompt_option_on_off(option))
 1402                                 UPDATE_INT_ATTRIBUTES(process_only_unread);
 1403                             break;
 1404 
 1405                         case OPT_PROMPT_FOLLOWUPTO:
 1406                             if (prompt_option_on_off(option))
 1407                                 UPDATE_INT_ATTRIBUTES(prompt_followupto);
 1408                             break;
 1409 
 1410                         case OPT_SHOW_SIGNATURES:
 1411                             if (prompt_option_on_off(option))
 1412                                 UPDATE_INT_ATTRIBUTES(show_signatures);
 1413                             break;
 1414 
 1415                         case OPT_SIGDASHES:
 1416                             if (prompt_option_on_off(option))
 1417                                 UPDATE_INT_ATTRIBUTES(sigdashes);
 1418                             break;
 1419 
 1420                         case OPT_SIGNATURE_REPOST:
 1421                             if (prompt_option_on_off(option))
 1422                                 UPDATE_INT_ATTRIBUTES(signature_repost);
 1423                             break;
 1424 
 1425                         case OPT_START_EDITOR_OFFSET:
 1426                             if (prompt_option_on_off(option))
 1427                                 UPDATE_INT_ATTRIBUTES(start_editor_offset);
 1428                             break;
 1429 
 1430 #ifndef USE_CURSES
 1431                         case OPT_STRIP_BLANKS:
 1432                             if (prompt_option_on_off(option)) {
 1433                                 redraw_screen(option);
 1434                                 changed |= MISC_OPTS;
 1435                             }
 1436                             break;
 1437 #endif /* !USE_CURSES */
 1438 
 1439                         case OPT_TEX2ISO_CONV:
 1440                             if (prompt_option_on_off(option))
 1441                                 UPDATE_INT_ATTRIBUTES(tex2iso_conv);
 1442                             break;
 1443 
 1444                         case OPT_THREAD_CATCHUP_ON_EXIT:
 1445                             if (prompt_option_on_off(option))
 1446                                 UPDATE_INT_ATTRIBUTES(thread_catchup_on_exit);
 1447                             break;
 1448 
 1449                         case OPT_WRAP_ON_NEXT_UNREAD:
 1450                             if (prompt_option_on_off(option))
 1451                                 UPDATE_INT_ATTRIBUTES(wrap_on_next_unread);
 1452                             break;
 1453 
 1454                         case OPT_VERBATIM_HANDLING:
 1455                             /*
 1456                              * option toggles visibility of other
 1457                              * options -> needs redraw_screen()
 1458                              */
 1459                             if (prompt_option_on_off(option)) {
 1460                                 UPDATE_INT_ATTRIBUTES(verbatim_handling);
 1461                                 set_last_option_on_screen(first_option_on_screen);
 1462                                 redraw_screen(option);
 1463                             }
 1464                             break;
 1465 
 1466                         /* show mini help menu */
 1467                         case OPT_BEGINNER_LEVEL:
 1468                             if (prompt_option_on_off(option)) {
 1469                                 set_noteslines(cLINES);
 1470                                 changed |= MISC_OPTS;
 1471                             }
 1472                             break;
 1473 
 1474                         /* show all arts or just new/unread arts */
 1475                         case OPT_SHOW_ONLY_UNREAD_ARTS:
 1476                             if (prompt_option_on_off(option)) {
 1477                                 UPDATE_INT_ATTRIBUTES(show_only_unread_arts);
 1478                                 changed |= SHOW_ONLY_UNREAD;
 1479                             }
 1480                             break;
 1481 
 1482                         /* draw -> / highlighted bar */
 1483                         case OPT_DRAW_ARROW:
 1484                             if (prompt_option_on_off(option)) {
 1485                                 unhighlight_option(option);
 1486                                 if (!tinrc.draw_arrow && !tinrc.inverse_okay) {
 1487                                     tinrc.inverse_okay = TRUE;
 1488                                     repaint_option(OPT_INVERSE_OKAY);
 1489                                     center_line(0, TRUE, _(txt_options_menu));
 1490                                 }
 1491                                 changed |= MISC_OPTS;
 1492                             }
 1493                             break;
 1494 
 1495                         /* draw inversed screen header lines */
 1496                         /* draw inversed group/article/option line if draw_arrow is OFF */
 1497                         case OPT_INVERSE_OKAY:
 1498                             if (prompt_option_on_off(option)) {
 1499                                 unhighlight_option(option);
 1500                                 if (!tinrc.draw_arrow && !tinrc.inverse_okay) {
 1501                                     tinrc.draw_arrow = TRUE;    /* we don't want to navigate blindly */
 1502                                     repaint_option(OPT_DRAW_ARROW);
 1503                                 }
 1504                                 center_line(0, TRUE, _(txt_options_menu));
 1505                                 changed |= MISC_OPTS;
 1506                             }
 1507                             break;
 1508 
 1509                         case OPT_MAIL_8BIT_HEADER:
 1510                             if (prompt_option_on_off(option)) {
 1511                                 if (tinrc.mail_mime_encoding != MIME_ENCODING_8BIT) {
 1512                                     tinrc.mail_8bit_header = FALSE;
 1513                                     print_any_option(OPT_MAIL_8BIT_HEADER);
 1514                                 }
 1515                                 UPDATE_INT_ATTRIBUTES(mail_8bit_header);
 1516                             }
 1517                             break;
 1518 
 1519                         case OPT_POST_8BIT_HEADER:
 1520                             if (prompt_option_on_off(option)) {
 1521                                 /* if post_mime_encoding != 8bit, post_8bit_header is disabled */
 1522                                 if (tinrc.post_mime_encoding != MIME_ENCODING_8BIT) {
 1523                                     tinrc.post_8bit_header = FALSE;
 1524                                     print_any_option(OPT_POST_8BIT_HEADER);
 1525                                 }
 1526                                 UPDATE_INT_ATTRIBUTES(post_8bit_header);
 1527                             }
 1528                             break;
 1529 
 1530                         /* show newsgroup description text next to newsgroups */
 1531                         case OPT_SHOW_DESCRIPTION:
 1532                             if (prompt_option_on_off(option)) {
 1533                                 show_description = tinrc.show_description;
 1534                                 if (show_description)           /* force reread of newgroups file */
 1535                                     read_descriptions(FALSE);
 1536                                 changed |= MISC_OPTS;
 1537                             }
 1538                             break;
 1539 
 1540 #ifdef HAVE_COLOR
 1541                         /* use ANSI color */
 1542                         case OPT_USE_COLOR:
 1543                             if (prompt_option_on_off(option)) {
 1544 #   ifdef USE_CURSES
 1545                                 if (!has_colors())
 1546                                     use_color = FALSE;
 1547                                 else
 1548 #   endif /* USE_CURSES */
 1549                                     use_color = tinrc.use_color;
 1550                                 set_last_option_on_screen(first_option_on_screen);
 1551                                 redraw_screen(option);
 1552                                 changed |= MISC_OPTS;
 1553                             }
 1554                             break;
 1555 #endif /* HAVE_COLOR */
 1556 
 1557 #ifdef XFACE_ABLE
 1558                         /* use slrnface */
 1559                         case OPT_USE_SLRNFACE:
 1560                             if (prompt_option_on_off(option)) {
 1561                                 if (!tinrc.use_slrnface)
 1562                                     slrnface_stop();
 1563                                 else
 1564                                     slrnface_start();
 1565                                 changed |= MISC_OPTS;
 1566                             }
 1567                             break;
 1568 #endif /* XFACE_ABLE */
 1569 
 1570                         /* word_highlight */
 1571                         case OPT_WORD_HIGHLIGHT:
 1572                             if (prompt_option_on_off(option)) {
 1573                                 word_highlight = tinrc.word_highlight;
 1574                                 set_last_option_on_screen(first_option_on_screen);
 1575                                 redraw_screen(option);
 1576                                 changed |= MISC_OPTS;
 1577                             }
 1578                             break;
 1579 
 1580 #if defined(HAVE_LIBICUUC) && defined(MULTIBYTE_ABLE) && defined(HAVE_UNICODE_UBIDI_H) && !defined(NO_LOCALE)
 1581                         case OPT_RENDER_BIDI:
 1582                             if (prompt_option_on_off(option))
 1583                                 changed |= MISC_OPTS;
 1584                             break;
 1585 #endif /* HAVE_LIBICUUC && MULTIBYTE_ABLE && HAVE_UNICODE_UBIDI_H && !NO_LOCALE */
 1586 
 1587                         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
 1588                             if (prompt_option_on_off(option))
 1589                                 SET_NUM_ATTRIBUTE(add_posted_to_filter);
 1590                             break;
 1591 
 1592                         case OPT_ATTRIB_ADVERTISING:
 1593                             if (prompt_option_on_off(option))
 1594                                 SET_NUM_ATTRIBUTE(advertising);
 1595                             break;
 1596 
 1597                         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
 1598                             if (prompt_option_on_off(option))
 1599                                 SET_NUM_ATTRIBUTE(alternative_handling);
 1600                             break;
 1601 
 1602                         case OPT_ATTRIB_ASK_FOR_METAMAIL:
 1603                             if (prompt_option_on_off(option))
 1604                                 SET_NUM_ATTRIBUTE(ask_for_metamail);
 1605                             break;
 1606 
 1607                         case OPT_ATTRIB_AUTO_LIST_THREAD:
 1608                             if (prompt_option_on_off(option))
 1609                                 SET_NUM_ATTRIBUTE(auto_list_thread);
 1610                             break;
 1611 
 1612                         case OPT_ATTRIB_AUTO_SAVE:
 1613                             if (prompt_option_on_off(option))
 1614                                 SET_NUM_ATTRIBUTE(auto_save);
 1615                             break;
 1616 
 1617                         case OPT_ATTRIB_AUTO_SELECT:
 1618                             if (prompt_option_on_off(option))
 1619                                 SET_NUM_ATTRIBUTE(auto_select);
 1620                             break;
 1621 
 1622                         case OPT_ATTRIB_BATCH_SAVE:
 1623                             if (prompt_option_on_off(option))
 1624                                 SET_NUM_ATTRIBUTE(batch_save);
 1625                             break;
 1626 
 1627                         case OPT_ATTRIB_DELETE_TMP_FILES:
 1628                             if (prompt_option_on_off(option))
 1629                                 SET_NUM_ATTRIBUTE(delete_tmp_files);
 1630                             break;
 1631 
 1632 #ifdef HAVE_COLOR
 1633                         case OPT_ATTRIB_EXTQUOTE_HANDLING:
 1634                             if (prompt_option_on_off(option))
 1635                                 SET_NUM_ATTRIBUTE(extquote_handling);
 1636                             break;
 1637 #endif /* HAVE_COLOR */
 1638 
 1639                         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
 1640                             if (prompt_option_on_off(option))
 1641                                 SET_NUM_ATTRIBUTE(group_catchup_on_exit);
 1642                             break;
 1643 
 1644                         case OPT_ATTRIB_MAIL_8BIT_HEADER:
 1645                             if (prompt_option_on_off(option))
 1646                                 SET_NUM_ATTRIBUTE(mail_8bit_header);
 1647                             break;
 1648 
 1649                         case OPT_ATTRIB_MARK_IGNORE_TAGS:
 1650                             if (prompt_option_on_off(option))
 1651                                 SET_NUM_ATTRIBUTE(mark_ignore_tags);
 1652                             break;
 1653 
 1654                         case OPT_ATTRIB_MARK_SAVED_READ:
 1655                             if (prompt_option_on_off(option))
 1656                                 SET_NUM_ATTRIBUTE(mark_saved_read);
 1657                             break;
 1658 
 1659                         case OPT_ATTRIB_MIME_FORWARD:
 1660                             if (prompt_option_on_off(option))
 1661                                 SET_NUM_ATTRIBUTE(mime_forward);
 1662                             break;
 1663 
 1664                         case OPT_ATTRIB_POST_8BIT_HEADER:
 1665                             if (prompt_option_on_off(option))
 1666                                 SET_NUM_ATTRIBUTE(post_8bit_header);
 1667                             break;
 1668 
 1669                         case OPT_ATTRIB_POST_PROCESS_VIEW:
 1670                             if (prompt_option_on_off(option))
 1671                                 SET_NUM_ATTRIBUTE(post_process_view);
 1672                             break;
 1673 
 1674                         case OPT_ATTRIB_POS_FIRST_UNREAD:
 1675                             if (prompt_option_on_off(option))
 1676                                 SET_NUM_ATTRIBUTE(pos_first_unread);
 1677                             break;
 1678 
 1679 #ifndef DISABLE_PRINTING
 1680                         case OPT_ATTRIB_PRINT_HEADER:
 1681                             if (prompt_option_on_off(option))
 1682                                 SET_NUM_ATTRIBUTE(print_header);
 1683                             break;
 1684 #endif /* !DISABLE_PRINTING */
 1685 
 1686                         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
 1687                             if (prompt_option_on_off(option))
 1688                                 SET_NUM_ATTRIBUTE(process_only_unread);
 1689                             break;
 1690 
 1691                         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
 1692                             if (prompt_option_on_off(option))
 1693                                 SET_NUM_ATTRIBUTE(prompt_followupto);
 1694                             break;
 1695 
 1696                         case OPT_ATTRIB_QUICK_KILL_CASE:
 1697                             if (prompt_option_on_off(option))
 1698                                 SET_NUM_ATTRIBUTE(quick_kill_case);
 1699                             break;
 1700 
 1701                         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
 1702                             if (prompt_option_on_off(option))
 1703                                 SET_NUM_ATTRIBUTE(quick_kill_expire);
 1704                             break;
 1705 
 1706                         case OPT_ATTRIB_QUICK_SELECT_CASE:
 1707                             if (prompt_option_on_off(option))
 1708                                 SET_NUM_ATTRIBUTE(quick_select_case);
 1709                             break;
 1710 
 1711                         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
 1712                             if (prompt_option_on_off(option))
 1713                                 SET_NUM_ATTRIBUTE(quick_select_expire);
 1714                             break;
 1715 
 1716                         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
 1717                             if (prompt_option_on_off(option)) {
 1718                                 SET_NUM_ATTRIBUTE(show_only_unread_arts);
 1719                                 changed |= SHOW_ONLY_UNREAD;
 1720                             }
 1721                             break;
 1722 
 1723                         case OPT_ATTRIB_SHOW_SIGNATURES:
 1724                             if (prompt_option_on_off(option))
 1725                                 SET_NUM_ATTRIBUTE(show_signatures);
 1726                             break;
 1727 
 1728                         case OPT_ATTRIB_SIGDASHES:
 1729                             if (prompt_option_on_off(option))
 1730                                 SET_NUM_ATTRIBUTE(sigdashes);
 1731                             break;
 1732 
 1733                         case OPT_ATTRIB_SIGNATURE_REPOST:
 1734                             if (prompt_option_on_off(option))
 1735                                 SET_NUM_ATTRIBUTE(signature_repost);
 1736                             break;
 1737 
 1738                         case OPT_ATTRIB_START_EDITOR_OFFSET:
 1739                             if (prompt_option_on_off(option))
 1740                                 SET_NUM_ATTRIBUTE(start_editor_offset);
 1741                             break;
 1742 
 1743                         case OPT_ATTRIB_TEX2ISO_CONV:
 1744                             if (prompt_option_on_off(option))
 1745                                 SET_NUM_ATTRIBUTE(tex2iso_conv);
 1746                             break;
 1747 
 1748                         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
 1749                             if (prompt_option_on_off(option))
 1750                                 SET_NUM_ATTRIBUTE(thread_catchup_on_exit);
 1751                             break;
 1752 
 1753                         case OPT_ATTRIB_VERBATIM_HANDLING:
 1754                             if (prompt_option_on_off(option))
 1755                                 SET_NUM_ATTRIBUTE(verbatim_handling);
 1756                             break;
 1757 
 1758                         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
 1759                             if (prompt_option_on_off(option))
 1760                                 SET_NUM_ATTRIBUTE(wrap_on_next_unread);
 1761                             break;
 1762 
 1763                         case OPT_ATTRIB_X_COMMENT_TO:
 1764                             if (prompt_option_on_off(option))
 1765                                 SET_NUM_ATTRIBUTE(x_comment_to);
 1766                             break;
 1767 
 1768                         default:
 1769                             break;
 1770                     } /* switch (option) */
 1771                     break;
 1772 
 1773                 case OPT_LIST:
 1774                     switch (option) {
 1775 #ifdef HAVE_COLOR
 1776                         case OPT_COL_FROM:
 1777                         case OPT_COL_HEAD:
 1778                         case OPT_COL_HELP:
 1779                         case OPT_COL_INVERS_BG:
 1780                         case OPT_COL_INVERS_FG:
 1781                         case OPT_COL_MESSAGE:
 1782                         case OPT_COL_MINIHELP:
 1783                         case OPT_COL_NEWSHEADERS:
 1784                         case OPT_COL_QUOTE:
 1785                         case OPT_COL_QUOTE2:
 1786                         case OPT_COL_QUOTE3:
 1787                         case OPT_COL_EXTQUOTE:
 1788                         case OPT_COL_RESPONSE:
 1789                         case OPT_COL_SIGNATURE:
 1790                         case OPT_COL_SUBJECT:
 1791                         case OPT_COL_TEXT:
 1792                         case OPT_COL_TITLE:
 1793                         case OPT_COL_MARKSTAR:
 1794                         case OPT_COL_MARKDASH:
 1795                         case OPT_COL_MARKSLASH:
 1796                         case OPT_COL_MARKSTROKE:
 1797                         case OPT_COL_URLS:
 1798                         case OPT_COL_VERBATIM:
 1799 #endif /* HAVE_COLOR */
 1800                         case OPT_CONFIRM_CHOICE:
 1801                         case OPT_GOTO_NEXT_UNREAD:
 1802                         case OPT_HIDE_UUE:
 1803                         case OPT_INTERACTIVE_MAILER:
 1804                         case OPT_KILL_LEVEL:
 1805                         case OPT_MAILBOX_FORMAT:
 1806                         case OPT_MONO_MARKDASH:
 1807                         case OPT_MONO_MARKSLASH:
 1808                         case OPT_MONO_MARKSTAR:
 1809                         case OPT_MONO_MARKSTROKE:
 1810 #ifdef HAVE_UNICODE_NORMALIZATION
 1811                         case OPT_NORMALIZATION_FORM:
 1812 #endif /* HAVE_UNICODE_NORMALIZATION */
 1813                         case OPT_QUOTE_STYLE:
 1814                         case OPT_STRIP_BOGUS:
 1815                         case OPT_WILDCARD:
 1816                         case OPT_WORD_H_DISPLAY_MARKS:
 1817 #ifdef USE_HEAPSORT
 1818                         case OPT_SORT_FUNCTION:
 1819 #endif /* USE_HEAPSORT */
 1820                             if (prompt_option_list(option))
 1821                                 changed |= MISC_OPTS;
 1822                             break;
 1823 
 1824 #ifdef HAVE_COLOR
 1825                         case OPT_COL_BACK:
 1826                         case OPT_COL_NORMAL:
 1827                             if (prompt_option_list(option)) {
 1828                                 redraw_screen(option);
 1829                                 changed |= MISC_OPTS;
 1830                             }
 1831                             break;
 1832 #endif /* HAVE_COLOR */
 1833 
 1834                         case OPT_AUTO_CC_BCC:
 1835                             if (prompt_option_list(option))
 1836                                 UPDATE_INT_ATTRIBUTES(auto_cc_bcc);
 1837                             break;
 1838 
 1839                         case OPT_THREAD_ARTICLES:
 1840                             if (prompt_option_list(option)) {
 1841                                 UPDATE_INT_ATTRIBUTES(thread_articles);
 1842                                 changed |= THREAD_ARTS;
 1843                             }
 1844                             break;
 1845 
 1846                         case OPT_SORT_ARTICLE_TYPE:
 1847                             if (prompt_option_list(option)) {
 1848                                 UPDATE_INT_ATTRIBUTES(sort_article_type);
 1849                                 changed |= SORT_OPTS;
 1850                             }
 1851                             break;
 1852 
 1853                         case OPT_SORT_THREADS_TYPE:
 1854                             if (prompt_option_list(option)) {
 1855                                 UPDATE_INT_ATTRIBUTES(sort_threads_type);
 1856                                 changed |= SORT_OPTS;
 1857                             }
 1858                             break;
 1859 
 1860                         case OPT_THREAD_SCORE:
 1861                             if (prompt_option_list(option))
 1862                                 changed |= THREAD_SCORE;
 1863                             break;
 1864 
 1865                         case OPT_TRIM_ARTICLE_BODY:
 1866                             if (prompt_option_list(option))
 1867                                 UPDATE_INT_ATTRIBUTES(trim_article_body);
 1868                             break;
 1869 
 1870                         case OPT_POST_PROCESS_TYPE:
 1871                             if (prompt_option_list(option))
 1872                                 UPDATE_INT_ATTRIBUTES(post_process_type);
 1873                             break;
 1874 
 1875                         case OPT_SHOW_AUTHOR:
 1876                             if (prompt_option_list(option)) {
 1877                                 UPDATE_INT_ATTRIBUTES(show_author);
 1878                                 changed |= SHOW_AUTHOR;
 1879                             }
 1880                             break;
 1881 
 1882                         case OPT_MAIL_MIME_ENCODING:
 1883                             if (prompt_option_list(option)) {
 1884 #ifdef CHARSET_CONVERSION
 1885                                 /*
 1886                                  * check if we have selected a !7bit encoding but a 7bit network charset
 1887                                  * or a !8bit encoding but a 8bit network charset, update encoding if needed
 1888                                  */
 1889                                 is_7bit = FALSE;
 1890                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1891                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1892                                         is_7bit = TRUE;
 1893                                         break;
 1894                                     }
 1895                                 }
 1896                                 if (is_7bit) {
 1897                                     if (tinrc.mail_mime_encoding != MIME_ENCODING_7BIT) {
 1898                                         tinrc.mail_mime_encoding = MIME_ENCODING_7BIT;
 1899                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1900                                     }
 1901                                 } else {
 1902                                     if (tinrc.mail_mime_encoding == MIME_ENCODING_7BIT) {
 1903                                         tinrc.mail_mime_encoding = MIME_ENCODING_QP;
 1904                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1905                                     }
 1906                                 }
 1907 #endif /* CHARSET_CONVERSION */
 1908                                 UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1909                                 /* do not use 8 bit headers if mime encoding is not 8bit */
 1910                                 if (tinrc.mail_mime_encoding != MIME_ENCODING_8BIT) {
 1911                                     tinrc.mail_8bit_header = FALSE;
 1912                                     repaint_option(OPT_MAIL_8BIT_HEADER);
 1913                                     UPDATE_INT_ATTRIBUTES(mail_8bit_header);
 1914                                 }
 1915                             }
 1916                             break;
 1917 
 1918                         case OPT_POST_MIME_ENCODING:
 1919                             if (prompt_option_list(option)) {
 1920 #ifdef CHARSET_CONVERSION
 1921                                 /*
 1922                                  * check if we have selected a !7bit encoding but a 7bit network charset
 1923                                  * or a !8bit encoding but a 8bit network charset, update encoding if needed
 1924                                  */
 1925                                 is_7bit = FALSE;
 1926                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1927                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1928                                         is_7bit = TRUE;
 1929                                         break;
 1930                                     }
 1931                                 }
 1932                                 if (is_7bit) {
 1933                                     if (tinrc.post_mime_encoding != MIME_ENCODING_7BIT) {
 1934                                         tinrc.post_mime_encoding = MIME_ENCODING_7BIT;
 1935                                         repaint_option(OPT_POST_MIME_ENCODING);
 1936                                     }
 1937                                 } else {
 1938                                     if (tinrc.post_mime_encoding == MIME_ENCODING_7BIT) {
 1939                                         tinrc.post_mime_encoding = MIME_ENCODING_8BIT;
 1940                                         repaint_option(OPT_POST_MIME_ENCODING);
 1941                                     }
 1942                                 }
 1943 #endif /* CHARSET_CONVERSION */
 1944                                 UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 1945                                 /* do not use 8 bit headers if mime encoding is not 8bit */
 1946                                 if (tinrc.post_mime_encoding != MIME_ENCODING_8BIT) {
 1947                                     tinrc.post_8bit_header = FALSE;
 1948                                     repaint_option(OPT_POST_8BIT_HEADER);
 1949                                     UPDATE_INT_ATTRIBUTES(post_8bit_header);
 1950                                 }
 1951                             }
 1952                             break;
 1953 
 1954 #ifdef CHARSET_CONVERSION
 1955                         case OPT_MM_NETWORK_CHARSET:
 1956                             if (prompt_option_list(option)) {
 1957                                 /*
 1958                                  * check if we have selected a 7bit charset but a !7bit encoding
 1959                                  * or a 8bit charset but a !8bit encoding, update encoding if needed
 1960                                  *
 1961                                  * if (mail|post)_mime_encoding != 8bit, disable (mail|post)_8bit_header
 1962                                  */
 1963                                 is_7bit = FALSE;
 1964                                 UPDATE_INT_ATTRIBUTES(mm_network_charset);
 1965                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1966                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1967                                         is_7bit = TRUE;
 1968                                         break;
 1969                                     }
 1970                                 }
 1971                                 if (is_7bit) {
 1972                                     if (tinrc.mail_mime_encoding != MIME_ENCODING_7BIT) {
 1973                                         tinrc.mail_mime_encoding = MIME_ENCODING_7BIT;
 1974                                         tinrc.mail_8bit_header = FALSE;
 1975                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1976                                         repaint_option(OPT_MAIL_8BIT_HEADER);
 1977                                         UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1978                                         UPDATE_INT_ATTRIBUTES(mail_8bit_header);
 1979                                     }
 1980                                     if (tinrc.post_mime_encoding != MIME_ENCODING_7BIT) {
 1981                                         tinrc.post_mime_encoding = MIME_ENCODING_7BIT;
 1982                                         tinrc.post_8bit_header = FALSE;
 1983                                         repaint_option(OPT_POST_MIME_ENCODING);
 1984                                         repaint_option(OPT_POST_8BIT_HEADER);
 1985                                         UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 1986                                         UPDATE_INT_ATTRIBUTES(post_8bit_header);
 1987                                     }
 1988                                 } else {
 1989                                     if (tinrc.mail_mime_encoding == MIME_ENCODING_7BIT) {
 1990                                         tinrc.mail_mime_encoding = MIME_ENCODING_QP;
 1991                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1992                                         UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1993                                     }
 1994                                     if (tinrc.post_mime_encoding == MIME_ENCODING_7BIT) {
 1995                                         tinrc.post_mime_encoding = MIME_ENCODING_8BIT;
 1996                                         repaint_option(OPT_POST_MIME_ENCODING);
 1997                                         UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 1998                                     }
 1999                                 }
 2000                             }
 2001                             break;
 2002 #endif /* CHARSET_CONVERSION */
 2003 
 2004                         case OPT_ATTRIB_AUTO_CC_BCC:
 2005                             if (prompt_option_list(option))
 2006                                 SET_NUM_ATTRIBUTE(auto_cc_bcc);
 2007                             break;
 2008 
 2009                         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 2010                             if (prompt_option_list(option))
 2011                                 SET_NUM_ATTRIBUTE(mail_mime_encoding);
 2012                             break;
 2013 
 2014 #ifdef CHARSET_CONVERSION
 2015                         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 2016                             if (prompt_option_list(option))
 2017                                 SET_NUM_ATTRIBUTE(mm_network_charset);
 2018                             break;
 2019 #endif /* CHARSET_CONVERSION */
 2020 
 2021                         case OPT_ATTRIB_POST_MIME_ENCODING:
 2022                             if (prompt_option_list(option))
 2023                                 SET_NUM_ATTRIBUTE(post_mime_encoding);
 2024                             break;
 2025 
 2026                         case OPT_ATTRIB_POST_PROCESS_TYPE:
 2027                             if (prompt_option_list(option))
 2028                                 SET_NUM_ATTRIBUTE(post_process_type);
 2029                             break;
 2030 
 2031                         case OPT_ATTRIB_QUICK_KILL_HEADER:
 2032                             if (prompt_option_list(option))
 2033                                 SET_NUM_ATTRIBUTE(quick_kill_header);
 2034                             break;
 2035 
 2036                         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 2037                             if (prompt_option_list(option))
 2038                                 SET_NUM_ATTRIBUTE(quick_select_header);
 2039                             break;
 2040 
 2041                         case OPT_ATTRIB_SHOW_AUTHOR:
 2042                             if (prompt_option_list(option)) {
 2043                                 SET_NUM_ATTRIBUTE(show_author);
 2044                                 changed |= SHOW_AUTHOR;
 2045                             }
 2046                             break;
 2047 
 2048                         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 2049                             if (prompt_option_list(option)) {
 2050                                 SET_NUM_ATTRIBUTE(sort_article_type);
 2051                                 changed |= SORT_OPTS;
 2052                             }
 2053                             break;
 2054 
 2055                         case OPT_ATTRIB_SORT_THREADS_TYPE:
 2056                             if (prompt_option_list(option)) {
 2057                                 SET_NUM_ATTRIBUTE(sort_threads_type);
 2058                                 changed |= SORT_OPTS;
 2059                             }
 2060                             break;
 2061 
 2062                         case OPT_ATTRIB_THREAD_ARTICLES:
 2063                             if (prompt_option_list(option)) {
 2064                                 SET_NUM_ATTRIBUTE(thread_articles);
 2065                                 changed |= THREAD_ARTS;
 2066                             }
 2067                             break;
 2068 
 2069                         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 2070                             if (prompt_option_list(option))
 2071                                 SET_NUM_ATTRIBUTE(trim_article_body);
 2072                             break;
 2073 
 2074                         default:
 2075                             break;
 2076                     } /* switch (option) */
 2077                     break;
 2078 
 2079                 case OPT_STRING:
 2080                     switch (option) {
 2081                         case OPT_INEWS_PROG:
 2082                         case OPT_MAILDIR:
 2083                         case OPT_MAILER_FORMAT:
 2084                         case OPT_MAIL_ADDRESS:
 2085                         case OPT_MAIL_QUOTE_FORMAT:
 2086                         case OPT_METAMAIL_PROG:
 2087                         case OPT_NEWS_QUOTE_FORMAT:
 2088                         case OPT_SAVEDIR:
 2089                         case OPT_SIGFILE:
 2090 #ifndef DISABLE_PRINTING
 2091                         case OPT_PRINTER:
 2092 #endif /* !DISABLE_PRINTING */
 2093                         case OPT_QUOTE_CHARS:
 2094                         case OPT_SPAMTRAP_WARNING_ADDRESSES:
 2095                         case OPT_URL_HANDLER:
 2096                         case OPT_XPOST_QUOTE_FORMAT:
 2097                             if (prompt_option_string(option))
 2098                                 changed |= MISC_OPTS;
 2099                             break;
 2100 
 2101                         case OPT_EDITOR_FORMAT:
 2102                             if (prompt_option_string(option)) {
 2103                                 if (!strlen(tinrc.editor_format))
 2104                                     STRCPY(tinrc.editor_format, TIN_EDITOR_FMT_ON);
 2105                                 changed |= MISC_OPTS;
 2106                             }
 2107                             break;
 2108 
 2109                         case OPT_GROUP_FORMAT:
 2110                             if (prompt_option_string(option)) {
 2111                                 if (!strlen(tinrc.group_format))
 2112                                     STRCPY(tinrc.group_format, DEFAULT_GROUP_FORMAT);
 2113                                 changed |= MISC_OPTS;
 2114                             }
 2115                             break;
 2116 
 2117                         case OPT_ATTRIB_GROUP_FORMAT:
 2118                             if (prompt_option_string(option))
 2119                                 SET_STRING_ATTRIBUTE(group_format);
 2120                             break;
 2121 
 2122 #ifndef CHARSET_CONVERSION
 2123                         case OPT_MM_CHARSET:
 2124                             if (prompt_option_string(option)) {
 2125                                 /*
 2126                                  * No charset conversion available, assume local charset
 2127                                  * to be network charset.
 2128                                  */
 2129                                 STRCPY(tinrc.mm_local_charset, tinrc.mm_charset);
 2130                                 changed |= MISC_OPTS;
 2131                             }
 2132                             break;
 2133 #else
 2134 #   ifdef NO_LOCALE
 2135                         case OPT_MM_LOCAL_CHARSET:
 2136                             if (prompt_option_string(option))
 2137                             /* no locales -> can't guess local charset */
 2138                                 changed |= MISC_OPTS;
 2139                             break;
 2140 
 2141 #   endif /* NO_LOCALE */
 2142 #endif /* !CHARSET_CONVERSION */
 2143 
 2144                         case OPT_NEWS_HEADERS_TO_DISPLAY:
 2145                             if (prompt_option_string(option)) {
 2146                                 build_news_headers_array(scopes[0].attribute, TRUE);
 2147                                 changed |= MISC_OPTS;
 2148                             }
 2149                             break;
 2150 
 2151                         case OPT_NEWS_HEADERS_TO_NOT_DISPLAY:
 2152                             if (prompt_option_string(option)) {
 2153                                 build_news_headers_array(scopes[0].attribute, FALSE);
 2154                                 changed |= MISC_OPTS;
 2155                             }
 2156                             break;
 2157 
 2158                         case OPT_POSTED_ARTICLES_FILE:
 2159                             if (prompt_option_string(option)) {
 2160                                 char buf[PATH_LEN];
 2161 
 2162                                 strfpath(tinrc.posted_articles_file, buf, sizeof(buf), &CURR_GROUP, TRUE);
 2163                                 STRCPY(tinrc.posted_articles_file, buf);
 2164                                 changed |= MISC_OPTS;
 2165                             }
 2166                             break;
 2167 
 2168 #ifdef HAVE_COLOR
 2169                         case OPT_QUOTE_REGEX:
 2170                             if (prompt_option_string(option)) {
 2171                                 FreeIfNeeded(quote_regex.re);
 2172                                 FreeIfNeeded(quote_regex.extra);
 2173                                 if (!strlen(tinrc.quote_regex))
 2174                                     STRCPY(tinrc.quote_regex, DEFAULT_QUOTE_REGEX);
 2175                                 compile_regex(tinrc.quote_regex, &quote_regex, PCRE_CASELESS);
 2176                                 changed |= DISPLAY_OPTS;
 2177                             }
 2178                             break;
 2179 
 2180                         case OPT_QUOTE_REGEX2:
 2181                             if (prompt_option_string(option)) {
 2182                                 FreeIfNeeded(quote_regex2.re);
 2183                                 FreeIfNeeded(quote_regex2.extra);
 2184                                 if (!strlen(tinrc.quote_regex2))
 2185                                     STRCPY(tinrc.quote_regex2, DEFAULT_QUOTE_REGEX2);
 2186                                 compile_regex(tinrc.quote_regex2, &quote_regex2, PCRE_CASELESS);
 2187                                 changed |= DISPLAY_OPTS;
 2188                             }
 2189                             break;
 2190 
 2191                         case OPT_QUOTE_REGEX3:
 2192                             if (prompt_option_string(option)) {
 2193                                 FreeIfNeeded(quote_regex3.re);
 2194                                 FreeIfNeeded(quote_regex3.extra);
 2195                                 if (!strlen(tinrc.quote_regex3))
 2196                                     STRCPY(tinrc.quote_regex3, DEFAULT_QUOTE_REGEX3);
 2197                                 compile_regex(tinrc.quote_regex3, &quote_regex3, PCRE_CASELESS);
 2198                                 changed |= DISPLAY_OPTS;
 2199                             }
 2200                             break;
 2201 
 2202                         case OPT_EXTQUOTE_REGEX:
 2203                             if (prompt_option_string(option)) {
 2204                                 FreeIfNeeded(extquote_regex.re);
 2205                                 FreeIfNeeded(extquote_regex.extra);
 2206                                 if (!strlen(tinrc.extquote_regex))
 2207                                     STRCPY(tinrc.extquote_regex, DEFAULT_EXTQUOTE_REGEX);
 2208                                 compile_regex(tinrc.extquote_regex, &extquote_regex, PCRE_CASELESS);
 2209                                 changed |= DISPLAY_OPTS;
 2210                             }
 2211                             break;
 2212 #endif /* HAVE_COLOR */
 2213 
 2214                         case OPT_SELECT_FORMAT:
 2215                             if (prompt_option_string(option)) {
 2216                                 if (!strlen(tinrc.select_format))
 2217                                     STRCPY(tinrc.select_format, DEFAULT_SELECT_FORMAT);
 2218                                 changed |= MISC_OPTS;
 2219                             }
 2220                             break;
 2221 
 2222                         case OPT_SLASHES_REGEX:
 2223                             if (prompt_option_string(option)) {
 2224                                 FreeIfNeeded(slashes_regex.re);
 2225                                 FreeIfNeeded(slashes_regex.extra);
 2226                                 if (!strlen(tinrc.slashes_regex))
 2227                                     STRCPY(tinrc.slashes_regex, DEFAULT_SLASHES_REGEX);
 2228                                 compile_regex(tinrc.slashes_regex, &slashes_regex, PCRE_CASELESS);
 2229                                 changed |= DISPLAY_OPTS;
 2230                             }
 2231                             break;
 2232 
 2233                         case OPT_STARS_REGEX:
 2234                             if (prompt_option_string(option)) {
 2235                                 FreeIfNeeded(stars_regex.re);
 2236                                 FreeIfNeeded(stars_regex.extra);
 2237                                 if (!strlen(tinrc.stars_regex))
 2238                                     STRCPY(tinrc.stars_regex, DEFAULT_STARS_REGEX);
 2239                                 compile_regex(tinrc.stars_regex, &stars_regex, PCRE_CASELESS);
 2240                                 changed |= DISPLAY_OPTS;
 2241                             }
 2242                             break;
 2243 
 2244                         case OPT_STROKES_REGEX:
 2245                             if (prompt_option_string(option)) {
 2246                                 FreeIfNeeded(strokes_regex.re);
 2247                                 FreeIfNeeded(strokes_regex.extra);
 2248                                 if (!strlen(tinrc.strokes_regex))
 2249                                     STRCPY(tinrc.strokes_regex, DEFAULT_STROKES_REGEX);
 2250                                 compile_regex(tinrc.strokes_regex, &strokes_regex, PCRE_CASELESS);
 2251                                 changed |= DISPLAY_OPTS;
 2252                             }
 2253                             break;
 2254 
 2255                         case OPT_UNDERSCORES_REGEX:
 2256                             if (prompt_option_string(option)) {
 2257                                 FreeIfNeeded(underscores_regex.re);
 2258                                 FreeIfNeeded(underscores_regex.extra);
 2259                                 if (!strlen(tinrc.underscores_regex))
 2260                                     STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
 2261                                 compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
 2262                                 changed |= DISPLAY_OPTS;
 2263                             }
 2264                             break;
 2265 
 2266                         case OPT_STRIP_RE_REGEX:
 2267                             if (prompt_option_string(option)) {
 2268                                 FreeIfNeeded(strip_re_regex.re);
 2269                                 FreeIfNeeded(strip_re_regex.extra);
 2270                                 if (!strlen(tinrc.strip_re_regex))
 2271                                     STRCPY(tinrc.strip_re_regex, DEFAULT_STRIP_RE_REGEX);
 2272                                 compile_regex(tinrc.strip_re_regex, &strip_re_regex, PCRE_ANCHORED);
 2273                                 changed |= MISC_OPTS;
 2274                             }
 2275                             break;
 2276 
 2277                         case OPT_STRIP_WAS_REGEX:
 2278                             if (prompt_option_string(option)) {
 2279                                 FreeIfNeeded(strip_was_regex.re);
 2280                                 FreeIfNeeded(strip_was_regex.extra);
 2281                                 if (!strlen(tinrc.strip_was_regex)) {
 2282 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 2283                                     if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre())
 2284                                         STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 2285                                     else
 2286 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 2287                                         STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 2288                                 }
 2289                                 compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
 2290                                 changed |= MISC_OPTS;
 2291                             }
 2292                             break;
 2293 
 2294                         case OPT_THREAD_FORMAT:
 2295                             if (prompt_option_string(option)) {
 2296                                 if (!strlen(tinrc.thread_format))
 2297                                     STRCPY(tinrc.thread_format, DEFAULT_THREAD_FORMAT);
 2298                                 changed |= MISC_OPTS;
 2299                             }
 2300                             break;
 2301 
 2302                         case OPT_ATTRIB_THREAD_FORMAT:
 2303                             if (prompt_option_string(option))
 2304                                 SET_STRING_ATTRIBUTE(thread_format);
 2305                             break;
 2306 
 2307                         case OPT_VERBATIM_BEGIN_REGEX:
 2308                             if (prompt_option_string(option)) {
 2309                                 FreeIfNeeded(verbatim_begin_regex.re);
 2310                                 FreeIfNeeded(verbatim_begin_regex.extra);
 2311                                 if (!strlen(tinrc.verbatim_begin_regex))
 2312                                     STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
 2313                                 compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
 2314                                 changed |= DISPLAY_OPTS;
 2315                             }
 2316                             break;
 2317 
 2318                         case OPT_VERBATIM_END_REGEX:
 2319                             if (prompt_option_string(option)) {
 2320                                 FreeIfNeeded(verbatim_end_regex.re);
 2321                                 FreeIfNeeded(verbatim_end_regex.extra);
 2322                                 if (!strlen(tinrc.verbatim_end_regex))
 2323                                     STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
 2324                                 compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
 2325                                 changed |= DISPLAY_OPTS;
 2326                             }
 2327                             break;
 2328 
 2329                         case OPT_DATE_FORMAT:
 2330                             if (prompt_option_string(option)) {
 2331                                 if (!strlen(tinrc.date_format))
 2332                                     STRCPY(tinrc.date_format, DEFAULT_DATE_FORMAT);
 2333                                 changed |= MISC_OPTS;
 2334                             }
 2335                             break;
 2336 
 2337                         case OPT_ATTRIB_DATE_FORMAT:
 2338                             if (prompt_option_string(option))
 2339                                 SET_STRING_ATTRIBUTE(date_format);
 2340                             break;
 2341 
 2342                         case OPT_ATTRIB_EDITOR_FORMAT:
 2343                             if (prompt_option_string(option))
 2344                                 SET_STRING_ATTRIBUTE(editor_format);
 2345                             break;
 2346 
 2347                         case OPT_ATTRIB_FCC:
 2348                             if (prompt_option_string(option))
 2349                                 SET_STRING_ATTRIBUTE(fcc);
 2350                             break;
 2351 
 2352                         case OPT_ATTRIB_FOLLOWUP_TO:
 2353                             if (prompt_option_string(option))
 2354                                 SET_STRING_ATTRIBUTE(followup_to);
 2355                             break;
 2356 
 2357                         case OPT_ATTRIB_FROM:
 2358                             if (prompt_option_string(option))
 2359                                 SET_STRING_ATTRIBUTE(from);
 2360                             break;
 2361 
 2362 #ifdef HAVE_ISPELL
 2363                         case OPT_ATTRIB_ISPELL:
 2364                             if (prompt_option_string(option))
 2365                                 SET_STRING_ATTRIBUTE(ispell);
 2366                             break;
 2367 #endif /* HAVE_ISPELL */
 2368 
 2369                         case OPT_ATTRIB_MAILDIR:
 2370                             if (prompt_option_string(option))
 2371                                 SET_STRING_ATTRIBUTE(maildir);
 2372                             break;
 2373 
 2374                         case OPT_ATTRIB_MAILING_LIST:
 2375                             if (prompt_option_string(option))
 2376                                 SET_STRING_ATTRIBUTE(mailing_list);
 2377                             break;
 2378 
 2379                         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 2380                             if (prompt_option_string(option))
 2381                                 SET_STRING_ATTRIBUTE(mime_types_to_save);
 2382                             break;
 2383 
 2384                         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 2385                             if (prompt_option_string(option)) {
 2386                                 SET_STRING_ATTRIBUTE(news_headers_to_display);
 2387                                 build_news_headers_array(curr_scope->attribute, TRUE);
 2388                                 changed |= DISPLAY_OPTS;
 2389                             }
 2390                             break;
 2391 
 2392                         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 2393                             if (prompt_option_string(option)) {
 2394                                 SET_STRING_ATTRIBUTE(news_headers_to_not_display);
 2395                                 build_news_headers_array(curr_scope->attribute, FALSE);
 2396                                 changed |= DISPLAY_OPTS;
 2397                             }
 2398                             break;
 2399 
 2400                         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 2401                             if (prompt_option_string(option))
 2402                                 SET_STRING_ATTRIBUTE(news_quote_format);
 2403                             break;
 2404 
 2405                         case OPT_ATTRIB_ORGANIZATION:
 2406                             if (prompt_option_string(option))
 2407                                 SET_STRING_ATTRIBUTE(organization);
 2408                             break;
 2409 
 2410                         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 2411                             if (prompt_option_string(option))
 2412                                 SET_STRING_ATTRIBUTE(quick_kill_scope);
 2413                             break;
 2414 
 2415                         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 2416                             if (prompt_option_string(option))
 2417                                 SET_STRING_ATTRIBUTE(quick_select_scope);
 2418                             break;
 2419 
 2420                         case OPT_ATTRIB_QUOTE_CHARS:
 2421                             if (prompt_option_string(option))
 2422                                 SET_STRING_ATTRIBUTE(quote_chars);
 2423                             break;
 2424 
 2425                         case OPT_ATTRIB_SAVEDIR:
 2426                             if (prompt_option_string(option))
 2427                                 SET_STRING_ATTRIBUTE(savedir);
 2428                             break;
 2429 
 2430                         case OPT_ATTRIB_SAVEFILE:
 2431                             if (prompt_option_string(option))
 2432                                 SET_STRING_ATTRIBUTE(savefile);
 2433                             break;
 2434 
 2435                         case OPT_ATTRIB_SIGFILE:
 2436                             if (prompt_option_string(option))
 2437                                 SET_STRING_ATTRIBUTE(sigfile);
 2438                             break;
 2439 
 2440 #ifdef CHARSET_CONVERSION
 2441                         case OPT_ATTRIB_UNDECLARED_CHARSET:
 2442                             if (prompt_option_string(option))
 2443                                 SET_STRING_ATTRIBUTE(undeclared_charset);
 2444                             break;
 2445 
 2446 #endif /* CHARSET_CONVERSION */
 2447                         case OPT_ATTRIB_X_BODY:
 2448                             if (prompt_option_string(option))
 2449                                 SET_STRING_ATTRIBUTE(x_body);
 2450                             break;
 2451 
 2452                         case OPT_ATTRIB_X_HEADERS:
 2453                             if (prompt_option_string(option))
 2454                                 SET_STRING_ATTRIBUTE(x_headers);
 2455                             break;
 2456 
 2457                         default:
 2458                             break;
 2459                     } /* switch (option) */
 2460 
 2461                     break;
 2462 
 2463                 case OPT_NUM:
 2464                     switch (option) {
 2465                         case OPT_GETART_LIMIT:
 2466                         case OPT_SCROLL_LINES:
 2467                             if (prompt_option_num(option))
 2468                                 changed |= MISC_OPTS;
 2469                             break;
 2470 
 2471 #if defined(HAVE_ALARM) && defined(SIGALRM)
 2472                         case OPT_NNTP_READ_TIMEOUT_SECS:
 2473                             if (prompt_option_num(option)) {
 2474                                 if (tinrc.nntp_read_timeout_secs < 0)
 2475                                     tinrc.nntp_read_timeout_secs = 0;
 2476                                 changed |= MISC_OPTS;
 2477                             }
 2478                             break;
 2479 #endif /* HAVE_ALARM && SIGALRM */
 2480 
 2481                         case OPT_REREAD_ACTIVE_FILE_SECS:
 2482                             if (prompt_option_num(option)) {
 2483                                 if (tinrc.reread_active_file_secs < 0)
 2484                                     tinrc.reread_active_file_secs = 0;
 2485                                 changed |= MISC_OPTS;
 2486                             }
 2487                             break;
 2488 
 2489                         case OPT_RECENT_TIME:
 2490                             if (prompt_option_num(option)) {
 2491                                 if (tinrc.recent_time < 0)
 2492                                     tinrc.recent_time = 0;
 2493                                 changed |= MISC_OPTS;
 2494                             }
 2495                             break;
 2496 
 2497                         case OPT_FILTER_DAYS:
 2498                             if (prompt_option_num(option)) {
 2499                                 if (tinrc.filter_days <= 0)
 2500                                     tinrc.filter_days = 1;
 2501                                 changed |= MISC_OPTS;
 2502                             }
 2503                             break;
 2504 
 2505                         case OPT_SCORE_LIMIT_KILL:
 2506                         case OPT_SCORE_KILL:
 2507                         case OPT_SCORE_LIMIT_SELECT:
 2508                         case OPT_SCORE_SELECT:
 2509                             if (prompt_option_num(option)) {
 2510                                 check_score_defaults();
 2511                                 redraw_screen(option);
 2512                                 changed |= SCORE_OPTS;
 2513                             }
 2514                             break;
 2515 
 2516                         case OPT_THREAD_PERC:
 2517                             if (prompt_option_num(option)) {
 2518                                 if (tinrc.thread_perc < 0 || tinrc.thread_perc > 100)
 2519                                     tinrc.thread_perc = THREAD_PERC_DEFAULT;
 2520                                 UPDATE_INT_ATTRIBUTES(thread_perc);
 2521                             }
 2522                             break;
 2523 
 2524                         case OPT_WRAP_COLUMN:
 2525                             if (prompt_option_num(option))
 2526                                 changed |= DISPLAY_OPTS;
 2527                             break;
 2528 
 2529                         case OPT_ATTRIB_THREAD_PERC:
 2530                             if (prompt_option_num(option))
 2531                                 SET_NUM_ATTRIBUTE(thread_perc);
 2532                             break;
 2533 
 2534                         default:
 2535                             break;
 2536                     } /* switch (option) */
 2537                     break;
 2538 
 2539                 case OPT_CHAR:
 2540                     switch (option) {
 2541                         /*
 2542                          * TODO: do DASH_TO_SPACE/SPACE_TO_DASH conversion here?
 2543                          */
 2544                         case OPT_ART_MARKED_DELETED:
 2545                         case OPT_ART_MARKED_INRANGE:
 2546                         case OPT_ART_MARKED_RETURN:
 2547                         case OPT_ART_MARKED_SELECTED:
 2548                         case OPT_ART_MARKED_RECENT:
 2549                         case OPT_ART_MARKED_UNREAD:
 2550                         case OPT_ART_MARKED_READ:
 2551                         case OPT_ART_MARKED_KILLED:
 2552                         case OPT_ART_MARKED_READ_SELECTED:
 2553                             if (prompt_option_char(option))
 2554                                 changed |= MISC_OPTS;
 2555                             break;
 2556 
 2557                         default:
 2558                             break;
 2559                     } /* switch (option) */
 2560                     break;
 2561 
 2562                 default:
 2563                     break;
 2564             } /* switch (option_table[option].var_type) */
 2565             change_option = FALSE;
 2566             show_menu_help(txt_select_config_file_option);
 2567             repaint_option(option);
 2568             highlight_option(option);
 2569         } /* if (change_option) */
 2570     } /* forever */
 2571     /* NOTREACHED */
 2572     return;
 2573 }
 2574 
 2575 
 2576 /*
 2577  * scopes and attributes menu
 2578  */
 2579 
 2580 static t_function
 2581 scope_left(
 2582     void)
 2583 {
 2584     return GLOBAL_QUIT;
 2585 }
 2586 
 2587 
 2588 static t_function
 2589 scope_right(
 2590     void)
 2591 {
 2592     return SCOPE_SELECT;
 2593 }
 2594 
 2595 
 2596 static void
 2597 show_scope_page(
 2598     void)
 2599 {
 2600     int i;
 2601 
 2602     signal_context = cScope;
 2603     currmenu = &scopemenu;
 2604     mark_offset = 0;
 2605 
 2606     if (scopemenu.curr < 0)
 2607         scopemenu.curr = 0;
 2608 
 2609     scopemenu.max = num_scope - 1;
 2610 
 2611     ClearScreen();
 2612     set_first_screen_item();
 2613     center_line(0, TRUE, _(txt_scopes_menu));
 2614 
 2615     for (i = scopemenu.first; i < scopemenu.first + NOTESLINES && i < scopemenu.max; ++i)
 2616         build_scope_line(i);
 2617 
 2618     show_mini_help(SCOPE_LEVEL);
 2619 
 2620     if (scopemenu.max <= 0) {
 2621         info_message(_(txt_no_scopes));
 2622         return;
 2623     }
 2624 
 2625     draw_scope_arrow();
 2626 }
 2627 
 2628 
 2629 static void
 2630 scope_page(
 2631     enum context level)
 2632 {
 2633     char key[MAXKEYLEN];
 2634     int i;
 2635     t_bool changed = FALSE;
 2636     t_function func;
 2637     t_menu *oldmenu = NULL;
 2638 
 2639     if (currmenu)
 2640         oldmenu = currmenu;
 2641     scopemenu.curr = 0;
 2642     clear_note_area();
 2643     show_scope_page();
 2644     set_xclick_off();
 2645 
 2646     forever {
 2647         switch ((func = handle_keypad(scope_left, scope_right, NULL, scope_keys))) {
 2648             case GLOBAL_QUIT:
 2649                 if (changed)
 2650                     write_attributes_file(local_attributes_file);
 2651                 clear_note_area();
 2652                 if (oldmenu)
 2653                     currmenu = oldmenu;
 2654                 return;
 2655 
 2656             case DIGIT_1:
 2657             case DIGIT_2:
 2658             case DIGIT_3:
 2659             case DIGIT_4:
 2660             case DIGIT_5:
 2661             case DIGIT_6:
 2662             case DIGIT_7:
 2663             case DIGIT_8:
 2664             case DIGIT_9:
 2665                 if (scopemenu.max)
 2666                     prompt_item_num(func_to_key(func, scope_keys), _(txt_scope_select));
 2667                 break;
 2668 
 2669 #ifndef NO_SHELL_ESCAPE
 2670             case GLOBAL_SHELL_ESCAPE:
 2671                 do_shell_escape();
 2672                 break;
 2673 #endif /* !NO_SHELL_ESCAPE */
 2674 
 2675             case GLOBAL_HELP:
 2676                 show_help_page(SCOPE_LEVEL, _(txt_scopes_menu_com));
 2677                 show_scope_page();
 2678                 break;
 2679 
 2680             case GLOBAL_FIRST_PAGE:
 2681                 top_of_list();
 2682                 break;
 2683 
 2684             case GLOBAL_LAST_PAGE:
 2685                 end_of_list();
 2686                 break;
 2687 
 2688             case GLOBAL_REDRAW_SCREEN:
 2689                 my_retouch();
 2690                 set_xclick_off();
 2691                 show_scope_page();
 2692                 break;
 2693 
 2694             case GLOBAL_LINE_DOWN:
 2695                 move_down();
 2696                 break;
 2697 
 2698             case GLOBAL_LINE_UP:
 2699                 move_up();
 2700                 break;
 2701 
 2702             case GLOBAL_PAGE_DOWN:
 2703                 page_down();
 2704                 break;
 2705 
 2706             case GLOBAL_PAGE_UP:
 2707                 page_up();
 2708                 break;
 2709 
 2710             case GLOBAL_SCROLL_DOWN:
 2711                 scroll_down();
 2712                 break;
 2713 
 2714             case GLOBAL_SCROLL_UP:
 2715                 scroll_up();
 2716                 break;
 2717 
 2718             case GLOBAL_TOGGLE_HELP_DISPLAY:
 2719                 toggle_mini_help(SCOPE_LEVEL);
 2720                 show_scope_page();
 2721                 break;
 2722 
 2723             case SCOPE_ADD:
 2724                 if ((i = add_new_scope())) {
 2725                     changed = TRUE;
 2726                     scopemenu.curr = i;
 2727                     show_scope_page();
 2728                 }
 2729                 break;
 2730 
 2731             case SCOPE_DELETE:
 2732                 if (scopemenu.max) {
 2733                     if (scopes[scopemenu.curr + 1].global)
 2734                         info_message(_(txt_scope_operation_not_allowed));
 2735                     else if (delete_scope(scopemenu.curr + 1)) {
 2736                         changed = TRUE;
 2737                         show_scope_page();
 2738                     }
 2739                 }
 2740                 break;
 2741 
 2742             case SCOPE_EDIT_ATTRIBUTES_FILE:
 2743                 if (changed)
 2744                     write_attributes_file(local_attributes_file);
 2745                 if (!invoke_editor(local_attributes_file, attrib_file_offset, NULL))
 2746                     break;
 2747                 free_scopes_and_attributes();
 2748                 read_attributes_file(FALSE);
 2749                 assign_attributes_to_groups();
 2750                 changed = FALSE;
 2751                 scopemenu.curr = 0;
 2752                 show_scope_page();
 2753                 break;
 2754 
 2755             case SCOPE_MOVE:
 2756                 if (scopemenu.max > 1) {
 2757                     if (scopes[scopemenu.curr + 1].global)
 2758                         info_message(_(txt_scope_operation_not_allowed));
 2759                     else if ((i = move_scope(scopemenu.curr + 1))) {
 2760                         changed = TRUE;
 2761                         scopemenu.curr = i - 1;
 2762                         show_scope_page();
 2763                     }
 2764                 }
 2765                 break;
 2766 
 2767             case SCOPE_RENAME:
 2768                 if (scopemenu.max) {
 2769                     if (scopes[scopemenu.curr + 1].global)
 2770                         info_message(_(txt_scope_operation_not_allowed));
 2771                     else if (rename_scope(&scopes[scopemenu.curr + 1])) {
 2772                         changed = TRUE;
 2773                         show_scope_page();
 2774                     }
 2775                 }
 2776                 break;
 2777 
 2778             case SCOPE_SELECT:
 2779                 if (scopemenu.max) {
 2780                     curr_scope = &scopes[scopemenu.curr + 1];
 2781                     config_page(NULL, level);
 2782                     if (!curr_scope->global && scope_is_empty())
 2783                         do_delete_scope(scopemenu.curr + 1);
 2784                     curr_scope = NULL;
 2785                     changed = TRUE;
 2786                     show_scope_page();
 2787                 }
 2788                 break;
 2789 
 2790             default:
 2791                 info_message(_(txt_bad_command), printascii(key, func_to_key(GLOBAL_HELP, scope_keys)));
 2792                 break;
 2793         }
 2794     }
 2795 }
 2796 
 2797 
 2798 static void
 2799 draw_scope_arrow(
 2800     void)
 2801 {
 2802     draw_arrow_mark(INDEX_TOP + scopemenu.curr - scopemenu.first);
 2803     if (scopemenu.curr == scopemenu.max - 1)
 2804         info_message(_(txt_end_of_scopes));
 2805 }
 2806 
 2807 
 2808 static void
 2809 build_scope_line(
 2810     int i)
 2811 {
 2812     char *sptr;
 2813     int len = cCOLS - 11;
 2814 
 2815 #ifdef USE_CURSES
 2816     /*
 2817      * Allocate line buffer
 2818      * make it the same size like in !USE_CURSES case to simplify some code
 2819      */
 2820     sptr = my_malloc(cCOLS + 2);
 2821 #else
 2822     sptr = screen[INDEX2SNUM(i)].col;
 2823 #endif /* USE_CURSES */
 2824 
 2825     snprintf(sptr, cCOLS, "  %c %s  %-*.*s%s", (scopes[i + 1].global ? '!' : ' '), tin_ltoa(i + 1, 4), len, len, scopes[i + 1].scope, cCRLF);
 2826 
 2827 #ifndef USE_CURSES
 2828     if (tinrc.strip_blanks)
 2829         strcat(strip_line(sptr), cCRLF);
 2830 #endif /* !USE_CURSES */
 2831 
 2832     WriteLine(INDEX2LNUM(i), sptr);
 2833 
 2834 #ifdef USE_CURSES
 2835     free(sptr);
 2836 #endif /* USE_CURSES */
 2837 }
 2838 
 2839 
 2840 /*
 2841  * add a new scope and return the index
 2842  */
 2843 static int
 2844 add_new_scope(
 2845     void)
 2846 {
 2847     char buf[LEN];
 2848     int new_pos = 0;
 2849 
 2850     if (prompt_default_string(_(txt_scope_enter), buf, sizeof(buf), (char *) NULL, HIST_OTHER))
 2851         new_pos = add_scope(buf);
 2852 
 2853     return new_pos;
 2854 }
 2855 
 2856 
 2857 /*
 2858  * returns TRUE if the given scope was deleted
 2859  */
 2860 static t_bool
 2861 delete_scope(
 2862     int curr_pos)
 2863 {
 2864     if (prompt_yn(_(txt_scope_delete), FALSE) == 1) {
 2865         do_delete_scope(curr_pos);
 2866         return TRUE;
 2867     }
 2868 
 2869     return FALSE;
 2870 }
 2871 
 2872 
 2873 static void
 2874 do_delete_scope(
 2875     int curr_pos)
 2876 {
 2877     do_move_scope(curr_pos, num_scope - 1);
 2878     free_scope(--num_scope);
 2879 }
 2880 
 2881 
 2882 /*
 2883  * returns TRUE if scope was renamed
 2884  */
 2885 static t_bool
 2886 rename_scope(
 2887     struct t_scope *scope)
 2888 {
 2889     char buf[LEN];
 2890 
 2891     if (prompt_default_string(_(txt_scope_rename), buf, sizeof(buf), scope->scope, HIST_OTHER)) {
 2892         if (buf[0] == '\0')
 2893             return FALSE;
 2894         FreeIfNeeded(scope->scope);
 2895         scope->scope = my_strdup(buf);
 2896         return TRUE;
 2897     }
 2898 
 2899     return FALSE;
 2900 }
 2901 
 2902 
 2903 /*
 2904  * look if an entry with the given scope exists and return the index
 2905  */
 2906 static int
 2907 find_scope(
 2908     const char *scope)
 2909 {
 2910     int i;
 2911 
 2912     if (!scope || !*scope)
 2913         return 0;
 2914 
 2915     for (i = 1; i < num_scope; i++) {
 2916         if ((!scopes[i].global && strcasecmp(scope, scopes[i].scope) == 0))
 2917             return i;
 2918     }
 2919 
 2920     return 0;
 2921 }
 2922 
 2923 
 2924 /*
 2925  * returns the new position of the moved scope or 0 if repositioning
 2926  * is not possible
 2927  */
 2928 static int
 2929 move_scope(
 2930     int curr_pos)
 2931 {
 2932     char *p;
 2933     int new_pos;
 2934 
 2935     clear_message();
 2936     if ((p = tin_getline(_(txt_scope_new_position), 1, 0, 0, FALSE, HIST_OTHER)) != NULL)
 2937         new_pos = atoi(p);
 2938     else
 2939         new_pos = curr_pos;
 2940     clear_message();
 2941 
 2942     if (new_pos == curr_pos || new_pos == 0)
 2943         return 0;
 2944 
 2945     if (new_pos >= num_scope)
 2946         new_pos = num_scope - 1;
 2947 
 2948     if (scopes[new_pos].global) {
 2949         info_message(_(txt_scope_new_position_is_global));
 2950         return 0;
 2951     }
 2952 
 2953     do_move_scope(curr_pos, new_pos);
 2954 
 2955     return new_pos;
 2956 }
 2957 
 2958 
 2959 /*
 2960  * repositions a scope into scopes[]
 2961  */
 2962 static void
 2963 do_move_scope(
 2964     int from,
 2965     int to)
 2966 {
 2967     struct t_scope tmp;
 2968 
 2969     if (from == to)
 2970         return;
 2971 
 2972     tmp = scopes[from];
 2973 
 2974     if (from > to) {
 2975         while (from-- > to)
 2976             scopes[from + 1] = scopes[from];
 2977     } else {
 2978         while (from++ < to)
 2979             scopes[from - 1] = scopes[from];
 2980     }
 2981     scopes[to] = tmp;
 2982 }
 2983 
 2984 
 2985 /*
 2986  * free all group->attribute arrays and all scopes which are
 2987  * not marked as global
 2988  */
 2989 static void
 2990 free_scopes_and_attributes(
 2991     void)
 2992 {
 2993     int i;
 2994 
 2995     for_each_group(i) {
 2996         if (active[i].attribute && !active[i].attribute->global) {
 2997             free(active[i].attribute);
 2998             active[i].attribute = (struct t_attribute *) 0;
 2999         }
 3000     }
 3001 
 3002     while (num_scope > 1 && !scopes[num_scope - 1].global)
 3003             free_scope(--num_scope);
 3004 }
 3005 
 3006 
 3007 /*
 3008  * returns TRUE if no attribute in curr_scope has state == TRUE
 3009  */
 3010 static t_bool
 3011 scope_is_empty(
 3012     void)
 3013 {
 3014     enum option_enum i;
 3015 
 3016     for (i = 0; i <= last_opt; i++) {
 3017         if (option_is_visible(i) && !option_is_title(i) && check_state(i))
 3018             return FALSE;
 3019     }
 3020 
 3021     return TRUE;
 3022 }
 3023 
 3024 
 3025 /*
 3026  * returns the state of the given attribute
 3027  */
 3028 static t_bool
 3029 check_state(
 3030     enum option_enum option)
 3031 {
 3032     switch (option) {
 3033         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
 3034             return curr_scope->state->add_posted_to_filter;
 3035         case OPT_ATTRIB_ADVERTISING:
 3036             return curr_scope->state->advertising;
 3037         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
 3038             return curr_scope->state->alternative_handling;
 3039         case OPT_ATTRIB_ASK_FOR_METAMAIL:
 3040             return curr_scope->state->ask_for_metamail;
 3041         case OPT_ATTRIB_AUTO_CC_BCC:
 3042             return curr_scope->state->auto_cc_bcc;
 3043         case OPT_ATTRIB_AUTO_LIST_THREAD:
 3044             return curr_scope->state->auto_list_thread;
 3045         case OPT_ATTRIB_AUTO_SAVE:
 3046             return curr_scope->state->auto_save;
 3047         case OPT_ATTRIB_AUTO_SELECT:
 3048             return curr_scope->state->auto_select;
 3049         case OPT_ATTRIB_BATCH_SAVE:
 3050             return curr_scope->state->batch_save;
 3051         case OPT_ATTRIB_DATE_FORMAT:
 3052             return curr_scope->state->date_format;
 3053         case OPT_ATTRIB_DELETE_TMP_FILES:
 3054             return curr_scope->state->delete_tmp_files;
 3055         case OPT_ATTRIB_EDITOR_FORMAT:
 3056             return curr_scope->state->editor_format;
 3057 #ifdef HAVE_COLOR
 3058         case OPT_ATTRIB_EXTQUOTE_HANDLING:
 3059             return curr_scope->state->extquote_handling;
 3060 #endif /* HAVE_COLOR */
 3061         case OPT_ATTRIB_FCC:
 3062             return curr_scope->state->fcc;
 3063         case OPT_ATTRIB_FOLLOWUP_TO:
 3064             return curr_scope->state->followup_to;
 3065         case OPT_ATTRIB_FROM:
 3066             return curr_scope->state->from;
 3067         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
 3068             return curr_scope->state->group_catchup_on_exit;
 3069         case OPT_ATTRIB_GROUP_FORMAT:
 3070             return curr_scope->state->group_format;
 3071 #ifdef HAVE_ISPELL
 3072         case OPT_ATTRIB_ISPELL:
 3073             return curr_scope->state->ispell;
 3074 #endif /* HAVE_ISPELL */
 3075         case OPT_ATTRIB_MAILDIR:
 3076             return curr_scope->state->maildir;
 3077         case OPT_ATTRIB_MAIL_8BIT_HEADER:
 3078             return curr_scope->state->mail_8bit_header;
 3079         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 3080             return curr_scope->state->mail_mime_encoding;
 3081         case OPT_ATTRIB_MAILING_LIST:
 3082             return curr_scope->state->mailing_list;
 3083         case OPT_ATTRIB_MARK_IGNORE_TAGS:
 3084             return curr_scope->state->mark_ignore_tags;
 3085         case OPT_ATTRIB_MARK_SAVED_READ:
 3086             return curr_scope->state->mark_saved_read;
 3087         case OPT_ATTRIB_MIME_FORWARD:
 3088             return curr_scope->state->mime_forward;
 3089         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 3090             return curr_scope->state->mime_types_to_save;
 3091         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 3092             return curr_scope->state->news_headers_to_display;
 3093         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 3094             return curr_scope->state->news_headers_to_not_display;
 3095         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 3096             return curr_scope->state->news_quote_format;
 3097         case OPT_ATTRIB_ORGANIZATION:
 3098             return curr_scope->state->organization;
 3099         case OPT_ATTRIB_POST_8BIT_HEADER:
 3100             return curr_scope->state->post_8bit_header;
 3101         case OPT_ATTRIB_POST_MIME_ENCODING:
 3102             return curr_scope->state->post_mime_encoding;
 3103         case OPT_ATTRIB_POST_PROCESS_VIEW:
 3104             return curr_scope->state->post_process_view;
 3105         case OPT_ATTRIB_POS_FIRST_UNREAD:
 3106             return curr_scope->state->pos_first_unread;
 3107 #ifndef DISABLE_PRINTING
 3108         case OPT_ATTRIB_PRINT_HEADER:
 3109             return curr_scope->state->print_header;
 3110 #endif /* !DISABLE_PRINTING */
 3111         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
 3112             return curr_scope->state->process_only_unread;
 3113         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
 3114             return curr_scope->state->prompt_followupto;
 3115         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 3116             return curr_scope->state->quick_kill_scope;
 3117         case OPT_ATTRIB_QUICK_KILL_HEADER:
 3118             return curr_scope->state->quick_kill_header;
 3119         case OPT_ATTRIB_QUICK_KILL_CASE:
 3120             return curr_scope->state->quick_kill_case;
 3121         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
 3122             return curr_scope->state->quick_kill_expire;
 3123         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 3124             return curr_scope->state->quick_select_scope;
 3125         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 3126             return curr_scope->state->quick_select_header;
 3127         case OPT_ATTRIB_QUICK_SELECT_CASE:
 3128             return curr_scope->state->quick_select_case;
 3129         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
 3130             return curr_scope->state->quick_select_expire;
 3131         case OPT_ATTRIB_QUOTE_CHARS:
 3132             return curr_scope->state->quote_chars;
 3133         case OPT_ATTRIB_SAVEDIR:
 3134             return curr_scope->state->savedir;
 3135         case OPT_ATTRIB_SAVEFILE:
 3136             return curr_scope->state->savefile;
 3137         case OPT_ATTRIB_SHOW_AUTHOR:
 3138             return curr_scope->state->show_author;
 3139         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
 3140             return curr_scope->state->show_only_unread_arts;
 3141         case OPT_ATTRIB_SHOW_SIGNATURES:
 3142             return curr_scope->state->show_signatures;
 3143         case OPT_ATTRIB_SIGDASHES:
 3144             return curr_scope->state->sigdashes;
 3145         case OPT_ATTRIB_SIGFILE:
 3146             return curr_scope->state->sigfile;
 3147         case OPT_ATTRIB_SIGNATURE_REPOST:
 3148             return curr_scope->state->signature_repost;
 3149         case OPT_ATTRIB_START_EDITOR_OFFSET:
 3150             return curr_scope->state->start_editor_offset;
 3151         case OPT_ATTRIB_THREAD_ARTICLES:
 3152             return curr_scope->state->thread_articles;
 3153         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
 3154             return curr_scope->state->thread_catchup_on_exit;
 3155         case OPT_ATTRIB_THREAD_FORMAT:
 3156             return curr_scope->state->thread_format;
 3157         case OPT_ATTRIB_THREAD_PERC:
 3158             return curr_scope->state->thread_perc;
 3159         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 3160             return curr_scope->state->trim_article_body;
 3161         case OPT_ATTRIB_TEX2ISO_CONV:
 3162             return curr_scope->state->tex2iso_conv;
 3163         case OPT_ATTRIB_SORT_THREADS_TYPE:
 3164             return curr_scope->state->sort_threads_type;
 3165 #ifdef CHARSET_CONVERSION
 3166         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 3167             return curr_scope->state->mm_network_charset;
 3168         case OPT_ATTRIB_UNDECLARED_CHARSET:
 3169             return curr_scope->state->undeclared_charset;
 3170 #endif /* CHARSET_CONVERSION */
 3171         case OPT_ATTRIB_VERBATIM_HANDLING:
 3172             return curr_scope->state->verbatim_handling;
 3173         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
 3174             return curr_scope->state->wrap_on_next_unread;
 3175         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 3176             return curr_scope->state->sort_article_type;
 3177         case OPT_ATTRIB_POST_PROCESS_TYPE:
 3178             return curr_scope->state->post_process_type;
 3179         case OPT_ATTRIB_X_BODY:
 3180             return curr_scope->state->x_body;
 3181         case OPT_ATTRIB_X_COMMENT_TO:
 3182             return curr_scope->state->x_comment_to;
 3183         case OPT_ATTRIB_X_HEADERS:
 3184             return curr_scope->state->x_headers;
 3185 
 3186         default:
 3187             return FALSE;
 3188     }
 3189 }
 3190 
 3191 
 3192 /*
 3193  * set the state of the given attribute to FALSE and the corresponding
 3194  * tinrc.attrib_* to a default value
 3195  */
 3196 static void
 3197 reset_state(
 3198     enum option_enum option)
 3199 {
 3200     struct t_scope *default_scope = &scopes[0];
 3201 
 3202     switch (option) {
 3203         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
 3204             curr_scope->state->add_posted_to_filter = FALSE;
 3205             tinrc.attrib_add_posted_to_filter = default_scope->attribute->add_posted_to_filter;
 3206             break;
 3207         case OPT_ATTRIB_ADVERTISING:
 3208             curr_scope->state->advertising = FALSE;
 3209             tinrc.attrib_advertising = default_scope->attribute->advertising;
 3210             break;
 3211         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
 3212             curr_scope->state->alternative_handling = FALSE;
 3213             tinrc.attrib_alternative_handling = default_scope->attribute->alternative_handling;
 3214             break;
 3215         case OPT_ATTRIB_ASK_FOR_METAMAIL:
 3216             curr_scope->state->ask_for_metamail = FALSE;
 3217             tinrc.attrib_ask_for_metamail = default_scope->attribute->ask_for_metamail;
 3218             break;
 3219         case OPT_ATTRIB_AUTO_CC_BCC:
 3220             curr_scope->state->auto_cc_bcc = FALSE;
 3221             tinrc.attrib_auto_cc_bcc = default_scope->attribute->auto_cc_bcc;
 3222             break;
 3223         case OPT_ATTRIB_AUTO_LIST_THREAD:
 3224             curr_scope->state->auto_list_thread = FALSE;
 3225             tinrc.attrib_auto_list_thread = default_scope->attribute->auto_list_thread;
 3226             break;
 3227         case OPT_ATTRIB_AUTO_SAVE:
 3228             curr_scope->state->auto_save = FALSE;
 3229             tinrc.attrib_auto_save = default_scope->attribute->auto_save;
 3230             break;
 3231         case OPT_ATTRIB_AUTO_SELECT:
 3232             curr_scope->state->auto_select = FALSE;
 3233             tinrc.attrib_auto_select = default_scope->attribute->auto_select;
 3234             break;
 3235         case OPT_ATTRIB_BATCH_SAVE:
 3236             curr_scope->state->batch_save = FALSE;
 3237             tinrc.attrib_batch_save = default_scope->attribute->batch_save;
 3238             break;
 3239         case OPT_ATTRIB_DATE_FORMAT:
 3240             FreeAndNull(curr_scope->attribute->date_format);
 3241             curr_scope->state->date_format = FALSE;
 3242             snprintf(tinrc.attrib_date_format, sizeof(tinrc.attrib_date_format), "%s", BlankIfNull(default_scope->attribute->date_format));
 3243             break;
 3244         case OPT_ATTRIB_DELETE_TMP_FILES:
 3245             curr_scope->state->delete_tmp_files = FALSE;
 3246             tinrc.attrib_delete_tmp_files = default_scope->attribute->delete_tmp_files;
 3247             break;
 3248         case OPT_ATTRIB_EDITOR_FORMAT:
 3249             FreeAndNull(curr_scope->attribute->editor_format);
 3250             curr_scope->state->editor_format = FALSE;
 3251             snprintf(tinrc.attrib_editor_format, sizeof(tinrc.attrib_editor_format), "%s", BlankIfNull(default_scope->attribute->editor_format));
 3252             break;
 3253 #ifdef HAVE_COLOR
 3254         case OPT_ATTRIB_EXTQUOTE_HANDLING:
 3255             curr_scope->state->extquote_handling = FALSE;
 3256             tinrc.attrib_extquote_handling = default_scope->attribute->extquote_handling;
 3257             break;
 3258 #endif /* HAVE_COLOR */
 3259         case OPT_ATTRIB_FCC:
 3260             FreeAndNull(curr_scope->attribute->fcc);
 3261             curr_scope->state->fcc = FALSE;
 3262             snprintf(tinrc.attrib_fcc, sizeof(tinrc.attrib_fcc), "%s", BlankIfNull(default_scope->attribute->fcc));
 3263             break;
 3264         case OPT_ATTRIB_FOLLOWUP_TO:
 3265             FreeAndNull(curr_scope->attribute->followup_to);
 3266             curr_scope->state->followup_to = FALSE;
 3267             snprintf(tinrc.attrib_followup_to, sizeof(tinrc.attrib_followup_to), "%s", BlankIfNull(default_scope->attribute->followup_to));
 3268             break;
 3269         case OPT_ATTRIB_FROM:
 3270             FreeAndNull(curr_scope->attribute->from);
 3271             curr_scope->state->from = FALSE;
 3272             snprintf(tinrc.attrib_from, sizeof(tinrc.attrib_from), "%s", BlankIfNull(default_scope->attribute->from));
 3273             break;
 3274         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
 3275             curr_scope->state->group_catchup_on_exit = FALSE;
 3276             tinrc.attrib_group_catchup_on_exit = default_scope->attribute->group_catchup_on_exit;
 3277             break;
 3278         case OPT_ATTRIB_GROUP_FORMAT:
 3279             FreeAndNull(curr_scope->attribute->group_format);
 3280             curr_scope->state->group_format = FALSE;
 3281             snprintf(tinrc.attrib_group_format, sizeof(tinrc.attrib_group_format), "%s", BlankIfNull(default_scope->attribute->group_format));
 3282             break;
 3283 #ifdef HAVE_ISPELL
 3284         case OPT_ATTRIB_ISPELL:
 3285             FreeAndNull(curr_scope->attribute->ispell);
 3286             curr_scope->state->ispell = FALSE;
 3287             snprintf(tinrc.attrib_ispell, sizeof(tinrc.attrib_ispell), "%s", BlankIfNull(default_scope->attribute->ispell));
 3288             break;
 3289 #endif /* HAVE_ISPELL */
 3290         case OPT_ATTRIB_MAILDIR:
 3291             FreeAndNull(curr_scope->attribute->maildir);
 3292             curr_scope->state->maildir = FALSE;
 3293             snprintf(tinrc.attrib_maildir, sizeof(tinrc.attrib_maildir), "%s", BlankIfNull(default_scope->attribute->maildir));
 3294             break;
 3295         case OPT_ATTRIB_MAIL_8BIT_HEADER:
 3296             curr_scope->state->mail_8bit_header = FALSE;
 3297             tinrc.attrib_mail_8bit_header = default_scope->attribute->mail_8bit_header;
 3298             break;
 3299         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 3300             curr_scope->state->mail_mime_encoding = FALSE;
 3301             tinrc.attrib_mail_mime_encoding = default_scope->attribute->mail_mime_encoding;
 3302             break;
 3303         case OPT_ATTRIB_MAILING_LIST:
 3304             FreeAndNull(curr_scope->attribute->mailing_list);
 3305             curr_scope->state->mailing_list = FALSE;
 3306             snprintf(tinrc.attrib_mailing_list, sizeof(tinrc.attrib_mailing_list), "%s", BlankIfNull(default_scope->attribute->mailing_list));
 3307             break;
 3308         case OPT_ATTRIB_MARK_IGNORE_TAGS:
 3309             curr_scope->state->mark_ignore_tags = FALSE;
 3310             tinrc.attrib_mark_ignore_tags = default_scope->attribute->mark_ignore_tags;
 3311             break;
 3312         case OPT_ATTRIB_MARK_SAVED_READ:
 3313             curr_scope->state->mark_saved_read = FALSE;
 3314             tinrc.attrib_mark_saved_read = default_scope->attribute->mark_saved_read;
 3315             break;
 3316         case OPT_ATTRIB_MIME_FORWARD:
 3317             curr_scope->state->mime_forward = FALSE;
 3318             tinrc.attrib_mime_forward = default_scope->attribute->mime_forward;
 3319             break;
 3320         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 3321             FreeAndNull(curr_scope->attribute->mime_types_to_save);
 3322             curr_scope->state->mime_types_to_save = FALSE;
 3323             snprintf(tinrc.attrib_mime_types_to_save, sizeof(tinrc.attrib_mime_types_to_save), "%s", BlankIfNull(default_scope->attribute->mime_types_to_save));
 3324             break;
 3325         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 3326             FreeAndNull(curr_scope->attribute->news_headers_to_display);
 3327             build_news_headers_array(curr_scope->attribute, TRUE);
 3328             curr_scope->state->news_headers_to_display = FALSE;
 3329             snprintf(tinrc.attrib_news_headers_to_display, sizeof(tinrc.attrib_news_headers_to_display), "%s", BlankIfNull(default_scope->attribute->news_headers_to_display));
 3330             break;
 3331         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 3332             FreeAndNull(curr_scope->attribute->news_headers_to_not_display);
 3333             build_news_headers_array(curr_scope->attribute, FALSE);
 3334             curr_scope->state->news_headers_to_not_display = FALSE;
 3335             snprintf(tinrc.attrib_news_headers_to_not_display, sizeof(tinrc.attrib_news_headers_to_not_display), "%s", BlankIfNull(default_scope->attribute->news_headers_to_not_display));
 3336             break;
 3337         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 3338             FreeAndNull(curr_scope->attribute->quick_kill_scope);
 3339             curr_scope->state->quick_kill_scope = FALSE;
 3340             snprintf(tinrc.attrib_quick_kill_scope, sizeof(tinrc.attrib_quick_kill_scope), "%s", BlankIfNull(default_scope->attribute->quick_kill_scope));
 3341             break;
 3342         case OPT_ATTRIB_QUICK_KILL_HEADER:
 3343             curr_scope->state->quick_kill_header = FALSE;
 3344             tinrc.attrib_quick_kill_header = default_scope->attribute->quick_kill_header;
 3345             break;
 3346         case OPT_ATTRIB_QUICK_KILL_CASE:
 3347             curr_scope->state->quick_kill_case = FALSE;
 3348             tinrc.attrib_quick_kill_case = default_scope->attribute->quick_kill_case;
 3349             break;
 3350         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
 3351             curr_scope->state->quick_kill_expire = FALSE;
 3352             tinrc.attrib_quick_kill_expire = default_scope->attribute->quick_kill_expire;
 3353             break;
 3354         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 3355             FreeAndNull(curr_scope->attribute->quick_select_scope);
 3356             curr_scope->state->quick_select_scope = FALSE;
 3357             snprintf(tinrc.attrib_quick_select_scope, sizeof(tinrc.attrib_quick_select_scope), "%s", BlankIfNull(default_scope->attribute->quick_select_scope));
 3358             break;
 3359         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 3360             curr_scope->state->quick_select_header = FALSE;
 3361             tinrc.attrib_quick_select_header = default_scope->attribute->quick_select_header;
 3362             break;
 3363         case OPT_ATTRIB_QUICK_SELECT_CASE:
 3364             curr_scope->state->quick_select_case = FALSE;
 3365             tinrc.attrib_quick_select_case = default_scope->attribute->quick_select_case;
 3366             break;
 3367         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
 3368             curr_scope->state->quick_select_expire = FALSE;
 3369             tinrc.attrib_quick_select_expire = default_scope->attribute->quick_select_expire;
 3370             break;
 3371         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 3372             FreeAndNull(curr_scope->attribute->news_quote_format);
 3373             curr_scope->state->news_quote_format = FALSE;
 3374             snprintf(tinrc.attrib_news_quote_format, sizeof(tinrc.attrib_news_quote_format), "%s", BlankIfNull(default_scope->attribute->news_quote_format));
 3375             break;
 3376         case OPT_ATTRIB_ORGANIZATION:
 3377             FreeAndNull(curr_scope->attribute->organization);
 3378             curr_scope->state->organization = FALSE;
 3379             snprintf(tinrc.attrib_organization, sizeof(tinrc.attrib_organization), "%s", BlankIfNull(default_scope->attribute->organization));
 3380             break;
 3381         case OPT_ATTRIB_POST_8BIT_HEADER:
 3382             curr_scope->state->post_8bit_header = FALSE;
 3383             tinrc.attrib_post_8bit_header = default_scope->attribute->post_8bit_header;
 3384             break;
 3385         case OPT_ATTRIB_POST_MIME_ENCODING:
 3386             curr_scope->state->post_mime_encoding = FALSE;
 3387             tinrc.attrib_post_mime_encoding = default_scope->attribute->post_mime_encoding;
 3388             break;
 3389         case OPT_ATTRIB_POST_PROCESS_VIEW:
 3390             curr_scope->state->post_process_view = FALSE;
 3391             tinrc.attrib_post_process_view = default_scope->attribute->post_process_view;
 3392             break;
 3393         case OPT_ATTRIB_POS_FIRST_UNREAD:
 3394             curr_scope->state->pos_first_unread = FALSE;
 3395             tinrc.attrib_pos_first_unread = default_scope->attribute->pos_first_unread;
 3396             break;
 3397 #ifndef DISABLE_PRINTING
 3398         case OPT_ATTRIB_PRINT_HEADER:
 3399             curr_scope->state->print_header = FALSE;
 3400             tinrc.attrib_print_header = default_scope->attribute->print_header;
 3401             break;
 3402 #endif /* !DISABLE_PRINTING */
 3403         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
 3404             curr_scope->state->process_only_unread = FALSE;
 3405             tinrc.attrib_process_only_unread = default_scope->attribute->process_only_unread;
 3406             break;
 3407         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
 3408             curr_scope->state->prompt_followupto = FALSE;
 3409             tinrc.attrib_prompt_followupto = default_scope->attribute->prompt_followupto;
 3410             break;
 3411         case OPT_ATTRIB_QUOTE_CHARS:
 3412             FreeAndNull(curr_scope->attribute->quote_chars);
 3413             curr_scope->state->quote_chars = FALSE;
 3414             snprintf(tinrc.attrib_quote_chars, sizeof(tinrc.attrib_quote_chars), "%s", BlankIfNull(default_scope->attribute->quote_chars));
 3415             break;
 3416         case OPT_ATTRIB_SAVEDIR:
 3417             FreeAndNull(curr_scope->attribute->savedir);
 3418             curr_scope->state->savedir = FALSE;
 3419             snprintf(tinrc.attrib_savedir, sizeof(tinrc.attrib_savedir), "%s", BlankIfNull(default_scope->attribute->savedir));
 3420             break;
 3421         case OPT_ATTRIB_SAVEFILE:
 3422             FreeAndNull(curr_scope->attribute->savefile);
 3423             curr_scope->state->savefile = FALSE;
 3424             snprintf(tinrc.attrib_savefile, sizeof(tinrc.attrib_savefile), "%s", BlankIfNull(default_scope->attribute->savefile));
 3425             break;
 3426         case OPT_ATTRIB_SHOW_AUTHOR:
 3427             curr_scope->state->show_author = FALSE;
 3428             tinrc.attrib_show_author = default_scope->attribute->show_author;
 3429             break;
 3430         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
 3431             curr_scope->state->show_only_unread_arts = FALSE;
 3432             tinrc.attrib_show_only_unread_arts = default_scope->attribute->show_only_unread_arts;
 3433             break;
 3434         case OPT_ATTRIB_SHOW_SIGNATURES:
 3435             curr_scope->state->show_signatures = FALSE;
 3436             tinrc.attrib_show_signatures = default_scope->attribute->show_signatures;
 3437             break;
 3438         case OPT_ATTRIB_SIGDASHES:
 3439             curr_scope->state->sigdashes = FALSE;
 3440             tinrc.attrib_sigdashes = default_scope->attribute->sigdashes;
 3441             break;
 3442         case OPT_ATTRIB_SIGFILE:
 3443             FreeAndNull(curr_scope->attribute->sigfile);
 3444             curr_scope->state->sigfile = FALSE;
 3445             snprintf(tinrc.attrib_sigfile, sizeof(tinrc.attrib_sigfile), "%s", BlankIfNull(default_scope->attribute->sigfile));
 3446             break;
 3447         case OPT_ATTRIB_SIGNATURE_REPOST:
 3448             curr_scope->state->signature_repost = FALSE;
 3449             tinrc.attrib_signature_repost = default_scope->attribute->signature_repost;
 3450             break;
 3451         case OPT_ATTRIB_START_EDITOR_OFFSET:
 3452             curr_scope->state->start_editor_offset = FALSE;
 3453             tinrc.attrib_start_editor_offset = default_scope->attribute->start_editor_offset;
 3454             break;
 3455         case OPT_ATTRIB_THREAD_ARTICLES:
 3456             curr_scope->state->thread_articles = FALSE;
 3457             tinrc.attrib_thread_articles = default_scope->attribute->thread_articles;
 3458             break;
 3459         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
 3460             curr_scope->state->thread_catchup_on_exit = FALSE;
 3461             tinrc.attrib_thread_catchup_on_exit = default_scope->attribute->thread_catchup_on_exit;
 3462             break;
 3463         case OPT_ATTRIB_THREAD_FORMAT:
 3464             FreeAndNull(curr_scope->attribute->thread_format);
 3465             curr_scope->state->thread_format = FALSE;
 3466             snprintf(tinrc.attrib_thread_format, sizeof(tinrc.attrib_thread_format), "%s", BlankIfNull(default_scope->attribute->thread_format));
 3467             break;
 3468         case OPT_ATTRIB_THREAD_PERC:
 3469             curr_scope->state->thread_perc = FALSE;
 3470             tinrc.attrib_thread_perc = default_scope->attribute->thread_perc;
 3471             break;
 3472         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 3473             curr_scope->state->trim_article_body = FALSE;
 3474             tinrc.attrib_trim_article_body = default_scope->attribute->trim_article_body;
 3475             break;
 3476         case OPT_ATTRIB_TEX2ISO_CONV:
 3477             curr_scope->state->tex2iso_conv = FALSE;
 3478             tinrc.attrib_tex2iso_conv = default_scope->attribute->tex2iso_conv;
 3479             break;
 3480         case OPT_ATTRIB_SORT_THREADS_TYPE:
 3481             curr_scope->state->sort_threads_type = FALSE;
 3482             tinrc.attrib_sort_threads_type = default_scope->attribute->sort_threads_type;
 3483             break;
 3484 #ifdef CHARSET_CONVERSION
 3485         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 3486             curr_scope->state->mm_network_charset = FALSE;
 3487             tinrc.attrib_mm_network_charset = default_scope->attribute->mm_network_charset;
 3488             break;
 3489         case OPT_ATTRIB_UNDECLARED_CHARSET:
 3490             FreeAndNull(curr_scope->attribute->undeclared_charset);
 3491             curr_scope->state->undeclared_charset = FALSE;
 3492             snprintf(tinrc.attrib_undeclared_charset, sizeof(tinrc.attrib_undeclared_charset), "%s", BlankIfNull(default_scope->attribute->undeclared_charset));
 3493             break;
 3494 #endif /* CHARSET_CONVERSION */
 3495         case OPT_ATTRIB_VERBATIM_HANDLING:
 3496             curr_scope->state->verbatim_handling = FALSE;
 3497             tinrc.attrib_verbatim_handling = default_scope->attribute->verbatim_handling;
 3498             break;
 3499         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
 3500             curr_scope->state->wrap_on_next_unread = FALSE;
 3501             tinrc.attrib_wrap_on_next_unread = default_scope->attribute->wrap_on_next_unread;
 3502             break;
 3503         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 3504             curr_scope->state->sort_article_type = FALSE;
 3505             tinrc.attrib_sort_article_type = default_scope->attribute->sort_article_type;
 3506             break;
 3507         case OPT_ATTRIB_POST_PROCESS_TYPE:
 3508             curr_scope->state->post_process_type = FALSE;
 3509             tinrc.attrib_post_process_type = default_scope->attribute->post_process_type;
 3510             break;
 3511         case OPT_ATTRIB_X_BODY:
 3512             FreeAndNull(curr_scope->attribute->x_body);
 3513             curr_scope->state->x_body = FALSE;
 3514             snprintf(tinrc.attrib_x_body, sizeof(tinrc.attrib_x_body), "%s", BlankIfNull(default_scope->attribute->x_body));
 3515             break;
 3516         case OPT_ATTRIB_X_COMMENT_TO:
 3517             curr_scope->state->x_comment_to = FALSE;
 3518             tinrc.attrib_x_comment_to = default_scope->attribute->x_comment_to;
 3519             break;
 3520         case OPT_ATTRIB_X_HEADERS:
 3521             FreeAndNull(curr_scope->attribute->x_headers);
 3522             curr_scope->state->x_headers = FALSE;
 3523             snprintf(tinrc.attrib_x_headers, sizeof(tinrc.attrib_x_headers), "%s", BlankIfNull(default_scope->attribute->x_headers));
 3524             break;
 3525 
 3526         default:
 3527             break;
 3528     }
 3529 }
 3530 
 3531 
 3532 #define INITIALIZE_STRING_ATTRIBUTE(option) do { \
 3533         if (curr_scope->state->option) \
 3534             snprintf(CAO(tinrc.attrib_, option), sizeof(CAO(tinrc.attrib_, option)), "%s", curr_scope->attribute->option); \
 3535         else \
 3536             snprintf(CAO(tinrc.attrib_, option), sizeof(CAO(tinrc.attrib_, option)), "%s", BlankIfNull(default_scope->attribute->option)); \
 3537     } while (0)
 3538 #define INITIALIZE_NUM_ATTRIBUTE(option) do { \
 3539         if (curr_scope->state->option) \
 3540             CAO(tinrc.attrib_, option) = curr_scope->attribute->option; \
 3541         else \
 3542             CAO(tinrc.attrib_, option) = default_scope->attribute->option; \
 3543     } while (0)
 3544 
 3545 static void
 3546 initialize_attributes(
 3547     void)
 3548 {
 3549     struct t_scope *default_scope = &scopes[0];
 3550 
 3551     INITIALIZE_NUM_ATTRIBUTE(add_posted_to_filter);
 3552     INITIALIZE_NUM_ATTRIBUTE(advertising);
 3553     INITIALIZE_NUM_ATTRIBUTE(alternative_handling);
 3554     INITIALIZE_NUM_ATTRIBUTE(ask_for_metamail);
 3555     INITIALIZE_NUM_ATTRIBUTE(auto_cc_bcc);
 3556     INITIALIZE_NUM_ATTRIBUTE(auto_list_thread);
 3557     INITIALIZE_NUM_ATTRIBUTE(auto_save);
 3558     INITIALIZE_NUM_ATTRIBUTE(auto_select);
 3559     INITIALIZE_NUM_ATTRIBUTE(batch_save);
 3560     INITIALIZE_NUM_ATTRIBUTE(delete_tmp_files);
 3561 #ifdef HAVE_COLOR
 3562     INITIALIZE_NUM_ATTRIBUTE(extquote_handling);
 3563 #endif /* HAVE_COLOR */
 3564     INITIALIZE_NUM_ATTRIBUTE(group_catchup_on_exit);
 3565     INITIALIZE_NUM_ATTRIBUTE(mail_8bit_header);
 3566     INITIALIZE_NUM_ATTRIBUTE(mail_mime_encoding);
 3567     INITIALIZE_NUM_ATTRIBUTE(mark_ignore_tags);
 3568     INITIALIZE_NUM_ATTRIBUTE(mark_saved_read);
 3569     INITIALIZE_NUM_ATTRIBUTE(mime_forward);
 3570     INITIALIZE_NUM_ATTRIBUTE(pos_first_unread);
 3571     INITIALIZE_NUM_ATTRIBUTE(post_8bit_header);
 3572     INITIALIZE_NUM_ATTRIBUTE(post_mime_encoding);
 3573     INITIALIZE_NUM_ATTRIBUTE(post_process_view);
 3574 #ifndef DISABLE_PRINTING
 3575     INITIALIZE_NUM_ATTRIBUTE(print_header);
 3576 #endif /* !DISABLE_PRINTING */
 3577     INITIALIZE_NUM_ATTRIBUTE(process_only_unread);
 3578     INITIALIZE_NUM_ATTRIBUTE(prompt_followupto);
 3579     INITIALIZE_NUM_ATTRIBUTE(quick_kill_header);
 3580     INITIALIZE_NUM_ATTRIBUTE(quick_kill_case);
 3581     INITIALIZE_NUM_ATTRIBUTE(quick_kill_expire);
 3582     INITIALIZE_NUM_ATTRIBUTE(quick_select_header);
 3583     INITIALIZE_NUM_ATTRIBUTE(quick_select_case);
 3584     INITIALIZE_NUM_ATTRIBUTE(quick_select_expire);
 3585     INITIALIZE_NUM_ATTRIBUTE(show_author);
 3586     INITIALIZE_NUM_ATTRIBUTE(show_only_unread_arts);
 3587     INITIALIZE_NUM_ATTRIBUTE(show_signatures);
 3588     INITIALIZE_NUM_ATTRIBUTE(sigdashes);
 3589     INITIALIZE_NUM_ATTRIBUTE(signature_repost);
 3590     INITIALIZE_NUM_ATTRIBUTE(start_editor_offset);
 3591     INITIALIZE_NUM_ATTRIBUTE(thread_articles);
 3592     INITIALIZE_NUM_ATTRIBUTE(thread_catchup_on_exit);
 3593     INITIALIZE_NUM_ATTRIBUTE(thread_perc);
 3594     INITIALIZE_NUM_ATTRIBUTE(trim_article_body);
 3595     INITIALIZE_NUM_ATTRIBUTE(tex2iso_conv);
 3596     INITIALIZE_NUM_ATTRIBUTE(verbatim_handling);
 3597     INITIALIZE_NUM_ATTRIBUTE(wrap_on_next_unread);
 3598     INITIALIZE_NUM_ATTRIBUTE(sort_article_type);
 3599     INITIALIZE_NUM_ATTRIBUTE(sort_threads_type);
 3600     INITIALIZE_NUM_ATTRIBUTE(post_process_type);
 3601     INITIALIZE_NUM_ATTRIBUTE(x_comment_to);
 3602     INITIALIZE_STRING_ATTRIBUTE(date_format);
 3603     INITIALIZE_STRING_ATTRIBUTE(editor_format);
 3604     INITIALIZE_STRING_ATTRIBUTE(fcc);
 3605     INITIALIZE_STRING_ATTRIBUTE(followup_to);
 3606     INITIALIZE_STRING_ATTRIBUTE(from);
 3607     INITIALIZE_STRING_ATTRIBUTE(group_format);
 3608 #ifdef HAVE_ISPELL
 3609     INITIALIZE_STRING_ATTRIBUTE(ispell);
 3610 #endif /* HAVE_ISPELL */
 3611     INITIALIZE_STRING_ATTRIBUTE(maildir);
 3612     INITIALIZE_STRING_ATTRIBUTE(mailing_list);
 3613     INITIALIZE_STRING_ATTRIBUTE(mime_types_to_save);
 3614     INITIALIZE_STRING_ATTRIBUTE(news_headers_to_display);
 3615     INITIALIZE_STRING_ATTRIBUTE(news_headers_to_not_display);
 3616     INITIALIZE_STRING_ATTRIBUTE(news_quote_format);
 3617     INITIALIZE_STRING_ATTRIBUTE(organization);
 3618     INITIALIZE_STRING_ATTRIBUTE(quick_kill_scope);
 3619     INITIALIZE_STRING_ATTRIBUTE(quick_select_scope);
 3620     INITIALIZE_STRING_ATTRIBUTE(quote_chars);
 3621     INITIALIZE_STRING_ATTRIBUTE(savedir);
 3622     INITIALIZE_STRING_ATTRIBUTE(savefile);
 3623     INITIALIZE_STRING_ATTRIBUTE(sigfile);
 3624     INITIALIZE_STRING_ATTRIBUTE(thread_format);
 3625 #ifdef CHARSET_CONVERSION
 3626     INITIALIZE_NUM_ATTRIBUTE(mm_network_charset);
 3627     INITIALIZE_STRING_ATTRIBUTE(undeclared_charset);
 3628 #endif /* CHARSET_CONVERSION */
 3629     INITIALIZE_STRING_ATTRIBUTE(x_body);
 3630     INITIALIZE_STRING_ATTRIBUTE(x_headers);
 3631 }