[Aptitude-svn-commit] r3426 - in branches/aptitude-0.3/aptitude: . src/vscreen

Daniel Burrows dburrows@costa.debian.org
Sat, 25 Jun 2005 17:29:47 +0000


Author: dburrows
Date: Sat Jun 25 17:29:45 2005
New Revision: 3426

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.h
Log:
Fix compilation problems, minor refactoring.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Jun 25 17:29:45 2005
@@ -1,5 +1,12 @@
 2005-06-25  Daniel Burrows  <dburrows@debian.org>
 
+	* src/vscreen/vs_button.cc, src/vscreen/vs_layout_item.cc, src/vscreen/vs_layout_item.h:
+
+	  Update places where chstring was explicitly used to call on
+	  fragment_line instead; factor some common code in
+	  vs_layout_item::paint and vs_layout_item::vs_layout_line::paint
+	  into vs_layout_item::paint_line.
+
 	* src/vscreen/vscreen_widget.h:
 
 	  Mirror the new cwindow addstr routines in vscreen_widget.

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc	Sat Jun 25 17:29:45 2005
@@ -82,11 +82,9 @@
 
       addch(' ');
 
-      chstring s=lines[i];
-      for(chstring::iterator j=s.begin(); j!=s.end(); ++j)
-	addch(*j);
-
-      int w=2+s.size();
+      const fragment_line &l=lines[i];
+      addstr(l);
+      int w=2+l.width();
 
       while(w+1<getmaxx())
 	{

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.cc	Sat Jun 25 17:29:45 2005
@@ -77,8 +77,8 @@
   delete f;
 }
 
-chstring vs_layout_item::get_line(vs_tree *win, size_t n, int basex,
-				  const style &st)
+fragment_line vs_layout_item::get_line(vs_tree *win, size_t n, int basex,
+				       const style &st)
 {
   if(win->getmaxx()!=lastw)
     {
@@ -100,22 +100,24 @@
     return lines[n];
 }
 
-void vs_layout_item::vs_layout_line::paint(vs_tree *win, int y, bool hierarchical, const style &st)
+void vs_layout_item::paint_line(int n, vs_tree *win, int y, bool hierarchical, const style &st)
 {
   int basex=hierarchical?2*get_depth():0;
 
-  chstring s=parent.get_line(win, n, basex, st);
+  fragment_line s=get_line(win, n, basex, st);
 
-  win->mvaddnstr(y, 0, chstring(basex, ' ')+s, basex+s.size());
+  win->mvaddnstr(y, 0, fragment_line(basex, ' ', st.get_attrs())+s, basex+s.size());
+}
+
+void vs_layout_item::vs_layout_line::paint(vs_tree *win, int y,
+					   bool hierarchical, const style &st)
+{
+  parent.paint_line(n, win, y, hierarchical, st);
 }
 
 void vs_layout_item::paint(vs_tree *win, int y, bool hierarchical,
 			   const style &st)
 {
-  int basex=hierarchical?2*get_depth():0;
-
-  chstring s=get_line(win, 0, basex, st);
-
-  win->mvaddnstr(y, 0, chstring(basex, ' ')+s, basex+s.size());
+  paint_line(0, win, y, hierarchical, st);
 }
 

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_layout_item.h	Sat Jun 25 17:29:45 2005
@@ -63,6 +63,10 @@
   const char *tag() const;
   const char *label() const;
 
+  /** Paints the nth line of this item at the given location in 'win'. */
+  void paint_line(int n,
+		  vs_tree *win, int y, bool hierarchical,
+		  const style &st);
   void paint(vs_tree *win, int y, bool hierarchical,
 	     const style &st);
 
@@ -72,8 +76,8 @@
   levelref *end();
   bool has_visible_children();
 
-  chstring get_line(vs_tree *win, size_t n, int basex,
-		    const style &st);
+  fragment_line get_line(vs_tree *win, size_t n, int basex,
+			 const style &st);
 
   ~vs_layout_item();
 };