mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Change multiple spaces in -s when out_to_http is used
This commit is contained in:
parent
e7eae4ec8f
commit
7a2e292429
21
src/conky.cc
21
src/conky.cc
@ -1173,6 +1173,17 @@ static inline void set_foreground_color(long c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string string_replace_all(std::string original, std::string oldpart, std::string newpart, std::string::size_type start) {
|
||||||
|
std::string::size_type i = start;
|
||||||
|
int oldpartlen = oldpart.length();
|
||||||
|
while(1) {
|
||||||
|
i = original.find(oldpart, i);
|
||||||
|
if(i == std::string::npos) break;
|
||||||
|
original.replace(i, oldpartlen, newpart);
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
static void draw_string(const char *s)
|
static void draw_string(const char *s)
|
||||||
{
|
{
|
||||||
int i, i2, pos, width_of_s;
|
int i, i2, pos, width_of_s;
|
||||||
@ -1213,13 +1224,11 @@ static void draw_string(const char *s)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_HTTP
|
#ifdef BUILD_HTTP
|
||||||
if ((output_methods & TO_HTTP) && draw_mode == FG) {
|
if ((output_methods & TO_HTTP) && draw_mode == FG) {
|
||||||
std::string::size_type i = webpage.length();
|
std::string::size_type origlen = webpage.length();
|
||||||
webpage.append(s_with_newlines);
|
webpage.append(s_with_newlines);
|
||||||
while(1) {
|
webpage = string_replace_all(webpage, "\n", "<br />", origlen);
|
||||||
i = webpage.find('\n', i);
|
webpage = string_replace_all(webpage, " ", " ", origlen);
|
||||||
if(i == std::string::npos) break;
|
webpage = string_replace_all(webpage, " ", " ", origlen);
|
||||||
webpage.replace(i, 1, "<br />");
|
|
||||||
}
|
|
||||||
webpage.append("<br />");
|
webpage.append("<br />");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user