[Aptitude-svn-commit] r3523 - in branches/aptitude-0.3/aptitude: . src
Daniel Burrows
dburrows@costa.debian.org
Sat, 02 Jul 2005 04:06:26 +0000
Author: dburrows
Date: Sat Jul 2 04:06:24 2005
New Revision: 3523
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/download_list.cc
branches/aptitude-0.3/aptitude/src/download_list.h
Log:
Update the download_list for wide characters.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Jul 2 04:06:24 2005
@@ -1,3 +1,9 @@
+2005-07-02 Daniel Burrows <dburrows@debian.org>
+
+ * src/download_list.cc, src/download_list.h:
+
+ Update the download_list for wide characters.
+
2005-07-01 Daniel Burrows <dburrows@debian.org>
* src/vscreen/curses++.cc, src/vscreen/curses++.h, src/vscreen/vscreen_widget.h:
Modified: branches/aptitude-0.3/aptitude/src/download_list.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.cc (original)
+++ branches/aptitude-0.3/aptitude/src/download_list.cc Sat Jul 2 04:06:24 2005
@@ -19,6 +19,7 @@
#include <vscreen/vs_util.h>
#include <vscreen/config/colors.h>
#include <vscreen/config/keybindings.h>
+#include <vscreen/transcode.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
@@ -28,6 +29,16 @@
using namespace std;
+download_list::workerinf::workerinf(const wstring &_msg, int _current, int _total)
+ :msg(_msg), current(_current), total(_total)
+{
+}
+
+download_list::workerinf::workerinf(const string &_msg, int _current, int _total)
+ :msg(transcode(_msg)), current(_current), total(_total)
+{
+}
+
// FIXME: HACK
static void download_summary_nasty_hack(sigc::slot0<void> cancel_slot)
{
@@ -63,10 +74,11 @@
rval=vs_dialog_ok(fragment, arg(sigc::ptr_fun(vscreen_exitmain)));
else
rval=vs_dialog_yesno(fragment,
- arg(sigc::ptr_fun(vscreen_exitmain)), _("Continue"),
+ arg(sigc::ptr_fun(vscreen_exitmain)),
+ transcode(_("Continue")),
arg(sigc::bind(sigc::ptr_fun(download_summary_nasty_hack),
*cancel_slot)),
- _("Cancel"),
+ transcode(_("Cancel")),
style_attrs_flip(A_REVERSE));
rval->connect_key("PrevPage",
@@ -127,20 +139,17 @@
unsigned int where=start;
int width,height;
const style progress_style=st+get_style("DownloadProgress");
- const int st_attrs=st.get_attrs();
- const int progress_attrs=progress_style.get_attrs();
getmaxyx(height, width);
// Display the completed items
while(y<height-1 && where<msgs.size())
{
const style msg_style=st+msgs[where].second;
- const int msg_attrs=msg_style.get_attrs();
- const string disp(msgs[where].first,
- min<string::size_type>(startx, msgs[where].first.size()));
+ const wstring disp(msgs[where].first,
+ min<wstring::size_type>(startx, msgs[where].first.size()));
show_string_as_progbar(0, y, disp,
- msg_attrs, msg_attrs,
+ msg_style, msg_style,
width, width);
y++;
@@ -161,11 +170,11 @@
if(width1>width)
width1=width;
- string disp(workers[where].msg,
- min<string::size_type>(startx, workers[where].msg.size()));
+ wstring disp(workers[where].msg,
+ min<wstring::size_type>(startx, workers[where].msg.size()));
show_string_as_progbar(0, y, disp,
- progress_attrs, st_attrs,
+ progress_style, st,
width1, width);
y++;
@@ -173,9 +182,9 @@
}
// status line.
- string output="";
+ wstring output=L"";
- output+=_("Total Progress: ");
+ output+=transcode(_("Total Progress: "));
int barsize=0;
@@ -201,14 +210,14 @@
snprintf(progress_string, 50, _(" [ %i%% ]"), int(double((100.0*(CurrentBytes+CurrentItems)))/(TotalBytes+TotalItems)));
- output+=progress_string;
+ output+=transcode(progress_string);
}
show_string_as_progbar(0,
height-1,
output,
- progress_attrs,
- get_style("Status").get_attrs(),
+ progress_style,
+ get_style("Status"),
barsize,
width);
}
@@ -235,7 +244,7 @@
else
{
pkgAcquire::ItemDesc *item=serf->CurrentItem;
- string output=(item->Owner->Status==pkgAcquire::Item::StatFetching)?item->ShortDesc:item->Description+": ";
+ wstring output=transcode((item->Owner->Status==pkgAcquire::Item::StatFetching)?item->ShortDesc:item->Description+": ");
char intbuf[50]; // Waay more than enough.
@@ -244,7 +253,7 @@
SizeToStr(serf->CurrentSize).c_str(),
SizeToStr(serf->TotalSize).c_str());
- output+=intbuf;
+ output+=transcode(intbuf);
workers.push_back(workerinf(output,
serf->CurrentSize,
@@ -262,8 +271,7 @@
bool download_list::MediaChange(string media, string drive,
download_manager &manager)
{
- fragment *f=wrapbox(fragf(
- _("Please insert the disc labeled \"%s\" into the drive \"%s\""),
+ fragment *f=wrapbox(fragf(_("Please insert the disc labeled \"%s\" into the drive \"%s\""),
media.c_str(), drive.c_str()));
vscreen_widget *w=vs_dialog_ok(f, arg(sigc::ptr_fun(vscreen_exitmain)),
@@ -281,7 +289,7 @@
{
if(display_messages)
{
- msgs.push_back(msg(itmdesc.Description+" "+_("[Hit]"),
+ msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[Hit]")),
get_style("DownloadHit")));
sync_top();
@@ -301,7 +309,7 @@
{
if(display_messages)
{
- msgs.push_back(msg(itmdesc.Description+" "+_("[Downloaded]"),
+ msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[Downloaded]")),
get_style("DownloadProgress")));
sync_top();
@@ -321,15 +329,15 @@
// ???
if(itmdesc.Owner->Status==pkgAcquire::Item::StatDone)
- msgs.push_back(msg(itmdesc.Description+" "+_("[IGNORED]"),
+ msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[IGNORED]")),
get_style("DownloadHit")));
else
{
failed=true;
- msgs.push_back(msg(itmdesc.Description+" "+_("[ERROR]"),
+ msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[ERROR]")),
get_style("Error")));
- msgs.push_back(msg(" "+itmdesc.Owner->ErrorText,
+ msgs.push_back(msg(transcode(" "+itmdesc.Owner->ErrorText),
get_style("Error")));
}
@@ -410,26 +418,26 @@
return msgs.size()+workers.size()+1;
}
-bool download_list::handle_char(chtype ch)
+bool download_list::handle_key(const key &k)
{
- if(global_bindings.key_matches(ch, "NextPage"))
+ if(global_bindings.key_matches(k, "NextPage"))
pagedown();
- if(global_bindings.key_matches(ch, "Down"))
+ if(global_bindings.key_matches(k, "Down"))
linedown();
- else if(global_bindings.key_matches(ch, "PrevPage"))
+ else if(global_bindings.key_matches(k, "PrevPage"))
pageup();
- else if(global_bindings.key_matches(ch, "Up"))
+ else if(global_bindings.key_matches(k, "Up"))
lineup();
- else if(global_bindings.key_matches(ch, "Begin"))
+ else if(global_bindings.key_matches(k, "Begin"))
skip_to_top();
- else if(global_bindings.key_matches(ch, "End"))
+ else if(global_bindings.key_matches(k, "End"))
skip_to_bottom();
- else if(global_bindings.key_matches(ch, "Left"))
+ else if(global_bindings.key_matches(k, "Left"))
shift_left();
- else if(global_bindings.key_matches(ch, "Right"))
+ else if(global_bindings.key_matches(k, "Right"))
shift_right();
else
- return vscreen_widget::handle_char(ch);
+ return vscreen_widget::handle_key(k);
return true;
}
@@ -523,13 +531,13 @@
void download_list::shift_right()
{
- string::size_type maxx=0;
+ wstring::size_type maxx=0;
if(display_messages)
- for(vector<string>::size_type n=0; n<msgs.size(); ++n)
+ for(vector<wstring>::size_type n=0; n<msgs.size(); ++n)
maxx=max<int>(maxx, msgs[n].first.size());
- for(vector<string>::size_type n=0; n<workers.size(); ++n)
+ for(vector<wstring>::size_type n=0; n<workers.size(); ++n)
maxx=max<int>(maxx, workers[n].msg.size());
if(startx+8<maxx)
Modified: branches/aptitude-0.3/aptitude/src/download_list.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.h (original)
+++ branches/aptitude-0.3/aptitude/src/download_list.h Sat Jul 2 04:06:24 2005
@@ -22,14 +22,14 @@
// Caches the last-seen info about a worker.
struct workerinf
{
- std::string msg;
+ std::wstring msg;
int current,total;
- workerinf(std::string _msg, int _current, int _total)
- :msg(_msg), current(_current), total(_total) {}
+ workerinf(const std::wstring &_msg, int _current, int _total);
+ workerinf(const std::string &_msg, int _current, int _total);
};
- typedef std::pair<std::string, style> msg;
+ typedef std::pair<std::wstring, style> msg;
// Contains strings paired with attributes.
typedef std::vector<msg> msglist;
@@ -84,7 +84,7 @@
void layout_me();
protected:
void paint(const style &st);
- bool handle_char(chtype ch);
+ bool handle_key(const key &k);
public:
download_list(slot0arg _abortslot=NULL,
bool _display_messages=true);