diff --git a/.travis.yml b/.travis.yml index 3c2a7c768..9348b3faf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ addons: - liblua5.1-0-dev - libtolua++5.1-dev - libcairo2-dev - - libxinerama-dev - gawk before_script: - mkdir build && cd build && cmake .. && cd .. diff --git a/AUTHORS b/AUTHORS index 09bc0a583..6709d6b3b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,9 +15,6 @@ Adi Zaimi Alex Iconv patch -Alexey Bondarenko - $scroll fix - affinity X-Mozilla-Status support diff --git a/src/conky.cc b/src/conky.cc index 444d12f69..6522ce1d3 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -562,7 +562,7 @@ static bool isutf8(const char* envvar) { } /* UTF-8 */ -conky::simple_config_setting utf8_mode("override_utf8_locale", +static conky::simple_config_setting utf8_mode("override_utf8_locale", isutf8("LC_ALL") || isutf8("LC_CTYPE") || isutf8("LANG"), false); #endif /* BUILD_X11 */ diff --git a/src/conky.h b/src/conky.h index a545a00c0..38c37ab06 100644 --- a/src/conky.h +++ b/src/conky.h @@ -322,12 +322,6 @@ void generate_text_internal(char *, int, struct text_object); int percent_print(char *, int, unsigned); void human_readable(long long, char *, int); -#ifdef BUILD_X11 - -/* UTF-8 */ -extern conky::simple_config_setting utf8_mode; -#endif - /* maximum size of config TEXT buffer, i.e. below TEXT line. */ extern conky::range_config_setting max_user_text; diff --git a/src/luamm.hh b/src/luamm.hh index 3898d4f33..8973e95f9 100644 --- a/src/luamm.hh +++ b/src/luamm.hh @@ -28,7 +28,6 @@ #include #include #include -#include #include diff --git a/src/scroll.cc b/src/scroll.cc index a03c22a15..0f1b4fef5 100644 --- a/src/scroll.cc +++ b/src/scroll.cc @@ -35,48 +35,6 @@ #include "x11.h" #include -/** - * Length of a character in bytes. - * @param c first byte of the character - */ -inline int scroll_character_length(char c) { -#ifdef BUILD_X11 - if (utf8_mode.get(*state)) { - unsigned char uc = (unsigned char) c; - int len = 0; - - if (c == -1) - return 1; - - if ((uc & 0x80) == 0) - return 1; - - while (len < 7 && (uc & (0x80 >> len)) != 0) - ++len; - - return len; - } -#endif - - return 1; -} - -/** - * Check if a byte should be skipped when counting characters to scroll text to right. - */ -inline bool scroll_check_skip_byte(char c) { -#ifdef BUILD_X11 - if (utf8_mode.get(*state)) { - // Check if byte matches UTF-8 continuation byte pattern (0b10xxxxxx) - if ((c & 0xC0) == 0x80) { - return true; - } - } -#endif - - return SPECIAL_CHAR == c; -} - #define SCROLL_LEFT 1 #define SCROLL_RIGHT 2 #define SCROLL_WAIT 3 @@ -92,45 +50,6 @@ struct scroll_data { int direction; }; -/** - * Get count of characters to right from (sd->start) position. - */ -static unsigned int scroll_count_characters_to_right(struct scroll_data* sd, const std::vector& buf) { - unsigned int n = 0; - int offset = sd->start; - - while ('\0' != buf[offset] && offset < buf.size()) { - offset += scroll_character_length(buf[offset]); - ++n; - } - - return n; -} - -static void scroll_scroll_left(struct scroll_data* sd, const std::vector& buf, unsigned int amount) { - for (int i = 0; (i < amount) && (buf[sd->start] != '\0') && (sd->start < buf.size()); ++i) { - sd->start += scroll_character_length(buf[sd->start]); - } - - if (buf[sd->start] == 0 || sd->start > strlen(buf.data())) { - sd->start = 0; - } -} - -static void scroll_scroll_right(struct scroll_data* sd, const std::vector& buf, unsigned int amount) { - for (int i = 0; i < amount; ++i) { - if (sd->start <= 0) { - sd->start = (int) strlen(&(buf[0])); - } - - while (--(sd->start) >= 0) { - if (!scroll_check_skip_byte(buf[sd->start])) { - break; - } - } - } -} - void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_crash, char *free_at_crash2) { struct scroll_data *sd; @@ -203,9 +122,8 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size) { struct scroll_data *sd = (struct scroll_data *)obj->data.opaque; unsigned int j, colorchanges = 0, frontcolorchanges = 0, visibcolorchanges = 0, strend; - unsigned int visiblechars = 0; char *pwithcolors; - std::vector buf(max_user_text.get(*state), (char) 0); + std::vector buf(max_user_text.get(*state)); if (!sd) return; @@ -227,38 +145,20 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size) snprintf(p, p_max_size, "%s", &(buf[0])); return; } - //if length of text changed to shorter so the (sd->start) is already - //outside of actual text then reset (sd->start) - if (sd->start >= strlen(&(buf[0]))) { - sd->start = 0; - } //make sure a colorchange at the front is not part of the string we are going to show while(buf[sd->start] == SPECIAL_CHAR) { sd->start++; } //place all chars that should be visible in p, including colorchanges - for(j=0, visiblechars=0; visiblechars < sd->show;) { - char c = p[j] = buf[sd->start + j]; - if (0 == c) { - break; - } - - ++j; - - if (SPECIAL_CHAR == c) { - ++visibcolorchanges; - } else { - int l = scroll_character_length(c); - - while (--l) { - p[j] = buf[sd->start + j]; - ++j; - } - - ++visiblechars; - } + for(j=0; j < sd->show + visibcolorchanges; j++) { + p[j] = buf[sd->start + j]; + if(p[j] == SPECIAL_CHAR) { + visibcolorchanges++; + } + //if there is still room fill it with spaces + if( ! p[j]) break; } - for(; visiblechars < sd->show; j++, visiblechars++) { + for(; j < sd->show + visibcolorchanges; j++) { p[j] = ' '; } p[j] = 0; @@ -282,11 +182,14 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size) free(pwithcolors); //scroll if(sd->direction == SCROLL_LEFT) { - scroll_scroll_left(sd, buf, sd->step); + sd->start += sd->step; + if(buf[sd->start] == 0 || (unsigned) sd->start > strlen(&(buf[0]))) { + sd->start = 0; + } } else if(sd->direction == SCROLL_WAIT) { - unsigned int charsleft = scroll_count_characters_to_right(sd, buf); + size_t len = strlen(&buf[0]); - if(sd->show >= charsleft) { + if(sd->start >= len || sd->show + sd->start >= len) { if (sd->wait_arg && (--sd->wait <= 0 && sd->wait_arg != 1)) { sd->wait = sd->wait_arg; } else { @@ -296,16 +199,17 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size) if(!sd->wait_arg || sd->wait_arg == 1 || (sd->wait_arg && sd->wait-- <= 0)) { sd->wait = 0; + sd->start += sd->step; - if (sd->step < charsleft) { - scroll_scroll_left(sd, buf, sd->step); - } else { - scroll_scroll_left(sd, buf, charsleft); - } + if (sd->start + sd->show >= len) + sd->start = len - sd->show; } } } else { - scroll_scroll_right(sd, buf, sd->step); + if(sd->start < 1) { + sd->start = strlen(&(buf[0])); + } + sd->start -= sd->step; } #ifdef BUILD_X11 //reset color when scroll is finished