Break out configuration main menu

This was the only big block of code left in our main loop. Move it to a
separate function, making the main loop a bit clearer.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-02-20 19:23:25 +01:00
parent b5c1981842
commit 17aa73b73f
3 changed files with 58 additions and 49 deletions

View File

@ -68,9 +68,6 @@ main (int argc, char **argv)
int non_interactive; int non_interactive;
int no_data_file = 1; int no_data_file = 1;
int cut_item = 0; int cut_item = 0;
char *no_color_support =
_("Sorry, colors are not supported by your terminal\n"
"(Press [ENTER] to continue)");
char *quit_message = _("Do you really want to quit ?"); char *quit_message = _("Do you really want to quit ?");
char choices[] = "[y/n] "; char choices[] = "[y/n] ";
int count; int count;
@ -242,52 +239,8 @@ main (int argc, char **argv)
case KEY_GENERIC_CONFIG_MENU: case KEY_GENERIC_CONFIG_MENU:
wins_erase_status_bar (); wins_erase_status_bar ();
custom_config_bar (); custom_config_main ();
while ((key = wgetch (win[STA].p)) != 'q') inday = do_storage (0);
{
switch (key)
{
case 'C':
case 'c':
if (has_colors ())
custom_color_config ();
else
{
colorize = 0;
wins_erase_status_bar ();
mvwprintw (win[STA].p, 0, 0, _(no_color_support));
wgetch (win[STA].p);
}
break;
case 'L':
case 'l':
custom_layout_config ();
break;
case 'G':
case 'g':
custom_general_config ();
break;
case 'N':
case 'n':
notify_config_bar ();
break;
case 'K':
case 'k':
custom_keys_config ();
break;
case 's':
case 'S':
custom_sidebar_config ();
break;
default:
continue;
}
wins_reset ();
wins_update (FLAG_ALL);
wins_erase_status_bar ();
custom_config_bar ();
inday = do_storage (0);
}
wins_update (FLAG_ALL); wins_update (FLAG_ALL);
break; break;

View File

@ -644,6 +644,7 @@ void custom_confwin_init (struct window *, char *);
void custom_set_swsiz (struct scrollwin *); void custom_set_swsiz (struct scrollwin *);
void custom_general_config (void); void custom_general_config (void);
void custom_keys_config (void); void custom_keys_config (void);
void custom_config_main (void);
/* day.c */ /* day.c */
void day_free_list (void); void day_free_list (void);

View File

@ -1097,3 +1097,58 @@ custom_keys_config (void)
wins_scrollwin_display (&kwin); wins_scrollwin_display (&kwin);
} }
} }
void
custom_config_main (void)
{
char *no_color_support =
_("Sorry, colors are not supported by your terminal\n"
"(Press [ENTER] to continue)");
int ch;
custom_config_bar ();
while ((ch = wgetch (win[STA].p)) != 'q')
{
switch (ch)
{
case 'C':
case 'c':
if (has_colors ())
custom_color_config ();
else
{
colorize = 0;
wins_erase_status_bar ();
mvwprintw (win[STA].p, 0, 0, _(no_color_support));
wgetch (win[STA].p);
}
break;
case 'L':
case 'l':
custom_layout_config ();
break;
case 'G':
case 'g':
custom_general_config ();
break;
case 'N':
case 'n':
notify_config_bar ();
break;
case 'K':
case 'k':
custom_keys_config ();
break;
case 's':
case 'S':
custom_sidebar_config ();
break;
default:
continue;
}
wins_reset ();
wins_update (FLAG_ALL);
wins_erase_status_bar ();
custom_config_bar ();
}
}