From: Pasi Kallinen Date: Sat, 7 Oct 2017 22:45:46 +0000 (+0300) Subject: Qt4: Add menucolors X-Git-Tag: NetHack-3.6.1_RC01~307 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=583edab99f2bf050fdc84312bb4235517c9674d1;p=nethack Qt4: Add menucolors The Qt4 windowport already supported my 3.4.3 menucolors patch, so adding that was simple. --- diff --git a/include/extern.h b/include/extern.h index 018094dd4..ca78d340f 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1723,7 +1723,7 @@ E const char *FDECL(clr2colorname, (int)); E int FDECL(match_str2clr, (char *)); E int FDECL(match_str2attr, (const char *, BOOLEAN_P)); E boolean FDECL(add_menu_coloring, (char *)); -E boolean FDECL(get_menu_coloring, (char *, int *, int *)); +E boolean FDECL(get_menu_coloring, (const char *, int *, int *)); E void NDECL(free_menu_coloring); E boolean FDECL(msgtype_parse_add, (char *)); E int FDECL(msgtype_type, (const char *, BOOLEAN_P)); diff --git a/src/options.c b/src/options.c index c17e44869..7086a7b5e 100644 --- a/src/options.c +++ b/src/options.c @@ -1747,7 +1747,7 @@ char *tmpstr; boolean get_menu_coloring(str, color, attr) -char *str; +const char *str; int *color, *attr; { struct menucoloring *tmpmc; diff --git a/win/Qt4/qt4menu.cpp b/win/Qt4/qt4menu.cpp index b15aa0ee5..7d70a26e2 100644 --- a/win/Qt4/qt4menu.cpp +++ b/win/Qt4/qt4menu.cpp @@ -32,9 +32,7 @@ extern "C" { extern "C" int qt_compact_mode; // end temporary -#ifdef MENU_COLOR extern "C" struct menucoloring *menu_colorings; -#endif namespace nethack_qt4 { @@ -42,8 +40,6 @@ namespace nethack_qt4 { void centerOnMain( QWidget* w ); // end temporary -static boolean get_menu_coloring(char const *str, int *color, int *attr); - QSize NetHackQtTextListBox::sizeHint() const { QScrollBar *hscroll = horizontalScrollBar(); @@ -194,39 +190,17 @@ void NetHackQtMenuWindow::AddMenu(int glyph, const ANY_P* identifier, + str.mid(bracket+2); } } -#ifdef MENU_COLOR int mcolor, mattr; if (attr == 0 - && get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) { + && get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) { itemlist[itemcount].attr = mattr; itemlist[itemcount].color = mcolor; } -#endif ++itemcount; if (glyph!=NO_GLYPH) has_glyphs=true; } -#ifdef MENU_COLOR -static boolean -get_menu_coloring(char const *str, int *color, int *attr) -{ - struct menucoloring *tmpmc; - if (iflags.use_menu_color) - for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next) -# ifdef MENU_COLOR_REGEX - if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) { -# else - if (pmatch(tmpmc->match, str)) { -# endif - *color = tmpmc->color; - *attr = tmpmc->attr; - return TRUE; - } - return FALSE; -} -#endif /* MENU_COLOR */ - void NetHackQtMenuWindow::EndMenu(const QString& p) { prompt.setText(p); @@ -417,11 +391,9 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi) table->item(row, 4)->setFlags(Qt::ItemIsEnabled); WidenColumn(4, fm.width(text)); -#ifdef MENU_COLOR if (mi.color != -1) { twi->setForeground(colors[mi.color]); } -#endif QFont itemfont(table->font()); switch (mi.attr) {