ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/DashInterface.cpp
(Generate patch)

Comparing DashInterface/DashInterface.cpp (file contents):
Revision 41 by douglas, 2008-03-06T02:41:40-08:00 vs.
Revision 42 by douglas, 2008-03-06T13:04:20-08:00

# Line 23 | Line 23
23   #include <sys/sysctl.h>
24   #include <sys/utsname.h>
25  
26 #include <sqlite3.h>
27
26   #include "Display.hpp"
27  
28   bool debug(false);
# Line 46 | Line 44 | class DashInterface
44          {
45                  std::string output(ascii.Convert(input));
46  
47 <                std::replace(output.begin(), output.end(), '~', char(206));
47 >                std::replace(output.begin(), output.end(), '~', '\xce');
48  
49                  return output;
50          }
# Line 63 | Line 61 | class DashInterface
61                                  int position(audacious.GetPlaylistPosition());
62                                  std::string artist(Filter(audacious.GetTupleFieldData(_B("artist"), position)));
63  
64 <                                display.Set(0, 1, artist.size() > 20 ? artist.erase(20) : artist.append(20 - artist.size(), ' '));
64 >                                artist.resize(20, ' ');
65 >                                display.Set(0, 1, artist);
66  
67                                  std::string title(Filter(audacious.GetTupleFieldData(_B("title"), position)));
68  
69 <                                display.Set(0, 2, title.size() > 20 ? title.erase(20) : title.append(20 - title.size(), ' '));
69 >                                title.resize(20, ' ');
70 >                                display.Set(0, 2, title);
71  
72                                  int played(audacious.GetOutputTime() / 1000);
73                                  int left(audacious.GetPlaylistTime(position) / 1000 - played);
# Line 75 | Line 75 | class DashInterface
75  
76                                  ::asprintf(&times, "%2i:%02i -%2i:%02i", played / 60, played % 60, left / 60, left % 60);
77  
78 <                                display.Set(0, 3, times + std::string(20 - std::strlen(times), ' '));
78 >                                std::string times_(times);
79  
80                                  std::free(times);
81 +
82 +                                times_.resize(20, ' ');
83 +                                display.Set(0, 3, times_);
84                          }
85                          else
86                          {
# Line 113 | Line 116 | class DashInterface
116                          Pcre::RegEx::Match match(version(os.release));
117                          std::string name(os.sysname + _B(" ") + match[1] + match[2] + match[3]);
118  
119 <                        display.Set(0, 1, name.append(20 - name.size(), ' '));
119 >                        name.resize(20, ' ');
120 >                        display.Set(0, 1, name);
121                  }
122  
123                  int mib[] = { CTL_KERN, KERN_BOOTTIME };
# Line 142 | Line 146 | class DashInterface
146  
147                          std::string then(when);
148  
145                        then.append(17 - std::strlen(when), ' ');
146
149                          std::free(when);
150  
151 +                        then.resize(17, ' ');
152 +
153                          if (change)
154                                  display.Set(0, 2, _B("up ") + then);
155                          else
# Line 164 | Line 168 | class DashInterface
168  
169                          ::asprintf(&load, "%.2f, %.2f, %.2f", averages[0], averages[1] , averages[2]);
170  
171 <                        display.Set(0, 3, load + std::string(20 - std::strlen(load), ' '));
171 >                        std::string load_(load);
172  
173                          std::free(load);
174 +
175 +                        load_.resize(20, ' ');
176 +                        display.Set(0, 3, load_);
177                  }
178          }
179  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines