~ubuntu-branches/ubuntu/trusty/newsbeuter/trusty-proposed

« back to all changes in this revision

Viewing changes to src/select_formaction.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2008-05-01 14:51:20 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080501145120-i65avsclnrpl2cfq
Tags: 0.9-1
* New upstream release.
  - Fix problem displaying titles when using zh_CN.UTF-8
    locale (Closes: #471434).
* Add default configuration to set sensible-browser as browser and
  add dirs file to create /etc/newsbeuter (Closes: #470833).
* remove libnxml-depends and libmrss-depends calls in rules and
  related dependency lines in control since they are not needed
  anymore (Closes: #467201).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include <formatstring.h>
3
3
#include <view.h>
4
4
#include <config.h>
 
5
#include <utils.h>
 
6
#include <listformatter.h>
5
7
 
6
8
#include <sstream>
7
9
#include <cassert>
24
26
        unsigned int idx = 0;
25
27
        if (1==sscanf(cmd.c_str(),"%u",&idx)) {
26
28
                if (idx > 0 && idx <= ((type == SELECTTAG) ? tags.size() : filters.size())) {
27
 
                        std::ostringstream idxstr;
28
 
                        idxstr << idx - 1;
29
 
                        f->set("tagpos", idxstr.str());
 
29
                        f->set("tagpos", utils::to_s(idx - 1));
30
30
                }
31
31
        } else {
32
32
                formaction::handle_cmdline(cmd);
77
77
 
78
78
void select_formaction::prepare() {
79
79
        if (do_redraw) {
80
 
                std::string code = "{list";
 
80
                listformatter listfmt;
81
81
                unsigned int i=0;
82
82
                switch (type) {
83
83
                case SELECTTAG:
84
84
                        for (std::vector<std::string>::const_iterator it=tags.begin();it!=tags.end();++it,++i) {
85
 
                                std::ostringstream line;
86
 
                                char num[32];
87
 
                                snprintf(num,sizeof(num),"%4d  ", i+1);
88
 
                                std::string tagstr = num;
89
 
                                tagstr.append(it->c_str());
90
 
                                line << "{listitem[" << i << "] text:" << stfl::quote(tagstr.c_str()) << "}";
91
 
                                code.append(line.str());
 
85
                                std::string tagstr = utils::strprintf("%4u  %s", i+1, it->c_str());
 
86
                                listfmt.add_line(tagstr, i);
92
87
                        }
93
88
                        break;
94
89
                case SELECTFILTER:
95
90
                        for (std::vector<filter_name_expr_pair>::const_iterator it=filters.begin();it!=filters.end();++it,++i) {
96
 
                                std::ostringstream line;
97
 
                                char num[32];
98
 
                                snprintf(num,sizeof(num),"%4d  ", i+1);
99
 
                                std::string tagstr = num;
100
 
                                tagstr.append(it->first.c_str());
101
 
                                line << "{listitem[" << i << "] text:" << stfl::quote(tagstr.c_str()) << "}";
102
 
                                code.append(line.str());
 
91
                                std::string tagstr = utils::strprintf("%4u  %s", i+1, it->first.c_str());
 
92
                                listfmt.add_line(tagstr, i);
103
93
                        }
104
94
                        break;
105
95
                default:
106
96
                        assert(0);
107
97
                }
108
 
                code.append("}");
109
 
                f->modify("taglist", "replace_inner", code);
 
98
                f->modify("taglist", "replace_inner", listfmt.format_list());
110
99
                
111
100
                do_redraw = false;
112
101
        }