/* * dselect - Debian package maintenance user interface * main.cc - main program * * Copyright © 1994-1996 Ian Jackson * Copyright © 2000,2001 Wichert Akkerman * Copyright © 2006-2015 Guillem Jover * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #if HAVE_LOCALE_H #include #endif #include #include #include #include #include #include #include // Solaris requires curses.h to be included before term.h #include "dselect-curses.h" #if defined(HAVE_NCURSESW_TERM_H) #include #elif defined(HAVE_NCURSES_TERM_H) #include #else #include #endif #include #include #include #include #include #include "dselect.h" #include "bindings.h" #include "pkglist.h" static const char printforhelp[] = N_("Type dselect --help for help."); bool expertmode = false; static keybindings packagelistbindings(packagelist_kinterps,packagelist_korgbindings); struct table_t { const char *name; const int num; }; static const struct table_t colourtable[]= { {"black", COLOR_BLACK }, {"red", COLOR_RED }, {"green", COLOR_GREEN }, {"yellow", COLOR_YELLOW }, {"blue", COLOR_BLUE }, {"magenta", COLOR_MAGENTA }, {"cyan", COLOR_CYAN }, {"white", COLOR_WHITE }, {nullptr, 0}, }; static const struct table_t attrtable[]= { {"normal", A_NORMAL }, {"standout", A_STANDOUT }, {"underline", A_UNDERLINE }, {"reverse", A_REVERSE }, {"blink", A_BLINK }, {"bright", A_BLINK }, // on some terminals {"dim", A_DIM }, {"bold", A_BOLD }, {nullptr, 0}, }; /* A slightly confusing mapping from dselect's internal names to * the user-visible names.*/ static const struct table_t screenparttable[]= { {"list", list }, {"listsel", listsel }, {"title", title }, {"infohead", thisstate }, {"pkgstate", selstate }, {"pkgstatesel", selstatesel }, {"listhead", colheads }, {"query", query }, {"info", info_body }, {"infodesc", info_head }, {"infofoot", whatinfo }, {"helpscreen", helpscreen }, {nullptr, 0}, }; /* Historical (patriotic?) colours. */ struct colordata color[]= { /* fore back attr */ {COLOR_WHITE, COLOR_BLACK, 0 }, // default, not used {COLOR_WHITE, COLOR_BLACK, 0 }, // list {COLOR_WHITE, COLOR_BLACK, A_REVERSE }, // listsel {COLOR_WHITE, COLOR_RED, 0 }, // title {COLOR_WHITE, COLOR_BLUE, 0 }, // thisstate {COLOR_WHITE, COLOR_BLACK, A_BOLD }, // selstate {COLOR_WHITE, COLOR_BLACK, A_REVERSE | A_BOLD }, // selstatesel {COLOR_WHITE, COLOR_BLUE, 0 }, // colheads {COLOR_WHITE, COLOR_RED, 0 }, // query {COLOR_WHITE, COLOR_BLACK, 0 }, // info_body {COLOR_WHITE, COLOR_BLACK, A_BOLD }, // info_head {COLOR_WHITE, COLOR_BLUE, 0 }, // whatinfo {COLOR_WHITE, COLOR_BLACK, 0 }, // help }; struct menuentry { const char *command; const char *key; const char *option; const char *menuent; urqfunction *fn; }; static const menuentry menuentries[]= { { "access", N_("a"), N_("[A]ccess"), N_("Choose the access method to use."), &urq_setup }, { "update", N_("u"), N_("[U]pdate"), N_("Update list of available packages, if possible."), &urq_update }, { "select", N_("s"), N_("[S]elect"), N_("Request which packages you want on your system."), &urq_list }, { "install", N_("i"), N_("[I]nstall"),N_("Install and upgrade wanted packages."), &urq_install }, { "config", N_("c"), N_("[C]onfig"), N_("Configure any packages that are unconfigured."), &urq_config }, { "remove", N_("r"), N_("[R]emove"), N_("Remove unwanted software."), &urq_remove }, { "quit", N_("q"), N_("[Q]uit"), N_("Quit dselect."), &urq_quit }, { nullptr, nullptr, N_("menu"), nullptr, &urq_menu }, { nullptr } }; static const char programdesc[]= N_("Debian '%s' package handling frontend version %s.\n"); static const char licensestring[]= N_( "This is free software; see the GNU General Public License version 2 or\n" "later for copying conditions. There is NO warranty.\n"); static void DPKG_ATTR_NORET printversion(const struct cmdinfo *ci, const char *value) { printf(gettext(programdesc), DSELECT, PACKAGE_RELEASE); printf("%s", gettext(licensestring)); m_output(stdout, _("")); exit(0); } static void DPKG_ATTR_NORET usage(const struct cmdinfo *ci, const char *value) { int i; printf(_( "Usage: %s [