"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.2/src/options_menu.c" (8 Dec 2017, 105742 Bytes) of package /linux/misc/tin-2.4.2.tar.xz:


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.1_vs_2.4.2.

    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   : 2017-08-13
    7  *  Notes     : Split from config.c
    8  *
    9  * Copyright (c) 2004-2018 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 USE_CANLOCK
 1776                         case OPT_CANCEL_LOCK_ALGO:
 1777 #endif /* USE_CANLOCK */
 1778 #ifdef HAVE_COLOR
 1779                         case OPT_COL_FROM:
 1780                         case OPT_COL_HEAD:
 1781                         case OPT_COL_HELP:
 1782                         case OPT_COL_INVERS_BG:
 1783                         case OPT_COL_INVERS_FG:
 1784                         case OPT_COL_MESSAGE:
 1785                         case OPT_COL_MINIHELP:
 1786                         case OPT_COL_NEWSHEADERS:
 1787                         case OPT_COL_QUOTE:
 1788                         case OPT_COL_QUOTE2:
 1789                         case OPT_COL_QUOTE3:
 1790                         case OPT_COL_EXTQUOTE:
 1791                         case OPT_COL_RESPONSE:
 1792                         case OPT_COL_SIGNATURE:
 1793                         case OPT_COL_SUBJECT:
 1794                         case OPT_COL_TEXT:
 1795                         case OPT_COL_TITLE:
 1796                         case OPT_COL_MARKSTAR:
 1797                         case OPT_COL_MARKDASH:
 1798                         case OPT_COL_MARKSLASH:
 1799                         case OPT_COL_MARKSTROKE:
 1800                         case OPT_COL_URLS:
 1801                         case OPT_COL_VERBATIM:
 1802 #endif /* HAVE_COLOR */
 1803                         case OPT_CONFIRM_CHOICE:
 1804                         case OPT_GOTO_NEXT_UNREAD:
 1805                         case OPT_HIDE_UUE:
 1806                         case OPT_INTERACTIVE_MAILER:
 1807                         case OPT_KILL_LEVEL:
 1808                         case OPT_MAILBOX_FORMAT:
 1809                         case OPT_MONO_MARKDASH:
 1810                         case OPT_MONO_MARKSLASH:
 1811                         case OPT_MONO_MARKSTAR:
 1812                         case OPT_MONO_MARKSTROKE:
 1813 #ifdef HAVE_UNICODE_NORMALIZATION
 1814                         case OPT_NORMALIZATION_FORM:
 1815 #endif /* HAVE_UNICODE_NORMALIZATION */
 1816                         case OPT_QUOTE_STYLE:
 1817                         case OPT_STRIP_BOGUS:
 1818                         case OPT_WILDCARD:
 1819                         case OPT_WORD_H_DISPLAY_MARKS:
 1820 #ifdef USE_HEAPSORT
 1821                         case OPT_SORT_FUNCTION:
 1822 #endif /* USE_HEAPSORT */
 1823                             if (prompt_option_list(option))
 1824                                 changed |= MISC_OPTS;
 1825                             break;
 1826 
 1827 #ifdef HAVE_COLOR
 1828                         case OPT_COL_BACK:
 1829                         case OPT_COL_NORMAL:
 1830                             if (prompt_option_list(option)) {
 1831                                 redraw_screen(option);
 1832                                 changed |= MISC_OPTS;
 1833                             }
 1834                             break;
 1835 #endif /* HAVE_COLOR */
 1836 
 1837                         case OPT_AUTO_CC_BCC:
 1838                             if (prompt_option_list(option))
 1839                                 UPDATE_INT_ATTRIBUTES(auto_cc_bcc);
 1840                             break;
 1841 
 1842                         case OPT_THREAD_ARTICLES:
 1843                             if (prompt_option_list(option)) {
 1844                                 UPDATE_INT_ATTRIBUTES(thread_articles);
 1845                                 changed |= THREAD_ARTS;
 1846                             }
 1847                             break;
 1848 
 1849                         case OPT_SORT_ARTICLE_TYPE:
 1850                             if (prompt_option_list(option)) {
 1851                                 UPDATE_INT_ATTRIBUTES(sort_article_type);
 1852                                 changed |= SORT_OPTS;
 1853                             }
 1854                             break;
 1855 
 1856                         case OPT_SORT_THREADS_TYPE:
 1857                             if (prompt_option_list(option)) {
 1858                                 UPDATE_INT_ATTRIBUTES(sort_threads_type);
 1859                                 changed |= SORT_OPTS;
 1860                             }
 1861                             break;
 1862 
 1863                         case OPT_THREAD_SCORE:
 1864                             if (prompt_option_list(option))
 1865                                 changed |= THREAD_SCORE;
 1866                             break;
 1867 
 1868                         case OPT_TRIM_ARTICLE_BODY:
 1869                             if (prompt_option_list(option))
 1870                                 UPDATE_INT_ATTRIBUTES(trim_article_body);
 1871                             break;
 1872 
 1873                         case OPT_POST_PROCESS_TYPE:
 1874                             if (prompt_option_list(option))
 1875                                 UPDATE_INT_ATTRIBUTES(post_process_type);
 1876                             break;
 1877 
 1878                         case OPT_SHOW_AUTHOR:
 1879                             if (prompt_option_list(option)) {
 1880                                 UPDATE_INT_ATTRIBUTES(show_author);
 1881                                 changed |= SHOW_AUTHOR;
 1882                             }
 1883                             break;
 1884 
 1885                         case OPT_MAIL_MIME_ENCODING:
 1886                             if (prompt_option_list(option)) {
 1887 #ifdef CHARSET_CONVERSION
 1888                                 /*
 1889                                  * check if we have selected a !7bit encoding but a 7bit network charset
 1890                                  * or a !8bit encoding but a 8bit network charset, update encoding if needed
 1891                                  */
 1892                                 is_7bit = FALSE;
 1893                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1894                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1895                                         is_7bit = TRUE;
 1896                                         break;
 1897                                     }
 1898                                 }
 1899                                 if (is_7bit) {
 1900                                     if (tinrc.mail_mime_encoding != MIME_ENCODING_7BIT) {
 1901                                         tinrc.mail_mime_encoding = MIME_ENCODING_7BIT;
 1902                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1903                                     }
 1904                                 } else {
 1905                                     if (tinrc.mail_mime_encoding == MIME_ENCODING_7BIT) {
 1906                                         tinrc.mail_mime_encoding = MIME_ENCODING_QP;
 1907                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1908                                     }
 1909                                 }
 1910 #endif /* CHARSET_CONVERSION */
 1911                                 UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1912                                 /* do not use 8 bit headers if mime encoding is not 8bit */
 1913                                 if (tinrc.mail_mime_encoding != MIME_ENCODING_8BIT) {
 1914                                     tinrc.mail_8bit_header = FALSE;
 1915                                     repaint_option(OPT_MAIL_8BIT_HEADER);
 1916                                     UPDATE_INT_ATTRIBUTES(mail_8bit_header);
 1917                                 }
 1918                             }
 1919                             break;
 1920 
 1921                         case OPT_POST_MIME_ENCODING:
 1922                             if (prompt_option_list(option)) {
 1923 #ifdef CHARSET_CONVERSION
 1924                                 /*
 1925                                  * check if we have selected a !7bit encoding but a 7bit network charset
 1926                                  * or a !8bit encoding but a 8bit network charset, update encoding if needed
 1927                                  */
 1928                                 is_7bit = FALSE;
 1929                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1930                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1931                                         is_7bit = TRUE;
 1932                                         break;
 1933                                     }
 1934                                 }
 1935                                 if (is_7bit) {
 1936                                     if (tinrc.post_mime_encoding != MIME_ENCODING_7BIT) {
 1937                                         tinrc.post_mime_encoding = MIME_ENCODING_7BIT;
 1938                                         repaint_option(OPT_POST_MIME_ENCODING);
 1939                                     }
 1940                                 } else {
 1941                                     if (tinrc.post_mime_encoding == MIME_ENCODING_7BIT) {
 1942                                         tinrc.post_mime_encoding = MIME_ENCODING_8BIT;
 1943                                         repaint_option(OPT_POST_MIME_ENCODING);
 1944                                     }
 1945                                 }
 1946 #endif /* CHARSET_CONVERSION */
 1947                                 UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 1948                                 /* do not use 8 bit headers if mime encoding is not 8bit */
 1949                                 if (tinrc.post_mime_encoding != MIME_ENCODING_8BIT) {
 1950                                     tinrc.post_8bit_header = FALSE;
 1951                                     repaint_option(OPT_POST_8BIT_HEADER);
 1952                                     UPDATE_INT_ATTRIBUTES(post_8bit_header);
 1953                                 }
 1954                             }
 1955                             break;
 1956 
 1957 #ifdef CHARSET_CONVERSION
 1958                         case OPT_MM_NETWORK_CHARSET:
 1959                             if (prompt_option_list(option)) {
 1960                                 /*
 1961                                  * check if we have selected a 7bit charset but a !7bit encoding
 1962                                  * or a 8bit charset but a !8bit encoding, update encoding if needed
 1963                                  *
 1964                                  * if (mail|post)_mime_encoding != 8bit, disable (mail|post)_8bit_header
 1965                                  */
 1966                                 is_7bit = FALSE;
 1967                                 UPDATE_INT_ATTRIBUTES(mm_network_charset);
 1968                                 for (i = 0; txt_mime_7bit_charsets[i] != NULL; i++) {
 1969                                     if (!strcasecmp(txt_mime_charsets[tinrc.mm_network_charset], txt_mime_7bit_charsets[i])) {
 1970                                         is_7bit = TRUE;
 1971                                         break;
 1972                                     }
 1973                                 }
 1974                                 if (is_7bit) {
 1975                                     if (tinrc.mail_mime_encoding != MIME_ENCODING_7BIT) {
 1976                                         tinrc.mail_mime_encoding = MIME_ENCODING_7BIT;
 1977                                         tinrc.mail_8bit_header = FALSE;
 1978                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1979                                         repaint_option(OPT_MAIL_8BIT_HEADER);
 1980                                         UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1981                                         UPDATE_INT_ATTRIBUTES(mail_8bit_header);
 1982                                     }
 1983                                     if (tinrc.post_mime_encoding != MIME_ENCODING_7BIT) {
 1984                                         tinrc.post_mime_encoding = MIME_ENCODING_7BIT;
 1985                                         tinrc.post_8bit_header = FALSE;
 1986                                         repaint_option(OPT_POST_MIME_ENCODING);
 1987                                         repaint_option(OPT_POST_8BIT_HEADER);
 1988                                         UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 1989                                         UPDATE_INT_ATTRIBUTES(post_8bit_header);
 1990                                     }
 1991                                 } else {
 1992                                     if (tinrc.mail_mime_encoding == MIME_ENCODING_7BIT) {
 1993                                         tinrc.mail_mime_encoding = MIME_ENCODING_QP;
 1994                                         repaint_option(OPT_MAIL_MIME_ENCODING);
 1995                                         UPDATE_INT_ATTRIBUTES(mail_mime_encoding);
 1996                                     }
 1997                                     if (tinrc.post_mime_encoding == MIME_ENCODING_7BIT) {
 1998                                         tinrc.post_mime_encoding = MIME_ENCODING_8BIT;
 1999                                         repaint_option(OPT_POST_MIME_ENCODING);
 2000                                         UPDATE_INT_ATTRIBUTES(post_mime_encoding);
 2001                                     }
 2002                                 }
 2003                             }
 2004                             break;
 2005 #endif /* CHARSET_CONVERSION */
 2006 
 2007                         case OPT_ATTRIB_AUTO_CC_BCC:
 2008                             if (prompt_option_list(option))
 2009                                 SET_NUM_ATTRIBUTE(auto_cc_bcc);
 2010                             break;
 2011 
 2012                         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 2013                             if (prompt_option_list(option))
 2014                                 SET_NUM_ATTRIBUTE(mail_mime_encoding);
 2015                             break;
 2016 
 2017 #ifdef CHARSET_CONVERSION
 2018                         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 2019                             if (prompt_option_list(option))
 2020                                 SET_NUM_ATTRIBUTE(mm_network_charset);
 2021                             break;
 2022 #endif /* CHARSET_CONVERSION */
 2023 
 2024                         case OPT_ATTRIB_POST_MIME_ENCODING:
 2025                             if (prompt_option_list(option))
 2026                                 SET_NUM_ATTRIBUTE(post_mime_encoding);
 2027                             break;
 2028 
 2029                         case OPT_ATTRIB_POST_PROCESS_TYPE:
 2030                             if (prompt_option_list(option))
 2031                                 SET_NUM_ATTRIBUTE(post_process_type);
 2032                             break;
 2033 
 2034                         case OPT_ATTRIB_QUICK_KILL_HEADER:
 2035                             if (prompt_option_list(option))
 2036                                 SET_NUM_ATTRIBUTE(quick_kill_header);
 2037                             break;
 2038 
 2039                         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 2040                             if (prompt_option_list(option))
 2041                                 SET_NUM_ATTRIBUTE(quick_select_header);
 2042                             break;
 2043 
 2044                         case OPT_ATTRIB_SHOW_AUTHOR:
 2045                             if (prompt_option_list(option)) {
 2046                                 SET_NUM_ATTRIBUTE(show_author);
 2047                                 changed |= SHOW_AUTHOR;
 2048                             }
 2049                             break;
 2050 
 2051                         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 2052                             if (prompt_option_list(option)) {
 2053                                 SET_NUM_ATTRIBUTE(sort_article_type);
 2054                                 changed |= SORT_OPTS;
 2055                             }
 2056                             break;
 2057 
 2058                         case OPT_ATTRIB_SORT_THREADS_TYPE:
 2059                             if (prompt_option_list(option)) {
 2060                                 SET_NUM_ATTRIBUTE(sort_threads_type);
 2061                                 changed |= SORT_OPTS;
 2062                             }
 2063                             break;
 2064 
 2065                         case OPT_ATTRIB_THREAD_ARTICLES:
 2066                             if (prompt_option_list(option)) {
 2067                                 SET_NUM_ATTRIBUTE(thread_articles);
 2068                                 changed |= THREAD_ARTS;
 2069                             }
 2070                             break;
 2071 
 2072                         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 2073                             if (prompt_option_list(option))
 2074                                 SET_NUM_ATTRIBUTE(trim_article_body);
 2075                             break;
 2076 
 2077                         default:
 2078                             break;
 2079                     } /* switch (option) */
 2080                     break;
 2081 
 2082                 case OPT_STRING:
 2083                     switch (option) {
 2084                         case OPT_INEWS_PROG:
 2085                         case OPT_MAILDIR:
 2086                         case OPT_MAILER_FORMAT:
 2087                         case OPT_MAIL_ADDRESS:
 2088                         case OPT_MAIL_QUOTE_FORMAT:
 2089                         case OPT_METAMAIL_PROG:
 2090                         case OPT_NEWS_QUOTE_FORMAT:
 2091                         case OPT_SAVEDIR:
 2092                         case OPT_SIGFILE:
 2093 #ifndef DISABLE_PRINTING
 2094                         case OPT_PRINTER:
 2095 #endif /* !DISABLE_PRINTING */
 2096                         case OPT_QUOTE_CHARS:
 2097                         case OPT_SPAMTRAP_WARNING_ADDRESSES:
 2098                         case OPT_URL_HANDLER:
 2099                         case OPT_XPOST_QUOTE_FORMAT:
 2100                             if (prompt_option_string(option))
 2101                                 changed |= MISC_OPTS;
 2102                             break;
 2103 
 2104                         case OPT_EDITOR_FORMAT:
 2105                             if (prompt_option_string(option)) {
 2106                                 if (!strlen(tinrc.editor_format))
 2107                                     STRCPY(tinrc.editor_format, TIN_EDITOR_FMT_ON);
 2108                                 changed |= MISC_OPTS;
 2109                             }
 2110                             break;
 2111 
 2112                         case OPT_GROUP_FORMAT:
 2113                             if (prompt_option_string(option)) {
 2114                                 if (!strlen(tinrc.group_format))
 2115                                     STRCPY(tinrc.group_format, DEFAULT_GROUP_FORMAT);
 2116                                 changed |= MISC_OPTS;
 2117                             }
 2118                             break;
 2119 
 2120                         case OPT_ATTRIB_GROUP_FORMAT:
 2121                             if (prompt_option_string(option))
 2122                                 SET_STRING_ATTRIBUTE(group_format);
 2123                             break;
 2124 
 2125 #ifndef CHARSET_CONVERSION
 2126                         case OPT_MM_CHARSET:
 2127                             if (prompt_option_string(option)) {
 2128                                 /*
 2129                                  * No charset conversion available, assume local charset
 2130                                  * to be network charset.
 2131                                  */
 2132                                 STRCPY(tinrc.mm_local_charset, tinrc.mm_charset);
 2133                                 changed |= MISC_OPTS;
 2134                             }
 2135                             break;
 2136 #else
 2137 #   ifdef NO_LOCALE
 2138                         case OPT_MM_LOCAL_CHARSET:
 2139                             if (prompt_option_string(option))
 2140                             /* no locales -> can't guess local charset */
 2141                                 changed |= MISC_OPTS;
 2142                             break;
 2143 
 2144 #   endif /* NO_LOCALE */
 2145 #endif /* !CHARSET_CONVERSION */
 2146 
 2147                         case OPT_NEWS_HEADERS_TO_DISPLAY:
 2148                             if (prompt_option_string(option)) {
 2149                                 build_news_headers_array(scopes[0].attribute, TRUE);
 2150                                 changed |= MISC_OPTS;
 2151                             }
 2152                             break;
 2153 
 2154                         case OPT_NEWS_HEADERS_TO_NOT_DISPLAY:
 2155                             if (prompt_option_string(option)) {
 2156                                 build_news_headers_array(scopes[0].attribute, FALSE);
 2157                                 changed |= MISC_OPTS;
 2158                             }
 2159                             break;
 2160 
 2161                         case OPT_POSTED_ARTICLES_FILE:
 2162                             if (prompt_option_string(option)) {
 2163                                 char buf[PATH_LEN];
 2164 
 2165                                 strfpath(tinrc.posted_articles_file, buf, sizeof(buf), &CURR_GROUP, TRUE);
 2166                                 STRCPY(tinrc.posted_articles_file, buf);
 2167                                 changed |= MISC_OPTS;
 2168                             }
 2169                             break;
 2170 
 2171 #ifdef HAVE_COLOR
 2172                         case OPT_QUOTE_REGEX:
 2173                             if (prompt_option_string(option)) {
 2174                                 FreeIfNeeded(quote_regex.re);
 2175                                 FreeIfNeeded(quote_regex.extra);
 2176                                 if (!strlen(tinrc.quote_regex))
 2177                                     STRCPY(tinrc.quote_regex, DEFAULT_QUOTE_REGEX);
 2178                                 compile_regex(tinrc.quote_regex, &quote_regex, PCRE_CASELESS);
 2179                                 changed |= DISPLAY_OPTS;
 2180                             }
 2181                             break;
 2182 
 2183                         case OPT_QUOTE_REGEX2:
 2184                             if (prompt_option_string(option)) {
 2185                                 FreeIfNeeded(quote_regex2.re);
 2186                                 FreeIfNeeded(quote_regex2.extra);
 2187                                 if (!strlen(tinrc.quote_regex2))
 2188                                     STRCPY(tinrc.quote_regex2, DEFAULT_QUOTE_REGEX2);
 2189                                 compile_regex(tinrc.quote_regex2, &quote_regex2, PCRE_CASELESS);
 2190                                 changed |= DISPLAY_OPTS;
 2191                             }
 2192                             break;
 2193 
 2194                         case OPT_QUOTE_REGEX3:
 2195                             if (prompt_option_string(option)) {
 2196                                 FreeIfNeeded(quote_regex3.re);
 2197                                 FreeIfNeeded(quote_regex3.extra);
 2198                                 if (!strlen(tinrc.quote_regex3))
 2199                                     STRCPY(tinrc.quote_regex3, DEFAULT_QUOTE_REGEX3);
 2200                                 compile_regex(tinrc.quote_regex3, &quote_regex3, PCRE_CASELESS);
 2201                                 changed |= DISPLAY_OPTS;
 2202                             }
 2203                             break;
 2204 
 2205                         case OPT_EXTQUOTE_REGEX:
 2206                             if (prompt_option_string(option)) {
 2207                                 FreeIfNeeded(extquote_regex.re);
 2208                                 FreeIfNeeded(extquote_regex.extra);
 2209                                 if (!strlen(tinrc.extquote_regex))
 2210                                     STRCPY(tinrc.extquote_regex, DEFAULT_EXTQUOTE_REGEX);
 2211                                 compile_regex(tinrc.extquote_regex, &extquote_regex, PCRE_CASELESS);
 2212                                 changed |= DISPLAY_OPTS;
 2213                             }
 2214                             break;
 2215 #endif /* HAVE_COLOR */
 2216 
 2217                         case OPT_SELECT_FORMAT:
 2218                             if (prompt_option_string(option)) {
 2219                                 if (!strlen(tinrc.select_format))
 2220                                     STRCPY(tinrc.select_format, DEFAULT_SELECT_FORMAT);
 2221                                 changed |= MISC_OPTS;
 2222                             }
 2223                             break;
 2224 
 2225                         case OPT_SLASHES_REGEX:
 2226                             if (prompt_option_string(option)) {
 2227                                 FreeIfNeeded(slashes_regex.re);
 2228                                 FreeIfNeeded(slashes_regex.extra);
 2229                                 if (!strlen(tinrc.slashes_regex))
 2230                                     STRCPY(tinrc.slashes_regex, DEFAULT_SLASHES_REGEX);
 2231                                 compile_regex(tinrc.slashes_regex, &slashes_regex, PCRE_CASELESS);
 2232                                 changed |= DISPLAY_OPTS;
 2233                             }
 2234                             break;
 2235 
 2236                         case OPT_STARS_REGEX:
 2237                             if (prompt_option_string(option)) {
 2238                                 FreeIfNeeded(stars_regex.re);
 2239                                 FreeIfNeeded(stars_regex.extra);
 2240                                 if (!strlen(tinrc.stars_regex))
 2241                                     STRCPY(tinrc.stars_regex, DEFAULT_STARS_REGEX);
 2242                                 compile_regex(tinrc.stars_regex, &stars_regex, PCRE_CASELESS);
 2243                                 changed |= DISPLAY_OPTS;
 2244                             }
 2245                             break;
 2246 
 2247                         case OPT_STROKES_REGEX:
 2248                             if (prompt_option_string(option)) {
 2249                                 FreeIfNeeded(strokes_regex.re);
 2250                                 FreeIfNeeded(strokes_regex.extra);
 2251                                 if (!strlen(tinrc.strokes_regex))
 2252                                     STRCPY(tinrc.strokes_regex, DEFAULT_STROKES_REGEX);
 2253                                 compile_regex(tinrc.strokes_regex, &strokes_regex, PCRE_CASELESS);
 2254                                 changed |= DISPLAY_OPTS;
 2255                             }
 2256                             break;
 2257 
 2258                         case OPT_UNDERSCORES_REGEX:
 2259                             if (prompt_option_string(option)) {
 2260                                 FreeIfNeeded(underscores_regex.re);
 2261                                 FreeIfNeeded(underscores_regex.extra);
 2262                                 if (!strlen(tinrc.underscores_regex))
 2263                                     STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
 2264                                 compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
 2265                                 changed |= DISPLAY_OPTS;
 2266                             }
 2267                             break;
 2268 
 2269                         case OPT_STRIP_RE_REGEX:
 2270                             if (prompt_option_string(option)) {
 2271                                 FreeIfNeeded(strip_re_regex.re);
 2272                                 FreeIfNeeded(strip_re_regex.extra);
 2273                                 if (!strlen(tinrc.strip_re_regex))
 2274                                     STRCPY(tinrc.strip_re_regex, DEFAULT_STRIP_RE_REGEX);
 2275                                 compile_regex(tinrc.strip_re_regex, &strip_re_regex, PCRE_ANCHORED);
 2276                                 changed |= MISC_OPTS;
 2277                             }
 2278                             break;
 2279 
 2280                         case OPT_STRIP_WAS_REGEX:
 2281                             if (prompt_option_string(option)) {
 2282                                 FreeIfNeeded(strip_was_regex.re);
 2283                                 FreeIfNeeded(strip_was_regex.extra);
 2284                                 if (!strlen(tinrc.strip_was_regex)) {
 2285 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 2286                                     if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre())
 2287                                         STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 2288                                     else
 2289 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 2290                                         STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 2291                                 }
 2292                                 compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
 2293                                 changed |= MISC_OPTS;
 2294                             }
 2295                             break;
 2296 
 2297                         case OPT_THREAD_FORMAT:
 2298                             if (prompt_option_string(option)) {
 2299                                 if (!strlen(tinrc.thread_format))
 2300                                     STRCPY(tinrc.thread_format, DEFAULT_THREAD_FORMAT);
 2301                                 changed |= MISC_OPTS;
 2302                             }
 2303                             break;
 2304 
 2305                         case OPT_ATTRIB_THREAD_FORMAT:
 2306                             if (prompt_option_string(option))
 2307                                 SET_STRING_ATTRIBUTE(thread_format);
 2308                             break;
 2309 
 2310                         case OPT_VERBATIM_BEGIN_REGEX:
 2311                             if (prompt_option_string(option)) {
 2312                                 FreeIfNeeded(verbatim_begin_regex.re);
 2313                                 FreeIfNeeded(verbatim_begin_regex.extra);
 2314                                 if (!strlen(tinrc.verbatim_begin_regex))
 2315                                     STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
 2316                                 compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
 2317                                 changed |= DISPLAY_OPTS;
 2318                             }
 2319                             break;
 2320 
 2321                         case OPT_VERBATIM_END_REGEX:
 2322                             if (prompt_option_string(option)) {
 2323                                 FreeIfNeeded(verbatim_end_regex.re);
 2324                                 FreeIfNeeded(verbatim_end_regex.extra);
 2325                                 if (!strlen(tinrc.verbatim_end_regex))
 2326                                     STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
 2327                                 compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
 2328                                 changed |= DISPLAY_OPTS;
 2329                             }
 2330                             break;
 2331 
 2332                         case OPT_DATE_FORMAT:
 2333                             if (prompt_option_string(option)) {
 2334                                 if (!strlen(tinrc.date_format))
 2335                                     STRCPY(tinrc.date_format, DEFAULT_DATE_FORMAT);
 2336                                 changed |= MISC_OPTS;
 2337                             }
 2338                             break;
 2339 
 2340                         case OPT_ATTRIB_DATE_FORMAT:
 2341                             if (prompt_option_string(option))
 2342                                 SET_STRING_ATTRIBUTE(date_format);
 2343                             break;
 2344 
 2345                         case OPT_ATTRIB_EDITOR_FORMAT:
 2346                             if (prompt_option_string(option))
 2347                                 SET_STRING_ATTRIBUTE(editor_format);
 2348                             break;
 2349 
 2350                         case OPT_ATTRIB_FCC:
 2351                             if (prompt_option_string(option))
 2352                                 SET_STRING_ATTRIBUTE(fcc);
 2353                             break;
 2354 
 2355                         case OPT_ATTRIB_FOLLOWUP_TO:
 2356                             if (prompt_option_string(option))
 2357                                 SET_STRING_ATTRIBUTE(followup_to);
 2358                             break;
 2359 
 2360                         case OPT_ATTRIB_FROM:
 2361                             if (prompt_option_string(option))
 2362                                 SET_STRING_ATTRIBUTE(from);
 2363                             break;
 2364 
 2365 #ifdef HAVE_ISPELL
 2366                         case OPT_ATTRIB_ISPELL:
 2367                             if (prompt_option_string(option))
 2368                                 SET_STRING_ATTRIBUTE(ispell);
 2369                             break;
 2370 #endif /* HAVE_ISPELL */
 2371 
 2372                         case OPT_ATTRIB_MAILDIR:
 2373                             if (prompt_option_string(option))
 2374                                 SET_STRING_ATTRIBUTE(maildir);
 2375                             break;
 2376 
 2377                         case OPT_ATTRIB_MAILING_LIST:
 2378                             if (prompt_option_string(option))
 2379                                 SET_STRING_ATTRIBUTE(mailing_list);
 2380                             break;
 2381 
 2382                         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 2383                             if (prompt_option_string(option))
 2384                                 SET_STRING_ATTRIBUTE(mime_types_to_save);
 2385                             break;
 2386 
 2387                         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 2388                             if (prompt_option_string(option)) {
 2389                                 SET_STRING_ATTRIBUTE(news_headers_to_display);
 2390                                 build_news_headers_array(curr_scope->attribute, TRUE);
 2391                                 changed |= DISPLAY_OPTS;
 2392                             }
 2393                             break;
 2394 
 2395                         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 2396                             if (prompt_option_string(option)) {
 2397                                 SET_STRING_ATTRIBUTE(news_headers_to_not_display);
 2398                                 build_news_headers_array(curr_scope->attribute, FALSE);
 2399                                 changed |= DISPLAY_OPTS;
 2400                             }
 2401                             break;
 2402 
 2403                         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 2404                             if (prompt_option_string(option))
 2405                                 SET_STRING_ATTRIBUTE(news_quote_format);
 2406                             break;
 2407 
 2408                         case OPT_ATTRIB_ORGANIZATION:
 2409                             if (prompt_option_string(option))
 2410                                 SET_STRING_ATTRIBUTE(organization);
 2411                             break;
 2412 
 2413                         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 2414                             if (prompt_option_string(option))
 2415                                 SET_STRING_ATTRIBUTE(quick_kill_scope);
 2416                             break;
 2417 
 2418                         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 2419                             if (prompt_option_string(option))
 2420                                 SET_STRING_ATTRIBUTE(quick_select_scope);
 2421                             break;
 2422 
 2423                         case OPT_ATTRIB_QUOTE_CHARS:
 2424                             if (prompt_option_string(option))
 2425                                 SET_STRING_ATTRIBUTE(quote_chars);
 2426                             break;
 2427 
 2428                         case OPT_ATTRIB_SAVEDIR:
 2429                             if (prompt_option_string(option))
 2430                                 SET_STRING_ATTRIBUTE(savedir);
 2431                             break;
 2432 
 2433                         case OPT_ATTRIB_SAVEFILE:
 2434                             if (prompt_option_string(option))
 2435                                 SET_STRING_ATTRIBUTE(savefile);
 2436                             break;
 2437 
 2438                         case OPT_ATTRIB_SIGFILE:
 2439                             if (prompt_option_string(option))
 2440                                 SET_STRING_ATTRIBUTE(sigfile);
 2441                             break;
 2442 
 2443 #ifdef CHARSET_CONVERSION
 2444                         case OPT_ATTRIB_UNDECLARED_CHARSET:
 2445                             if (prompt_option_string(option))
 2446                                 SET_STRING_ATTRIBUTE(undeclared_charset);
 2447                             break;
 2448 
 2449 #endif /* CHARSET_CONVERSION */
 2450                         case OPT_ATTRIB_X_BODY:
 2451                             if (prompt_option_string(option))
 2452                                 SET_STRING_ATTRIBUTE(x_body);
 2453                             break;
 2454 
 2455                         case OPT_ATTRIB_X_HEADERS:
 2456                             if (prompt_option_string(option))
 2457                                 SET_STRING_ATTRIBUTE(x_headers);
 2458                             break;
 2459 
 2460                         default:
 2461                             break;
 2462                     } /* switch (option) */
 2463 
 2464                     break;
 2465 
 2466                 case OPT_NUM:
 2467                     switch (option) {
 2468                         case OPT_GETART_LIMIT:
 2469                         case OPT_SCROLL_LINES:
 2470                             if (prompt_option_num(option))
 2471                                 changed |= MISC_OPTS;
 2472                             break;
 2473 
 2474 #if defined(HAVE_ALARM) && defined(SIGALRM)
 2475                         case OPT_NNTP_READ_TIMEOUT_SECS:
 2476                             if (prompt_option_num(option)) {
 2477                                 if (tinrc.nntp_read_timeout_secs < 0)
 2478                                     tinrc.nntp_read_timeout_secs = 0;
 2479                                 changed |= MISC_OPTS;
 2480                             }
 2481                             break;
 2482 #endif /* HAVE_ALARM && SIGALRM */
 2483 
 2484                         case OPT_REREAD_ACTIVE_FILE_SECS:
 2485                             if (prompt_option_num(option)) {
 2486                                 if (tinrc.reread_active_file_secs < 0)
 2487                                     tinrc.reread_active_file_secs = 0;
 2488                                 changed |= MISC_OPTS;
 2489                             }
 2490                             break;
 2491 
 2492                         case OPT_RECENT_TIME:
 2493                             if (prompt_option_num(option)) {
 2494                                 if (tinrc.recent_time < 0)
 2495                                     tinrc.recent_time = 0;
 2496                                 changed |= MISC_OPTS;
 2497                             }
 2498                             break;
 2499 
 2500                         case OPT_FILTER_DAYS:
 2501                             if (prompt_option_num(option)) {
 2502                                 if (tinrc.filter_days <= 0)
 2503                                     tinrc.filter_days = 1;
 2504                                 changed |= MISC_OPTS;
 2505                             }
 2506                             break;
 2507 
 2508                         case OPT_SCORE_LIMIT_KILL:
 2509                         case OPT_SCORE_KILL:
 2510                         case OPT_SCORE_LIMIT_SELECT:
 2511                         case OPT_SCORE_SELECT:
 2512                             if (prompt_option_num(option)) {
 2513                                 check_score_defaults();
 2514                                 redraw_screen(option);
 2515                                 changed |= SCORE_OPTS;
 2516                             }
 2517                             break;
 2518 
 2519                         case OPT_THREAD_PERC:
 2520                             if (prompt_option_num(option)) {
 2521                                 if (tinrc.thread_perc < 0 || tinrc.thread_perc > 100)
 2522                                     tinrc.thread_perc = THREAD_PERC_DEFAULT;
 2523                                 UPDATE_INT_ATTRIBUTES(thread_perc);
 2524                             }
 2525                             break;
 2526 
 2527                         case OPT_WRAP_COLUMN:
 2528                             if (prompt_option_num(option))
 2529                                 changed |= DISPLAY_OPTS;
 2530                             break;
 2531 
 2532                         case OPT_ATTRIB_THREAD_PERC:
 2533                             if (prompt_option_num(option))
 2534                                 SET_NUM_ATTRIBUTE(thread_perc);
 2535                             break;
 2536 
 2537                         default:
 2538                             break;
 2539                     } /* switch (option) */
 2540                     break;
 2541 
 2542                 case OPT_CHAR:
 2543                     switch (option) {
 2544                         /*
 2545                          * TODO: do DASH_TO_SPACE/SPACE_TO_DASH conversion here?
 2546                          */
 2547                         case OPT_ART_MARKED_DELETED:
 2548                         case OPT_ART_MARKED_INRANGE:
 2549                         case OPT_ART_MARKED_RETURN:
 2550                         case OPT_ART_MARKED_SELECTED:
 2551                         case OPT_ART_MARKED_RECENT:
 2552                         case OPT_ART_MARKED_UNREAD:
 2553                         case OPT_ART_MARKED_READ:
 2554                         case OPT_ART_MARKED_KILLED:
 2555                         case OPT_ART_MARKED_READ_SELECTED:
 2556                             if (prompt_option_char(option))
 2557                                 changed |= MISC_OPTS;
 2558                             break;
 2559 
 2560                         default:
 2561                             break;
 2562                     } /* switch (option) */
 2563                     break;
 2564 
 2565                 default:
 2566                     break;
 2567             } /* switch (option_table[option].var_type) */
 2568             change_option = FALSE;
 2569             show_menu_help(txt_select_config_file_option);
 2570             repaint_option(option);
 2571             highlight_option(option);
 2572         } /* if (change_option) */
 2573     } /* forever */
 2574     /* NOTREACHED */
 2575     return;
 2576 }
 2577 
 2578 
 2579 /*
 2580  * scopes and attributes menu
 2581  */
 2582 
 2583 static t_function
 2584 scope_left(
 2585     void)
 2586 {
 2587     return GLOBAL_QUIT;
 2588 }
 2589 
 2590 
 2591 static t_function
 2592 scope_right(
 2593     void)
 2594 {
 2595     return SCOPE_SELECT;
 2596 }
 2597 
 2598 
 2599 static void
 2600 show_scope_page(
 2601     void)
 2602 {
 2603     int i;
 2604 
 2605     signal_context = cScope;
 2606     currmenu = &scopemenu;
 2607     mark_offset = 0;
 2608 
 2609     if (scopemenu.curr < 0)
 2610         scopemenu.curr = 0;
 2611 
 2612     scopemenu.max = num_scope - 1;
 2613 
 2614     ClearScreen();
 2615     set_first_screen_item();
 2616     center_line(0, TRUE, _(txt_scopes_menu));
 2617 
 2618     for (i = scopemenu.first; i < scopemenu.first + NOTESLINES && i < scopemenu.max; ++i)
 2619         build_scope_line(i);
 2620 
 2621     show_mini_help(SCOPE_LEVEL);
 2622 
 2623     if (scopemenu.max <= 0) {
 2624         info_message(_(txt_no_scopes));
 2625         return;
 2626     }
 2627 
 2628     draw_scope_arrow();
 2629 }
 2630 
 2631 
 2632 static void
 2633 scope_page(
 2634     enum context level)
 2635 {
 2636     char key[MAXKEYLEN];
 2637     int i;
 2638     t_bool changed = FALSE;
 2639     t_function func;
 2640     t_menu *oldmenu = NULL;
 2641 
 2642     if (currmenu)
 2643         oldmenu = currmenu;
 2644     scopemenu.curr = 0;
 2645     clear_note_area();
 2646     show_scope_page();
 2647     set_xclick_off();
 2648 
 2649     forever {
 2650         switch ((func = handle_keypad(scope_left, scope_right, NULL, scope_keys))) {
 2651             case GLOBAL_QUIT:
 2652                 if (changed)
 2653                     write_attributes_file(local_attributes_file);
 2654                 clear_note_area();
 2655                 if (oldmenu)
 2656                     currmenu = oldmenu;
 2657                 return;
 2658 
 2659             case DIGIT_1:
 2660             case DIGIT_2:
 2661             case DIGIT_3:
 2662             case DIGIT_4:
 2663             case DIGIT_5:
 2664             case DIGIT_6:
 2665             case DIGIT_7:
 2666             case DIGIT_8:
 2667             case DIGIT_9:
 2668                 if (scopemenu.max)
 2669                     prompt_item_num(func_to_key(func, scope_keys), _(txt_scope_select));
 2670                 break;
 2671 
 2672 #ifndef NO_SHELL_ESCAPE
 2673             case GLOBAL_SHELL_ESCAPE:
 2674                 do_shell_escape();
 2675                 break;
 2676 #endif /* !NO_SHELL_ESCAPE */
 2677 
 2678             case GLOBAL_HELP:
 2679                 show_help_page(SCOPE_LEVEL, _(txt_scopes_menu_com));
 2680                 show_scope_page();
 2681                 break;
 2682 
 2683             case GLOBAL_FIRST_PAGE:
 2684                 top_of_list();
 2685                 break;
 2686 
 2687             case GLOBAL_LAST_PAGE:
 2688                 end_of_list();
 2689                 break;
 2690 
 2691             case GLOBAL_REDRAW_SCREEN:
 2692                 my_retouch();
 2693                 set_xclick_off();
 2694                 show_scope_page();
 2695                 break;
 2696 
 2697             case GLOBAL_LINE_DOWN:
 2698                 move_down();
 2699                 break;
 2700 
 2701             case GLOBAL_LINE_UP:
 2702                 move_up();
 2703                 break;
 2704 
 2705             case GLOBAL_PAGE_DOWN:
 2706                 page_down();
 2707                 break;
 2708 
 2709             case GLOBAL_PAGE_UP:
 2710                 page_up();
 2711                 break;
 2712 
 2713             case GLOBAL_SCROLL_DOWN:
 2714                 scroll_down();
 2715                 break;
 2716 
 2717             case GLOBAL_SCROLL_UP:
 2718                 scroll_up();
 2719                 break;
 2720 
 2721             case GLOBAL_TOGGLE_HELP_DISPLAY:
 2722                 toggle_mini_help(SCOPE_LEVEL);
 2723                 show_scope_page();
 2724                 break;
 2725 
 2726             case SCOPE_ADD:
 2727                 if ((i = add_new_scope())) {
 2728                     changed = TRUE;
 2729                     scopemenu.curr = i;
 2730                     show_scope_page();
 2731                 }
 2732                 break;
 2733 
 2734             case SCOPE_DELETE:
 2735                 if (scopemenu.max) {
 2736                     if (scopes[scopemenu.curr + 1].global)
 2737                         info_message(_(txt_scope_operation_not_allowed));
 2738                     else if (delete_scope(scopemenu.curr + 1)) {
 2739                         changed = TRUE;
 2740                         show_scope_page();
 2741                     }
 2742                 }
 2743                 break;
 2744 
 2745             case SCOPE_EDIT_ATTRIBUTES_FILE:
 2746                 if (changed)
 2747                     write_attributes_file(local_attributes_file);
 2748                 if (!invoke_editor(local_attributes_file, attrib_file_offset, NULL))
 2749                     break;
 2750                 free_scopes_and_attributes();
 2751                 read_attributes_file(FALSE);
 2752                 assign_attributes_to_groups();
 2753                 changed = FALSE;
 2754                 scopemenu.curr = 0;
 2755                 show_scope_page();
 2756                 break;
 2757 
 2758             case SCOPE_MOVE:
 2759                 if (scopemenu.max > 1) {
 2760                     if (scopes[scopemenu.curr + 1].global)
 2761                         info_message(_(txt_scope_operation_not_allowed));
 2762                     else if ((i = move_scope(scopemenu.curr + 1))) {
 2763                         changed = TRUE;
 2764                         scopemenu.curr = i - 1;
 2765                         show_scope_page();
 2766                     }
 2767                 }
 2768                 break;
 2769 
 2770             case SCOPE_RENAME:
 2771                 if (scopemenu.max) {
 2772                     if (scopes[scopemenu.curr + 1].global)
 2773                         info_message(_(txt_scope_operation_not_allowed));
 2774                     else if (rename_scope(&scopes[scopemenu.curr + 1])) {
 2775                         changed = TRUE;
 2776                         show_scope_page();
 2777                     }
 2778                 }
 2779                 break;
 2780 
 2781             case SCOPE_SELECT:
 2782                 if (scopemenu.max) {
 2783                     curr_scope = &scopes[scopemenu.curr + 1];
 2784                     config_page(NULL, level);
 2785                     if (!curr_scope->global && scope_is_empty())
 2786                         do_delete_scope(scopemenu.curr + 1);
 2787                     curr_scope = NULL;
 2788                     changed = TRUE;
 2789                     show_scope_page();
 2790                 }
 2791                 break;
 2792 
 2793             default:
 2794                 info_message(_(txt_bad_command), printascii(key, func_to_key(GLOBAL_HELP, scope_keys)));
 2795                 break;
 2796         }
 2797     }
 2798 }
 2799 
 2800 
 2801 static void
 2802 draw_scope_arrow(
 2803     void)
 2804 {
 2805     draw_arrow_mark(INDEX_TOP + scopemenu.curr - scopemenu.first);
 2806     if (scopemenu.curr == scopemenu.max - 1)
 2807         info_message(_(txt_end_of_scopes));
 2808 }
 2809 
 2810 
 2811 static void
 2812 build_scope_line(
 2813     int i)
 2814 {
 2815     char *sptr;
 2816     int len = cCOLS - 11;
 2817 
 2818 #ifdef USE_CURSES
 2819     /*
 2820      * Allocate line buffer
 2821      * make it the same size like in !USE_CURSES case to simplify some code
 2822      */
 2823     sptr = my_malloc(cCOLS + 2);
 2824 #else
 2825     sptr = screen[INDEX2SNUM(i)].col;
 2826 #endif /* USE_CURSES */
 2827 
 2828     snprintf(sptr, cCOLS, "  %c %s  %-*.*s%s", (scopes[i + 1].global ? '!' : ' '), tin_ltoa(i + 1, 4), len, len, scopes[i + 1].scope, cCRLF);
 2829 
 2830 #ifndef USE_CURSES
 2831     if (tinrc.strip_blanks)
 2832         strcat(strip_line(sptr), cCRLF);
 2833 #endif /* !USE_CURSES */
 2834 
 2835     WriteLine(INDEX2LNUM(i), sptr);
 2836 
 2837 #ifdef USE_CURSES
 2838     free(sptr);
 2839 #endif /* USE_CURSES */
 2840 }
 2841 
 2842 
 2843 /*
 2844  * add a new scope and return the index
 2845  */
 2846 static int
 2847 add_new_scope(
 2848     void)
 2849 {
 2850     char buf[LEN];
 2851     int new_pos = 0;
 2852 
 2853     if (prompt_default_string(_(txt_scope_enter), buf, sizeof(buf), (char *) NULL, HIST_OTHER))
 2854         new_pos = add_scope(buf);
 2855 
 2856     return new_pos;
 2857 }
 2858 
 2859 
 2860 /*
 2861  * returns TRUE if the given scope was deleted
 2862  */
 2863 static t_bool
 2864 delete_scope(
 2865     int curr_pos)
 2866 {
 2867     if (prompt_yn(_(txt_scope_delete), FALSE) == 1) {
 2868         do_delete_scope(curr_pos);
 2869         return TRUE;
 2870     }
 2871 
 2872     return FALSE;
 2873 }
 2874 
 2875 
 2876 static void
 2877 do_delete_scope(
 2878     int curr_pos)
 2879 {
 2880     do_move_scope(curr_pos, num_scope - 1);
 2881     free_scope(--num_scope);
 2882 }
 2883 
 2884 
 2885 /*
 2886  * returns TRUE if scope was renamed
 2887  */
 2888 static t_bool
 2889 rename_scope(
 2890     struct t_scope *scope)
 2891 {
 2892     char buf[LEN];
 2893 
 2894     if (prompt_default_string(_(txt_scope_rename), buf, sizeof(buf), scope->scope, HIST_OTHER)) {
 2895         if (buf[0] == '\0')
 2896             return FALSE;
 2897         FreeIfNeeded(scope->scope);
 2898         scope->scope = my_strdup(buf);
 2899         return TRUE;
 2900     }
 2901 
 2902     return FALSE;
 2903 }
 2904 
 2905 
 2906 /*
 2907  * look if an entry with the given scope exists and return the index
 2908  */
 2909 static int
 2910 find_scope(
 2911     const char *scope)
 2912 {
 2913     int i;
 2914 
 2915     if (!scope || !*scope)
 2916         return 0;
 2917 
 2918     for (i = 1; i < num_scope; i++) {
 2919         if ((!scopes[i].global && strcasecmp(scope, scopes[i].scope) == 0))
 2920             return i;
 2921     }
 2922 
 2923     return 0;
 2924 }
 2925 
 2926 
 2927 /*
 2928  * returns the new position of the moved scope or 0 if repositioning
 2929  * is not possible
 2930  */
 2931 static int
 2932 move_scope(
 2933     int curr_pos)
 2934 {
 2935     char *p;
 2936     int new_pos;
 2937 
 2938     clear_message();
 2939     if ((p = tin_getline(_(txt_scope_new_position), 1, 0, 0, FALSE, HIST_OTHER)) != NULL)
 2940         new_pos = atoi(p);
 2941     else
 2942         new_pos = curr_pos;
 2943     clear_message();
 2944 
 2945     if (new_pos == curr_pos || new_pos == 0)
 2946         return 0;
 2947 
 2948     if (new_pos >= num_scope)
 2949         new_pos = num_scope - 1;
 2950 
 2951     if (scopes[new_pos].global) {
 2952         info_message(_(txt_scope_new_position_is_global));
 2953         return 0;
 2954     }
 2955 
 2956     do_move_scope(curr_pos, new_pos);
 2957 
 2958     return new_pos;
 2959 }
 2960 
 2961 
 2962 /*
 2963  * repositions a scope into scopes[]
 2964  */
 2965 static void
 2966 do_move_scope(
 2967     int from,
 2968     int to)
 2969 {
 2970     struct t_scope tmp;
 2971 
 2972     if (from == to)
 2973         return;
 2974 
 2975     tmp = scopes[from];
 2976 
 2977     if (from > to) {
 2978         while (from-- > to)
 2979             scopes[from + 1] = scopes[from];
 2980     } else {
 2981         while (from++ < to)
 2982             scopes[from - 1] = scopes[from];
 2983     }
 2984     scopes[to] = tmp;
 2985 }
 2986 
 2987 
 2988 /*
 2989  * free all group->attribute arrays and all scopes which are
 2990  * not marked as global
 2991  */
 2992 static void
 2993 free_scopes_and_attributes(
 2994     void)
 2995 {
 2996     int i;
 2997 
 2998     for_each_group(i) {
 2999         if (active[i].attribute && !active[i].attribute->global) {
 3000             free(active[i].attribute);
 3001             active[i].attribute = (struct t_attribute *) 0;
 3002         }
 3003     }
 3004 
 3005     while (num_scope > 1 && !scopes[num_scope - 1].global)
 3006             free_scope(--num_scope);
 3007 }
 3008 
 3009 
 3010 /*
 3011  * returns TRUE if no attribute in curr_scope has state == TRUE
 3012  */
 3013 static t_bool
 3014 scope_is_empty(
 3015     void)
 3016 {
 3017     enum option_enum i;
 3018 
 3019     for (i = 0; i <= last_opt; i++) {
 3020         if (option_is_visible(i) && !option_is_title(i) && check_state(i))
 3021             return FALSE;
 3022     }
 3023 
 3024     return TRUE;
 3025 }
 3026 
 3027 
 3028 /*
 3029  * returns the state of the given attribute
 3030  */
 3031 static t_bool
 3032 check_state(
 3033     enum option_enum option)
 3034 {
 3035     switch (option) {
 3036         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
 3037             return curr_scope->state->add_posted_to_filter;
 3038         case OPT_ATTRIB_ADVERTISING:
 3039             return curr_scope->state->advertising;
 3040         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
 3041             return curr_scope->state->alternative_handling;
 3042         case OPT_ATTRIB_ASK_FOR_METAMAIL:
 3043             return curr_scope->state->ask_for_metamail;
 3044         case OPT_ATTRIB_AUTO_CC_BCC:
 3045             return curr_scope->state->auto_cc_bcc;
 3046         case OPT_ATTRIB_AUTO_LIST_THREAD:
 3047             return curr_scope->state->auto_list_thread;
 3048         case OPT_ATTRIB_AUTO_SAVE:
 3049             return curr_scope->state->auto_save;
 3050         case OPT_ATTRIB_AUTO_SELECT:
 3051             return curr_scope->state->auto_select;
 3052         case OPT_ATTRIB_BATCH_SAVE:
 3053             return curr_scope->state->batch_save;
 3054         case OPT_ATTRIB_DATE_FORMAT:
 3055             return curr_scope->state->date_format;
 3056         case OPT_ATTRIB_DELETE_TMP_FILES:
 3057             return curr_scope->state->delete_tmp_files;
 3058         case OPT_ATTRIB_EDITOR_FORMAT:
 3059             return curr_scope->state->editor_format;
 3060 #ifdef HAVE_COLOR
 3061         case OPT_ATTRIB_EXTQUOTE_HANDLING:
 3062             return curr_scope->state->extquote_handling;
 3063 #endif /* HAVE_COLOR */
 3064         case OPT_ATTRIB_FCC:
 3065             return curr_scope->state->fcc;
 3066         case OPT_ATTRIB_FOLLOWUP_TO:
 3067             return curr_scope->state->followup_to;
 3068         case OPT_ATTRIB_FROM:
 3069             return curr_scope->state->from;
 3070         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
 3071             return curr_scope->state->group_catchup_on_exit;
 3072         case OPT_ATTRIB_GROUP_FORMAT:
 3073             return curr_scope->state->group_format;
 3074 #ifdef HAVE_ISPELL
 3075         case OPT_ATTRIB_ISPELL:
 3076             return curr_scope->state->ispell;
 3077 #endif /* HAVE_ISPELL */
 3078         case OPT_ATTRIB_MAILDIR:
 3079             return curr_scope->state->maildir;
 3080         case OPT_ATTRIB_MAIL_8BIT_HEADER:
 3081             return curr_scope->state->mail_8bit_header;
 3082         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 3083             return curr_scope->state->mail_mime_encoding;
 3084         case OPT_ATTRIB_MAILING_LIST:
 3085             return curr_scope->state->mailing_list;
 3086         case OPT_ATTRIB_MARK_IGNORE_TAGS:
 3087             return curr_scope->state->mark_ignore_tags;
 3088         case OPT_ATTRIB_MARK_SAVED_READ:
 3089             return curr_scope->state->mark_saved_read;
 3090         case OPT_ATTRIB_MIME_FORWARD:
 3091             return curr_scope->state->mime_forward;
 3092         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 3093             return curr_scope->state->mime_types_to_save;
 3094         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 3095             return curr_scope->state->news_headers_to_display;
 3096         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 3097             return curr_scope->state->news_headers_to_not_display;
 3098         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 3099             return curr_scope->state->news_quote_format;
 3100         case OPT_ATTRIB_ORGANIZATION:
 3101             return curr_scope->state->organization;
 3102         case OPT_ATTRIB_POST_8BIT_HEADER:
 3103             return curr_scope->state->post_8bit_header;
 3104         case OPT_ATTRIB_POST_MIME_ENCODING:
 3105             return curr_scope->state->post_mime_encoding;
 3106         case OPT_ATTRIB_POST_PROCESS_VIEW:
 3107             return curr_scope->state->post_process_view;
 3108         case OPT_ATTRIB_POS_FIRST_UNREAD:
 3109             return curr_scope->state->pos_first_unread;
 3110 #ifndef DISABLE_PRINTING
 3111         case OPT_ATTRIB_PRINT_HEADER:
 3112             return curr_scope->state->print_header;
 3113 #endif /* !DISABLE_PRINTING */
 3114         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
 3115             return curr_scope->state->process_only_unread;
 3116         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
 3117             return curr_scope->state->prompt_followupto;
 3118         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 3119             return curr_scope->state->quick_kill_scope;
 3120         case OPT_ATTRIB_QUICK_KILL_HEADER:
 3121             return curr_scope->state->quick_kill_header;
 3122         case OPT_ATTRIB_QUICK_KILL_CASE:
 3123             return curr_scope->state->quick_kill_case;
 3124         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
 3125             return curr_scope->state->quick_kill_expire;
 3126         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 3127             return curr_scope->state->quick_select_scope;
 3128         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 3129             return curr_scope->state->quick_select_header;
 3130         case OPT_ATTRIB_QUICK_SELECT_CASE:
 3131             return curr_scope->state->quick_select_case;
 3132         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
 3133             return curr_scope->state->quick_select_expire;
 3134         case OPT_ATTRIB_QUOTE_CHARS:
 3135             return curr_scope->state->quote_chars;
 3136         case OPT_ATTRIB_SAVEDIR:
 3137             return curr_scope->state->savedir;
 3138         case OPT_ATTRIB_SAVEFILE:
 3139             return curr_scope->state->savefile;
 3140         case OPT_ATTRIB_SHOW_AUTHOR:
 3141             return curr_scope->state->show_author;
 3142         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
 3143             return curr_scope->state->show_only_unread_arts;
 3144         case OPT_ATTRIB_SHOW_SIGNATURES:
 3145             return curr_scope->state->show_signatures;
 3146         case OPT_ATTRIB_SIGDASHES:
 3147             return curr_scope->state->sigdashes;
 3148         case OPT_ATTRIB_SIGFILE:
 3149             return curr_scope->state->sigfile;
 3150         case OPT_ATTRIB_SIGNATURE_REPOST:
 3151             return curr_scope->state->signature_repost;
 3152         case OPT_ATTRIB_START_EDITOR_OFFSET:
 3153             return curr_scope->state->start_editor_offset;
 3154         case OPT_ATTRIB_THREAD_ARTICLES:
 3155             return curr_scope->state->thread_articles;
 3156         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
 3157             return curr_scope->state->thread_catchup_on_exit;
 3158         case OPT_ATTRIB_THREAD_FORMAT:
 3159             return curr_scope->state->thread_format;
 3160         case OPT_ATTRIB_THREAD_PERC:
 3161             return curr_scope->state->thread_perc;
 3162         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 3163             return curr_scope->state->trim_article_body;
 3164         case OPT_ATTRIB_TEX2ISO_CONV:
 3165             return curr_scope->state->tex2iso_conv;
 3166         case OPT_ATTRIB_SORT_THREADS_TYPE:
 3167             return curr_scope->state->sort_threads_type;
 3168 #ifdef CHARSET_CONVERSION
 3169         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 3170             return curr_scope->state->mm_network_charset;
 3171         case OPT_ATTRIB_UNDECLARED_CHARSET:
 3172             return curr_scope->state->undeclared_charset;
 3173 #endif /* CHARSET_CONVERSION */
 3174         case OPT_ATTRIB_VERBATIM_HANDLING:
 3175             return curr_scope->state->verbatim_handling;
 3176         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
 3177             return curr_scope->state->wrap_on_next_unread;
 3178         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 3179             return curr_scope->state->sort_article_type;
 3180         case OPT_ATTRIB_POST_PROCESS_TYPE:
 3181             return curr_scope->state->post_process_type;
 3182         case OPT_ATTRIB_X_BODY:
 3183             return curr_scope->state->x_body;
 3184         case OPT_ATTRIB_X_COMMENT_TO:
 3185             return curr_scope->state->x_comment_to;
 3186         case OPT_ATTRIB_X_HEADERS:
 3187             return curr_scope->state->x_headers;
 3188 
 3189         default:
 3190             return FALSE;
 3191     }
 3192 }
 3193 
 3194 
 3195 /*
 3196  * set the state of the given attribute to FALSE and the corresponding
 3197  * tinrc.attrib_* to a default value
 3198  */
 3199 static void
 3200 reset_state(
 3201     enum option_enum option)
 3202 {
 3203     struct t_scope *default_scope = &scopes[0];
 3204 
 3205     switch (option) {
 3206         case OPT_ATTRIB_ADD_POSTED_TO_FILTER:
 3207             curr_scope->state->add_posted_to_filter = FALSE;
 3208             tinrc.attrib_add_posted_to_filter = default_scope->attribute->add_posted_to_filter;
 3209             break;
 3210         case OPT_ATTRIB_ADVERTISING:
 3211             curr_scope->state->advertising = FALSE;
 3212             tinrc.attrib_advertising = default_scope->attribute->advertising;
 3213             break;
 3214         case OPT_ATTRIB_ALTERNATIVE_HANDLING:
 3215             curr_scope->state->alternative_handling = FALSE;
 3216             tinrc.attrib_alternative_handling = default_scope->attribute->alternative_handling;
 3217             break;
 3218         case OPT_ATTRIB_ASK_FOR_METAMAIL:
 3219             curr_scope->state->ask_for_metamail = FALSE;
 3220             tinrc.attrib_ask_for_metamail = default_scope->attribute->ask_for_metamail;
 3221             break;
 3222         case OPT_ATTRIB_AUTO_CC_BCC:
 3223             curr_scope->state->auto_cc_bcc = FALSE;
 3224             tinrc.attrib_auto_cc_bcc = default_scope->attribute->auto_cc_bcc;
 3225             break;
 3226         case OPT_ATTRIB_AUTO_LIST_THREAD:
 3227             curr_scope->state->auto_list_thread = FALSE;
 3228             tinrc.attrib_auto_list_thread = default_scope->attribute->auto_list_thread;
 3229             break;
 3230         case OPT_ATTRIB_AUTO_SAVE:
 3231             curr_scope->state->auto_save = FALSE;
 3232             tinrc.attrib_auto_save = default_scope->attribute->auto_save;
 3233             break;
 3234         case OPT_ATTRIB_AUTO_SELECT:
 3235             curr_scope->state->auto_select = FALSE;
 3236             tinrc.attrib_auto_select = default_scope->attribute->auto_select;
 3237             break;
 3238         case OPT_ATTRIB_BATCH_SAVE:
 3239             curr_scope->state->batch_save = FALSE;
 3240             tinrc.attrib_batch_save = default_scope->attribute->batch_save;
 3241             break;
 3242         case OPT_ATTRIB_DATE_FORMAT:
 3243             FreeAndNull(curr_scope->attribute->date_format);
 3244             curr_scope->state->date_format = FALSE;
 3245             snprintf(tinrc.attrib_date_format, sizeof(tinrc.attrib_date_format), "%s", BlankIfNull(default_scope->attribute->date_format));
 3246             break;
 3247         case OPT_ATTRIB_DELETE_TMP_FILES:
 3248             curr_scope->state->delete_tmp_files = FALSE;
 3249             tinrc.attrib_delete_tmp_files = default_scope->attribute->delete_tmp_files;
 3250             break;
 3251         case OPT_ATTRIB_EDITOR_FORMAT:
 3252             FreeAndNull(curr_scope->attribute->editor_format);
 3253             curr_scope->state->editor_format = FALSE;
 3254             snprintf(tinrc.attrib_editor_format, sizeof(tinrc.attrib_editor_format), "%s", BlankIfNull(default_scope->attribute->editor_format));
 3255             break;
 3256 #ifdef HAVE_COLOR
 3257         case OPT_ATTRIB_EXTQUOTE_HANDLING:
 3258             curr_scope->state->extquote_handling = FALSE;
 3259             tinrc.attrib_extquote_handling = default_scope->attribute->extquote_handling;
 3260             break;
 3261 #endif /* HAVE_COLOR */
 3262         case OPT_ATTRIB_FCC:
 3263             FreeAndNull(curr_scope->attribute->fcc);
 3264             curr_scope->state->fcc = FALSE;
 3265             snprintf(tinrc.attrib_fcc, sizeof(tinrc.attrib_fcc), "%s", BlankIfNull(default_scope->attribute->fcc));
 3266             break;
 3267         case OPT_ATTRIB_FOLLOWUP_TO:
 3268             FreeAndNull(curr_scope->attribute->followup_to);
 3269             curr_scope->state->followup_to = FALSE;
 3270             snprintf(tinrc.attrib_followup_to, sizeof(tinrc.attrib_followup_to), "%s", BlankIfNull(default_scope->attribute->followup_to));
 3271             break;
 3272         case OPT_ATTRIB_FROM:
 3273             FreeAndNull(curr_scope->attribute->from);
 3274             curr_scope->state->from = FALSE;
 3275             snprintf(tinrc.attrib_from, sizeof(tinrc.attrib_from), "%s", BlankIfNull(default_scope->attribute->from));
 3276             break;
 3277         case OPT_ATTRIB_GROUP_CATCHUP_ON_EXIT:
 3278             curr_scope->state->group_catchup_on_exit = FALSE;
 3279             tinrc.attrib_group_catchup_on_exit = default_scope->attribute->group_catchup_on_exit;
 3280             break;
 3281         case OPT_ATTRIB_GROUP_FORMAT:
 3282             FreeAndNull(curr_scope->attribute->group_format);
 3283             curr_scope->state->group_format = FALSE;
 3284             snprintf(tinrc.attrib_group_format, sizeof(tinrc.attrib_group_format), "%s", BlankIfNull(default_scope->attribute->group_format));
 3285             break;
 3286 #ifdef HAVE_ISPELL
 3287         case OPT_ATTRIB_ISPELL:
 3288             FreeAndNull(curr_scope->attribute->ispell);
 3289             curr_scope->state->ispell = FALSE;
 3290             snprintf(tinrc.attrib_ispell, sizeof(tinrc.attrib_ispell), "%s", BlankIfNull(default_scope->attribute->ispell));
 3291             break;
 3292 #endif /* HAVE_ISPELL */
 3293         case OPT_ATTRIB_MAILDIR:
 3294             FreeAndNull(curr_scope->attribute->maildir);
 3295             curr_scope->state->maildir = FALSE;
 3296             snprintf(tinrc.attrib_maildir, sizeof(tinrc.attrib_maildir), "%s", BlankIfNull(default_scope->attribute->maildir));
 3297             break;
 3298         case OPT_ATTRIB_MAIL_8BIT_HEADER:
 3299             curr_scope->state->mail_8bit_header = FALSE;
 3300             tinrc.attrib_mail_8bit_header = default_scope->attribute->mail_8bit_header;
 3301             break;
 3302         case OPT_ATTRIB_MAIL_MIME_ENCODING:
 3303             curr_scope->state->mail_mime_encoding = FALSE;
 3304             tinrc.attrib_mail_mime_encoding = default_scope->attribute->mail_mime_encoding;
 3305             break;
 3306         case OPT_ATTRIB_MAILING_LIST:
 3307             FreeAndNull(curr_scope->attribute->mailing_list);
 3308             curr_scope->state->mailing_list = FALSE;
 3309             snprintf(tinrc.attrib_mailing_list, sizeof(tinrc.attrib_mailing_list), "%s", BlankIfNull(default_scope->attribute->mailing_list));
 3310             break;
 3311         case OPT_ATTRIB_MARK_IGNORE_TAGS:
 3312             curr_scope->state->mark_ignore_tags = FALSE;
 3313             tinrc.attrib_mark_ignore_tags = default_scope->attribute->mark_ignore_tags;
 3314             break;
 3315         case OPT_ATTRIB_MARK_SAVED_READ:
 3316             curr_scope->state->mark_saved_read = FALSE;
 3317             tinrc.attrib_mark_saved_read = default_scope->attribute->mark_saved_read;
 3318             break;
 3319         case OPT_ATTRIB_MIME_FORWARD:
 3320             curr_scope->state->mime_forward = FALSE;
 3321             tinrc.attrib_mime_forward = default_scope->attribute->mime_forward;
 3322             break;
 3323         case OPT_ATTRIB_MIME_TYPES_TO_SAVE:
 3324             FreeAndNull(curr_scope->attribute->mime_types_to_save);
 3325             curr_scope->state->mime_types_to_save = FALSE;
 3326             snprintf(tinrc.attrib_mime_types_to_save, sizeof(tinrc.attrib_mime_types_to_save), "%s", BlankIfNull(default_scope->attribute->mime_types_to_save));
 3327             break;
 3328         case OPT_ATTRIB_NEWS_HEADERS_TO_DISPLAY:
 3329             FreeAndNull(curr_scope->attribute->news_headers_to_display);
 3330             build_news_headers_array(curr_scope->attribute, TRUE);
 3331             curr_scope->state->news_headers_to_display = FALSE;
 3332             snprintf(tinrc.attrib_news_headers_to_display, sizeof(tinrc.attrib_news_headers_to_display), "%s", BlankIfNull(default_scope->attribute->news_headers_to_display));
 3333             break;
 3334         case OPT_ATTRIB_NEWS_HEADERS_TO_NOT_DISPLAY:
 3335             FreeAndNull(curr_scope->attribute->news_headers_to_not_display);
 3336             build_news_headers_array(curr_scope->attribute, FALSE);
 3337             curr_scope->state->news_headers_to_not_display = FALSE;
 3338             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));
 3339             break;
 3340         case OPT_ATTRIB_QUICK_KILL_SCOPE:
 3341             FreeAndNull(curr_scope->attribute->quick_kill_scope);
 3342             curr_scope->state->quick_kill_scope = FALSE;
 3343             snprintf(tinrc.attrib_quick_kill_scope, sizeof(tinrc.attrib_quick_kill_scope), "%s", BlankIfNull(default_scope->attribute->quick_kill_scope));
 3344             break;
 3345         case OPT_ATTRIB_QUICK_KILL_HEADER:
 3346             curr_scope->state->quick_kill_header = FALSE;
 3347             tinrc.attrib_quick_kill_header = default_scope->attribute->quick_kill_header;
 3348             break;
 3349         case OPT_ATTRIB_QUICK_KILL_CASE:
 3350             curr_scope->state->quick_kill_case = FALSE;
 3351             tinrc.attrib_quick_kill_case = default_scope->attribute->quick_kill_case;
 3352             break;
 3353         case OPT_ATTRIB_QUICK_KILL_EXPIRE:
 3354             curr_scope->state->quick_kill_expire = FALSE;
 3355             tinrc.attrib_quick_kill_expire = default_scope->attribute->quick_kill_expire;
 3356             break;
 3357         case OPT_ATTRIB_QUICK_SELECT_SCOPE:
 3358             FreeAndNull(curr_scope->attribute->quick_select_scope);
 3359             curr_scope->state->quick_select_scope = FALSE;
 3360             snprintf(tinrc.attrib_quick_select_scope, sizeof(tinrc.attrib_quick_select_scope), "%s", BlankIfNull(default_scope->attribute->quick_select_scope));
 3361             break;
 3362         case OPT_ATTRIB_QUICK_SELECT_HEADER:
 3363             curr_scope->state->quick_select_header = FALSE;
 3364             tinrc.attrib_quick_select_header = default_scope->attribute->quick_select_header;
 3365             break;
 3366         case OPT_ATTRIB_QUICK_SELECT_CASE:
 3367             curr_scope->state->quick_select_case = FALSE;
 3368             tinrc.attrib_quick_select_case = default_scope->attribute->quick_select_case;
 3369             break;
 3370         case OPT_ATTRIB_QUICK_SELECT_EXPIRE:
 3371             curr_scope->state->quick_select_expire = FALSE;
 3372             tinrc.attrib_quick_select_expire = default_scope->attribute->quick_select_expire;
 3373             break;
 3374         case OPT_ATTRIB_NEWS_QUOTE_FORMAT:
 3375             FreeAndNull(curr_scope->attribute->news_quote_format);
 3376             curr_scope->state->news_quote_format = FALSE;
 3377             snprintf(tinrc.attrib_news_quote_format, sizeof(tinrc.attrib_news_quote_format), "%s", BlankIfNull(default_scope->attribute->news_quote_format));
 3378             break;
 3379         case OPT_ATTRIB_ORGANIZATION:
 3380             FreeAndNull(curr_scope->attribute->organization);
 3381             curr_scope->state->organization = FALSE;
 3382             snprintf(tinrc.attrib_organization, sizeof(tinrc.attrib_organization), "%s", BlankIfNull(default_scope->attribute->organization));
 3383             break;
 3384         case OPT_ATTRIB_POST_8BIT_HEADER:
 3385             curr_scope->state->post_8bit_header = FALSE;
 3386             tinrc.attrib_post_8bit_header = default_scope->attribute->post_8bit_header;
 3387             break;
 3388         case OPT_ATTRIB_POST_MIME_ENCODING:
 3389             curr_scope->state->post_mime_encoding = FALSE;
 3390             tinrc.attrib_post_mime_encoding = default_scope->attribute->post_mime_encoding;
 3391             break;
 3392         case OPT_ATTRIB_POST_PROCESS_VIEW:
 3393             curr_scope->state->post_process_view = FALSE;
 3394             tinrc.attrib_post_process_view = default_scope->attribute->post_process_view;
 3395             break;
 3396         case OPT_ATTRIB_POS_FIRST_UNREAD:
 3397             curr_scope->state->pos_first_unread = FALSE;
 3398             tinrc.attrib_pos_first_unread = default_scope->attribute->pos_first_unread;
 3399             break;
 3400 #ifndef DISABLE_PRINTING
 3401         case OPT_ATTRIB_PRINT_HEADER:
 3402             curr_scope->state->print_header = FALSE;
 3403             tinrc.attrib_print_header = default_scope->attribute->print_header;
 3404             break;
 3405 #endif /* !DISABLE_PRINTING */
 3406         case OPT_ATTRIB_PROCESS_ONLY_UNREAD:
 3407             curr_scope->state->process_only_unread = FALSE;
 3408             tinrc.attrib_process_only_unread = default_scope->attribute->process_only_unread;
 3409             break;
 3410         case OPT_ATTRIB_PROMPT_FOLLOWUPTO:
 3411             curr_scope->state->prompt_followupto = FALSE;
 3412             tinrc.attrib_prompt_followupto = default_scope->attribute->prompt_followupto;
 3413             break;
 3414         case OPT_ATTRIB_QUOTE_CHARS:
 3415             FreeAndNull(curr_scope->attribute->quote_chars);
 3416             curr_scope->state->quote_chars = FALSE;
 3417             snprintf(tinrc.attrib_quote_chars, sizeof(tinrc.attrib_quote_chars), "%s", BlankIfNull(default_scope->attribute->quote_chars));
 3418             break;
 3419         case OPT_ATTRIB_SAVEDIR:
 3420             FreeAndNull(curr_scope->attribute->savedir);
 3421             curr_scope->state->savedir = FALSE;
 3422             snprintf(tinrc.attrib_savedir, sizeof(tinrc.attrib_savedir), "%s", BlankIfNull(default_scope->attribute->savedir));
 3423             break;
 3424         case OPT_ATTRIB_SAVEFILE:
 3425             FreeAndNull(curr_scope->attribute->savefile);
 3426             curr_scope->state->savefile = FALSE;
 3427             snprintf(tinrc.attrib_savefile, sizeof(tinrc.attrib_savefile), "%s", BlankIfNull(default_scope->attribute->savefile));
 3428             break;
 3429         case OPT_ATTRIB_SHOW_AUTHOR:
 3430             curr_scope->state->show_author = FALSE;
 3431             tinrc.attrib_show_author = default_scope->attribute->show_author;
 3432             break;
 3433         case OPT_ATTRIB_SHOW_ONLY_UNREAD_ARTS:
 3434             curr_scope->state->show_only_unread_arts = FALSE;
 3435             tinrc.attrib_show_only_unread_arts = default_scope->attribute->show_only_unread_arts;
 3436             break;
 3437         case OPT_ATTRIB_SHOW_SIGNATURES:
 3438             curr_scope->state->show_signatures = FALSE;
 3439             tinrc.attrib_show_signatures = default_scope->attribute->show_signatures;
 3440             break;
 3441         case OPT_ATTRIB_SIGDASHES:
 3442             curr_scope->state->sigdashes = FALSE;
 3443             tinrc.attrib_sigdashes = default_scope->attribute->sigdashes;
 3444             break;
 3445         case OPT_ATTRIB_SIGFILE:
 3446             FreeAndNull(curr_scope->attribute->sigfile);
 3447             curr_scope->state->sigfile = FALSE;
 3448             snprintf(tinrc.attrib_sigfile, sizeof(tinrc.attrib_sigfile), "%s", BlankIfNull(default_scope->attribute->sigfile));
 3449             break;
 3450         case OPT_ATTRIB_SIGNATURE_REPOST:
 3451             curr_scope->state->signature_repost = FALSE;
 3452             tinrc.attrib_signature_repost = default_scope->attribute->signature_repost;
 3453             break;
 3454         case OPT_ATTRIB_START_EDITOR_OFFSET:
 3455             curr_scope->state->start_editor_offset = FALSE;
 3456             tinrc.attrib_start_editor_offset = default_scope->attribute->start_editor_offset;
 3457             break;
 3458         case OPT_ATTRIB_THREAD_ARTICLES:
 3459             curr_scope->state->thread_articles = FALSE;
 3460             tinrc.attrib_thread_articles = default_scope->attribute->thread_articles;
 3461             break;
 3462         case OPT_ATTRIB_THREAD_CATCHUP_ON_EXIT:
 3463             curr_scope->state->thread_catchup_on_exit = FALSE;
 3464             tinrc.attrib_thread_catchup_on_exit = default_scope->attribute->thread_catchup_on_exit;
 3465             break;
 3466         case OPT_ATTRIB_THREAD_FORMAT:
 3467             FreeAndNull(curr_scope->attribute->thread_format);
 3468             curr_scope->state->thread_format = FALSE;
 3469             snprintf(tinrc.attrib_thread_format, sizeof(tinrc.attrib_thread_format), "%s", BlankIfNull(default_scope->attribute->thread_format));
 3470             break;
 3471         case OPT_ATTRIB_THREAD_PERC:
 3472             curr_scope->state->thread_perc = FALSE;
 3473             tinrc.attrib_thread_perc = default_scope->attribute->thread_perc;
 3474             break;
 3475         case OPT_ATTRIB_TRIM_ARTICLE_BODY:
 3476             curr_scope->state->trim_article_body = FALSE;
 3477             tinrc.attrib_trim_article_body = default_scope->attribute->trim_article_body;
 3478             break;
 3479         case OPT_ATTRIB_TEX2ISO_CONV:
 3480             curr_scope->state->tex2iso_conv = FALSE;
 3481             tinrc.attrib_tex2iso_conv = default_scope->attribute->tex2iso_conv;
 3482             break;
 3483         case OPT_ATTRIB_SORT_THREADS_TYPE:
 3484             curr_scope->state->sort_threads_type = FALSE;
 3485             tinrc.attrib_sort_threads_type = default_scope->attribute->sort_threads_type;
 3486             break;
 3487 #ifdef CHARSET_CONVERSION
 3488         case OPT_ATTRIB_MM_NETWORK_CHARSET:
 3489             curr_scope->state->mm_network_charset = FALSE;
 3490             tinrc.attrib_mm_network_charset = default_scope->attribute->mm_network_charset;
 3491             break;
 3492         case OPT_ATTRIB_UNDECLARED_CHARSET:
 3493             FreeAndNull(curr_scope->attribute->undeclared_charset);
 3494             curr_scope->state->undeclared_charset = FALSE;
 3495             snprintf(tinrc.attrib_undeclared_charset, sizeof(tinrc.attrib_undeclared_charset), "%s", BlankIfNull(default_scope->attribute->undeclared_charset));
 3496             break;
 3497 #endif /* CHARSET_CONVERSION */
 3498         case OPT_ATTRIB_VERBATIM_HANDLING:
 3499             curr_scope->state->verbatim_handling = FALSE;
 3500             tinrc.attrib_verbatim_handling = default_scope->attribute->verbatim_handling;
 3501             break;
 3502         case OPT_ATTRIB_WRAP_ON_NEXT_UNREAD:
 3503             curr_scope->state->wrap_on_next_unread = FALSE;
 3504             tinrc.attrib_wrap_on_next_unread = default_scope->attribute->wrap_on_next_unread;
 3505             break;
 3506         case OPT_ATTRIB_SORT_ARTICLE_TYPE:
 3507             curr_scope->state->sort_article_type = FALSE;
 3508             tinrc.attrib_sort_article_type = default_scope->attribute->sort_article_type;
 3509             break;
 3510         case OPT_ATTRIB_POST_PROCESS_TYPE:
 3511             curr_scope->state->post_process_type = FALSE;
 3512             tinrc.attrib_post_process_type = default_scope->attribute->post_process_type;
 3513             break;
 3514         case OPT_ATTRIB_X_BODY:
 3515             FreeAndNull(curr_scope->attribute->x_body);
 3516             curr_scope->state->x_body = FALSE;
 3517             snprintf(tinrc.attrib_x_body, sizeof(tinrc.attrib_x_body), "%s", BlankIfNull(default_scope->attribute->x_body));
 3518             break;
 3519         case OPT_ATTRIB_X_COMMENT_TO:
 3520             curr_scope->state->x_comment_to = FALSE;
 3521             tinrc.attrib_x_comment_to = default_scope->attribute->x_comment_to;
 3522             break;
 3523         case OPT_ATTRIB_X_HEADERS:
 3524             FreeAndNull(curr_scope->attribute->x_headers);
 3525             curr_scope->state->x_headers = FALSE;
 3526             snprintf(tinrc.attrib_x_headers, sizeof(tinrc.attrib_x_headers), "%s", BlankIfNull(default_scope->attribute->x_headers));
 3527             break;
 3528 
 3529         default:
 3530             break;
 3531     }
 3532 }
 3533 
 3534 
 3535 #define INITIALIZE_STRING_ATTRIBUTE(option) do { \
 3536         if (curr_scope->state->option) \
 3537             snprintf(CAO(tinrc.attrib_, option), sizeof(CAO(tinrc.attrib_, option)), "%s", curr_scope->attribute->option); \
 3538         else \
 3539             snprintf(CAO(tinrc.attrib_, option), sizeof(CAO(tinrc.attrib_, option)), "%s", BlankIfNull(default_scope->attribute->option)); \
 3540     } while (0)
 3541 #define INITIALIZE_NUM_ATTRIBUTE(option) do { \
 3542         if (curr_scope->state->option) \
 3543             CAO(tinrc.attrib_, option) = curr_scope->attribute->option; \
 3544         else \
 3545             CAO(tinrc.attrib_, option) = default_scope->attribute->option; \
 3546     } while (0)
 3547 
 3548 static void
 3549 initialize_attributes(
 3550     void)
 3551 {
 3552     struct t_scope *default_scope = &scopes[0];
 3553 
 3554     INITIALIZE_NUM_ATTRIBUTE(add_posted_to_filter);
 3555     INITIALIZE_NUM_ATTRIBUTE(advertising);
 3556     INITIALIZE_NUM_ATTRIBUTE(alternative_handling);
 3557     INITIALIZE_NUM_ATTRIBUTE(ask_for_metamail);
 3558     INITIALIZE_NUM_ATTRIBUTE(auto_cc_bcc);
 3559     INITIALIZE_NUM_ATTRIBUTE(auto_list_thread);
 3560     INITIALIZE_NUM_ATTRIBUTE(auto_save);
 3561     INITIALIZE_NUM_ATTRIBUTE(auto_select);
 3562     INITIALIZE_NUM_ATTRIBUTE(batch_save);
 3563     INITIALIZE_NUM_ATTRIBUTE(delete_tmp_files);
 3564 #ifdef HAVE_COLOR
 3565     INITIALIZE_NUM_ATTRIBUTE(extquote_handling);
 3566 #endif /* HAVE_COLOR */
 3567     INITIALIZE_NUM_ATTRIBUTE(group_catchup_on_exit);
 3568     INITIALIZE_NUM_ATTRIBUTE(mail_8bit_header);
 3569     INITIALIZE_NUM_ATTRIBUTE(mail_mime_encoding);
 3570     INITIALIZE_NUM_ATTRIBUTE(mark_ignore_tags);
 3571     INITIALIZE_NUM_ATTRIBUTE(mark_saved_read);
 3572     INITIALIZE_NUM_ATTRIBUTE(mime_forward);
 3573     INITIALIZE_NUM_ATTRIBUTE(pos_first_unread);
 3574     INITIALIZE_NUM_ATTRIBUTE(post_8bit_header);
 3575     INITIALIZE_NUM_ATTRIBUTE(post_mime_encoding);
 3576     INITIALIZE_NUM_ATTRIBUTE(post_process_view);
 3577 #ifndef DISABLE_PRINTING
 3578     INITIALIZE_NUM_ATTRIBUTE(print_header);
 3579 #endif /* !DISABLE_PRINTING */
 3580     INITIALIZE_NUM_ATTRIBUTE(process_only_unread);
 3581     INITIALIZE_NUM_ATTRIBUTE(prompt_followupto);
 3582     INITIALIZE_NUM_ATTRIBUTE(quick_kill_header);
 3583     INITIALIZE_NUM_ATTRIBUTE(quick_kill_case);
 3584     INITIALIZE_NUM_ATTRIBUTE(quick_kill_expire);
 3585     INITIALIZE_NUM_ATTRIBUTE(quick_select_header);
 3586     INITIALIZE_NUM_ATTRIBUTE(quick_select_case);
 3587     INITIALIZE_NUM_ATTRIBUTE(quick_select_expire);
 3588     INITIALIZE_NUM_ATTRIBUTE(show_author);
 3589     INITIALIZE_NUM_ATTRIBUTE(show_only_unread_arts);
 3590     INITIALIZE_NUM_ATTRIBUTE(show_signatures);
 3591     INITIALIZE_NUM_ATTRIBUTE(sigdashes);
 3592     INITIALIZE_NUM_ATTRIBUTE(signature_repost);
 3593     INITIALIZE_NUM_ATTRIBUTE(start_editor_offset);
 3594     INITIALIZE_NUM_ATTRIBUTE(thread_articles);
 3595     INITIALIZE_NUM_ATTRIBUTE(thread_catchup_on_exit);
 3596     INITIALIZE_NUM_ATTRIBUTE(thread_perc);
 3597     INITIALIZE_NUM_ATTRIBUTE(trim_article_body);
 3598     INITIALIZE_NUM_ATTRIBUTE(tex2iso_conv);
 3599     INITIALIZE_NUM_ATTRIBUTE(verbatim_handling);
 3600     INITIALIZE_NUM_ATTRIBUTE(wrap_on_next_unread);
 3601     INITIALIZE_NUM_ATTRIBUTE(sort_article_type);
 3602     INITIALIZE_NUM_ATTRIBUTE(sort_threads_type);
 3603     INITIALIZE_NUM_ATTRIBUTE(post_process_type);
 3604     INITIALIZE_NUM_ATTRIBUTE(x_comment_to);
 3605     INITIALIZE_STRING_ATTRIBUTE(date_format);
 3606     INITIALIZE_STRING_ATTRIBUTE(editor_format);
 3607     INITIALIZE_STRING_ATTRIBUTE(fcc);
 3608     INITIALIZE_STRING_ATTRIBUTE(followup_to);
 3609     INITIALIZE_STRING_ATTRIBUTE(from);
 3610     INITIALIZE_STRING_ATTRIBUTE(group_format);
 3611 #ifdef HAVE_ISPELL
 3612     INITIALIZE_STRING_ATTRIBUTE(ispell);
 3613 #endif /* HAVE_ISPELL */
 3614     INITIALIZE_STRING_ATTRIBUTE(maildir);
 3615     INITIALIZE_STRING_ATTRIBUTE(mailing_list);
 3616     INITIALIZE_STRING_ATTRIBUTE(mime_types_to_save);
 3617     INITIALIZE_STRING_ATTRIBUTE(news_headers_to_display);
 3618     INITIALIZE_STRING_ATTRIBUTE(news_headers_to_not_display);
 3619     INITIALIZE_STRING_ATTRIBUTE(news_quote_format);
 3620     INITIALIZE_STRING_ATTRIBUTE(organization);
 3621     INITIALIZE_STRING_ATTRIBUTE(quick_kill_scope);
 3622     INITIALIZE_STRING_ATTRIBUTE(quick_select_scope);
 3623     INITIALIZE_STRING_ATTRIBUTE(quote_chars);
 3624     INITIALIZE_STRING_ATTRIBUTE(savedir);
 3625     INITIALIZE_STRING_ATTRIBUTE(savefile);
 3626     INITIALIZE_STRING_ATTRIBUTE(sigfile);
 3627     INITIALIZE_STRING_ATTRIBUTE(thread_format);
 3628 #ifdef CHARSET_CONVERSION
 3629     INITIALIZE_NUM_ATTRIBUTE(mm_network_charset);
 3630     INITIALIZE_STRING_ATTRIBUTE(undeclared_charset);
 3631 #endif /* CHARSET_CONVERSION */
 3632     INITIALIZE_STRING_ATTRIBUTE(x_body);
 3633     INITIALIZE_STRING_ATTRIBUTE(x_headers);
 3634 }