[Aptitude-svn-commit] r3514 - in branches/aptitude-0.3/aptitude: . src/vscreen
Daniel Burrows
dburrows@costa.debian.org
Wed, 29 Jun 2005 19:08:55 +0000
Author: dburrows
Date: Wed Jun 29 19:08:52 2005
New Revision: 3514
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/vscreen_widget.h
Log:
Update display_header and display_status 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 19:08:52 2005
@@ -1,5 +1,10 @@
2005-06-29 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/curses++.cc, src/vscreen/curses++.h, src/vscreen/vscreen_widget.h:
+
+ Update display_header and display_status to handle wide
+ characters.
+
* src/vscreen/vs_button.cc, src/vscreen/vs_scrollbar.cc:
Convert all uses of ACS_* to WACS_*.
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 Wed Jun 29 19:08:52 2005
@@ -291,34 +291,64 @@
}
}
-void cwindow::display_header(string s, int attr)
- // Y'know, this could be just a call to show_as_progbar or whatever I called
- // it..
+void cwindow::display_header(wstring s, const attr_t attr)
{
attrset(attr);
int width,height;
getmaxyx(height,width);
- move(0,0);
- for(int i=0; i<width; i++)
- addch(' ');
+ move(0, 0);
+ int x=0;
- mvaddnstr(0,0,s.c_str(),width);
+ wstring::size_type sloc=0;
+
+ while(x<width)
+ {
+ if(sloc<s.size())
+ {
+ const wchar_t wch=s[sloc];
+
+ add_wch(wch);
+ x+=wcwidth(wch);
+ ++sloc;
+ }
+ else
+ {
+ add_wch(L' ');
+ x+=wcwidth(L' ');
+ }
+ }
}
-void cwindow::display_status(string s, int attr)
+void cwindow::display_status(wstring s, attr_t attr)
{
attrset(attr);
int width,height;
getmaxyx(height,width);
- move(height-1,0);
- for(int i=0; i<width; i++)
- addch(' ');
+ move(height-1, 0);
+ int x=0;
- mvaddnstr(height-1,0,s.c_str(),width);
+ wstring::size_type sloc=0;
+
+ while(x<width)
+ {
+ if(sloc<s.size())
+ {
+ const wchar_t wch=s[sloc];
+
+ add_wch(wch);
+ x+=wcwidth(wch);
+ ++sloc;
+ }
+ else
+ {
+ add_wch(L' ');
+ x+=wcwidth(L' ');
+ }
+ }
}
int cwindow::addstr(const wchstring &str)
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 Wed Jun 29 19:08:52 2005
@@ -547,8 +547,8 @@
void show_string_as_progbar(int x, int y, std::string s, int attr1, int attr2, int size1, int totalsize);
// Glitz bit :) Displays the given string with a progress bar behind it.
- void display_header(std::string s, int attr);
- void display_status(std::string s, int attr);
+ void display_header(std::wstring s, const attr_t attr);
+ void display_status(std::wstring s, const attr_t attr);
// Make it easier to write interfaces that have a header and status line..
// they do what they say :)
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h Wed Jun 29 19:08:52 2005
@@ -345,8 +345,8 @@
void show_string_as_progbar(int x, int y, std::string s, int attr1, int attr2, int size1, int totalsize) {if(win) win.show_string_as_progbar(x, y, s, attr1, attr2, size1, totalsize);}
- void display_header(std::string s, unsigned int attr) {if(win) win.display_header(s, attr);}
- void display_status(std::string s, unsigned int attr) {if(win) win.display_status(s, attr);}
+ void display_header(std::wstring s, const style &st) {if(win) win.display_header(s, st.get_attrs());}
+ void display_status(std::wstring s, const style &st) {if(win) win.display_status(s, st.get_attrs());}
int erase() {return win?win.erase():0;}
int clear() {return win?win.clear():0;}