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

Daniel Burrows dburrows@costa.debian.org
Wed, 29 Jun 2005 18:50:47 +0000


Author: dburrows
Date: Wed Jun 29 18:50:44 2005
New Revision: 3512

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/TODO
   branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h
Log:
Convert vs_statuschoice to handle wide characters.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Jun 29 18:50:44 2005
@@ -1,5 +1,9 @@
 2005-06-29  Daniel Burrows  <dburrows@debian.org>
 
+	* src/vscreen/vs_statuschoice.cc, src/vscreen/vs_statuschoice.h:
+
+	  Convert vs_statuschoice to handle wide characters.
+
 	* src/vscreen/vs_menubar.cc, src/vscreen/vs_menubar.h, src/vscreen/testvscreen.cc:
 
 	  Convert vs_menubar to handle wide characters.

Modified: branches/aptitude-0.3/aptitude/TODO
==============================================================================
--- branches/aptitude-0.3/aptitude/TODO	(original)
+++ branches/aptitude-0.3/aptitude/TODO	Wed Jun 29 18:50:44 2005
@@ -11,7 +11,6 @@
    - left to do in UTF8:
 
     * ACS -> WACS
-    * vs_statuschoice
     * all of src/
 
    - Display layout loose ends:

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc	Wed Jun 29 18:50:44 2005
@@ -47,8 +47,8 @@
     }
   else
     {
-      std::string::size_type where=choices.find((char) k.ch);
-      if(where==string::npos)
+      std::wstring::size_type where=choices.find(k.ch);
+      if(where==wstring::npos)
 	beep();
       else
 	{
@@ -61,7 +61,7 @@
 
 void vs_statuschoice::paint(const style &st)
 {
-  string todisp=prompt+" ["+choices[0]+"]";
+  wstring todisp=prompt+L" ["+choices[0]+L"]";
   for(unsigned int i=1; i<choices.size(); i++)
     todisp+=choices[i];
   mvaddstr(0, 0, todisp.c_str());
@@ -74,7 +74,8 @@
 
 int vs_statuschoice::width_request()
 {
-  return prompt.size()+choices.size()+5;
+  return wcswidth(prompt.c_str(), prompt.size())
+    +wcswidth(choices.c_str(), choices.size())+5;
 }
 
 int vs_statuschoice::height_request(int w)

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h	Wed Jun 29 18:50:44 2005
@@ -37,15 +37,15 @@
 
 class vs_statuschoice:public vscreen_widget
 {
-  std::string prompt;
-  std::string choices;
+  std::wstring prompt;
+  std::wstring choices;
   // A string containing all possible choices; the first one is considered
   // to be the "default".
 
 protected:
   bool handle_key(const key &k);
 public:
-  vs_statuschoice(const std::string &_prompt, const std::string &_choices)
+  vs_statuschoice(const std::wstring &_prompt, const std::wstring &_choices)
     :vscreen_widget(), prompt(_prompt), choices(_choices)
   {
     assert(choices.size()>0);