diff options
author | Guillem Jover <guillem@debian.org> | 2012-03-20 10:07:53 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2012-03-27 20:10:09 +0200 |
commit | c49aec380adb025f218f89366b775ef6166e7318 (patch) | |
tree | 63aa15eeb3a2be4467da42be5fa5c2e7f641b503 /dselect/baselist.cc | |
parent | 7abdff8709a638213c477754dd6ddf61dfe6fe01 (diff) | |
download | dpkg-c49aec380adb025f218f89366b775ef6166e7318.tar.gz |
dselect: Use a new attribute array instead of separate attribute variables
Diffstat (limited to 'dselect/baselist.cc')
-rw-r--r-- | dselect/baselist.cc | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/dselect/baselist.cc b/dselect/baselist.cc index 0729dbe47..ee4969618 100644 --- a/dselect/baselist.cc +++ b/dselect/baselist.cc @@ -124,34 +124,22 @@ void baselist::startdisplay() { for (i = 1; i < numscreenparts; i++) { if (init_pair(i, color[i].fore, color[i].back) != OK) ohshite(_("failed to allocate colour pair")); + part_attr[i] = COLOR_PAIR(i) | color[i].attr; } - /* TODO: should use an array of attr's, indexed by attr name. Oh well. */ - list_attr= COLOR_PAIR(list) | color[list].attr; - listsel_attr= COLOR_PAIR(listsel) | color[listsel].attr; - title_attr= COLOR_PAIR(title) | color[title].attr; - thisstate_attr= COLOR_PAIR(thisstate) | color[thisstate].attr; - selstate_attr= COLOR_PAIR(selstate) | color[selstate].attr; - selstatesel_attr= COLOR_PAIR(selstatesel) | color[selstatesel].attr; - colheads_attr= COLOR_PAIR(colheads) | color[colheads].attr; - query_attr= COLOR_PAIR(query) | color[query].attr; - info_attr= COLOR_PAIR(info) | color[info].attr; - info_headattr= COLOR_PAIR(info_head) | color[info_head].attr; - whatinfo_attr= COLOR_PAIR(whatinfo) | color[whatinfo].attr; - helpscreen_attr= COLOR_PAIR(helpscreen) | color[helpscreen].attr; } else { /* User defined attributes for B&W mode are not currently supported. */ - title_attr= A_REVERSE; - thisstate_attr= A_STANDOUT; - list_attr= 0; - listsel_attr= A_STANDOUT; - selstate_attr= A_BOLD; - selstatesel_attr= A_STANDOUT; - colheads_attr= A_BOLD; - query_attr= title_attr; - info_attr= list_attr; - info_headattr= A_BOLD; - whatinfo_attr= thisstate_attr; - helpscreen_attr= A_NORMAL; + part_attr[title] = A_REVERSE; + part_attr[thisstate] = A_STANDOUT; + part_attr[list] = 0; + part_attr[listsel] = A_STANDOUT; + part_attr[selstate] = A_BOLD; + part_attr[selstatesel] = A_STANDOUT; + part_attr[colheads]= A_BOLD; + part_attr[query] = part_attr[title]; + part_attr[info] = part_attr[list]; + part_attr[info_head] = A_BOLD; + part_attr[whatinfo] = part_attr[thisstate]; + part_attr[helpscreen] = A_NORMAL; } // set up windows and pads, based on screen size @@ -165,31 +153,31 @@ void baselist::startdisplay() { titlewin= newwin(1,xmax, 0,0); if (!titlewin) ohshite(_("failed to create title window")); - wattrset(titlewin,title_attr); + wattrset(titlewin, part_attr[title]); whatinfowin= newwin(1,xmax, whatinfo_row,0); if (!whatinfowin) ohshite(_("failed to create whatinfo window")); - wattrset(whatinfowin,whatinfo_attr); + wattrset(whatinfowin, part_attr[whatinfo]); listpad = newpad(ymax, total_width); if (!listpad) ohshite(_("failed to create baselist pad")); colheadspad= newpad(1, total_width); if (!colheadspad) ohshite(_("failed to create heading pad")); - wattrset(colheadspad,colheads_attr); + wattrset(colheadspad, part_attr[colheads]); thisstatepad= newpad(1, total_width); if (!thisstatepad) ohshite(_("failed to create thisstate pad")); - wattrset(thisstatepad,thisstate_attr); + wattrset(thisstatepad, part_attr[thisstate]); infopad= newpad(MAX_DISPLAY_INFO, total_width); if (!infopad) ohshite(_("failed to create info pad")); - wattrset(infopad,info_attr); - wbkgdset(infopad, ' ' | info_attr); + wattrset(infopad, part_attr[info]); + wbkgdset(infopad, ' ' | part_attr[info]); querywin= newwin(1,xmax,ymax-1,0); if (!querywin) ohshite(_("failed to create query window")); - wbkgdset(querywin, ' ' | query_attr); + wbkgdset(querywin, ' ' | part_attr[query]); if (cursorline >= topofscreen + list_height) topofscreen= cursorline; if (topofscreen > nitems - list_height) topofscreen= nitems - list_height; @@ -225,7 +213,8 @@ void baselist::enddisplay() { void baselist::redrawall() { redrawtitle(); redrawcolheads(); - wattrset(listpad,list_attr); mywerase(listpad); + wattrset(listpad, part_attr[list]); + mywerase(listpad); ldrawnstart= ldrawnend= -1; // start is first drawn; end is first undrawn; -1=none refreshlist(); redrawthisstate(); |