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); |
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 |
|
} |
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); |
75 |
|
|
76 |
|
::asprintf(×, "%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 |
|
{ |
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 }; |
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 |
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 |
|
|