[Aptitude-svn-commit] r3278 - in branches/aptitude-0.3/aptitude: . src/vscreen
Daniel Burrows
dburrows@costa.debian.org
Tue, 10 May 2005 13:08:47 +0000
Author: dburrows
Date: Tue May 10 13:08:45 2005
New Revision: 3278
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/curses++.cc
branches/aptitude-0.3/aptitude/src/vscreen/curses++.h
branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc
Log:
Update chstring for styles.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Tue May 10 13:08:45 2005
@@ -1,5 +1,11 @@
2005-05-10 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/curses++.cc, src/vscreen/curses++.h:
+
+ Add some new constructors to chstring that will be needed later;
+ remove direct attribute manipulation and replace it with style
+ adjustment.
+
* src/vscreen/config/colors.cc:
Fix a silly compile error.
Modified: branches/aptitude-0.3/aptitude/src/vscreen/curses++.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/curses++.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/curses++.cc Tue May 10 13:08:45 2005
@@ -1,6 +1,6 @@
// curses++.cc
//
-// Copyright 1999,2000,2001 Daniel Burrows
+// Copyright 1999-2005 Daniel Burrows
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
// A few initialization routines and so on.
#include "curses++.h"
+#include "config/style.h"
#include <stdarg.h>
@@ -42,29 +43,16 @@
(*this)=s;
}
-chstring::chstring(const string &s, int attr)
+chstring::chstring(const string &s, const style &st)
{
(*this)=s;
- set_attr(attr);
+ apply_style(st);
}
-// Routines to manipulate chstrings:
-void chstring::add_attr(int attrs)
+void chstring::apply_style(const style &st)
{
- for(chstring::iterator i=begin(); i!=end(); ++i)
- (*i)|=attrs;
-}
-
-void chstring::remove_attr(int attrs)
-{
- for(chstring::iterator i=begin(); i!=end(); ++i)
- (*i)&=~attrs;
-}
-
-void chstring::set_attr(int attrs)
-{
- for(chstring::iterator i=begin(); i!=end(); ++i)
- (*i)=((*i)&A_CHARTEXT)|attrs;
+ for(iterator i=begin(); i!=end(); ++i)
+ *i=st.apply_to(*i);
}
int char_traits<chtype>::compare(const chtype *s1,
Modified: branches/aptitude-0.3/aptitude/src/vscreen/curses++.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/curses++.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/curses++.h Tue May 10 13:08:45 2005
@@ -67,6 +67,8 @@
};
}
+class style;
+
/** A string class which stores attributes along with characters.
*
* This has to derive from basic_string in order to implement operator=
@@ -80,9 +82,13 @@
:std::basic_string<chtype>(s) {}
chstring(const std::string &s);
- chstring(const std::string &s, int attr);
+ chstring(const std::string &s, const style &st);
chstring(const chstring &s):super(s) {}
+ /** Apply the given style to the given chstring, and set ourselves
+ * to the result.
+ */
+ chstring(const chstring &s, const style &st);
chstring(const chstring &s, size_t loc, size_t n=npos)
:super(s, loc, n) {}
@@ -93,14 +99,8 @@
/** Assign the characters of s to this, setting all attributes to A_NORMAL. */
chstring &operator=(const std::string &s);
- /** Add attrs to each character of this chstring. */
- void add_attr(int attrs);
-
- /** Remove attrs from each character of this chstring. */
- void remove_attr(int attrs);
-
- /** Set the attributes of each character of this chstring to attrs. */
- void set_attr(int attrs);
+ /** Change the attributes of this string by using the given style. */
+ void apply_style(const style &st);
};
inline chtype _getbkgd(WINDOW *win)
Modified: branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc Tue May 10 13:08:45 2005
@@ -976,8 +976,7 @@
break;
case 's':
case 'F':
- case 'C':
- case 'A':
+ case 'S':
if(arguments[argcount].format!=0 && arguments[argcount].format!=*(nextpercent+1))
return text_fragment("Bad argument string to fragf: inconsistent parameter types!",
get_color("Error"));