1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

alignment fixes

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@200 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-27 04:55:48 +00:00
parent 1ce64d3681
commit 7542bd4123
2 changed files with 49 additions and 12 deletions

View File

@ -3,6 +3,7 @@
2005-08-26 2005-08-26
* Fixed slight vertical misalignment of bars/graphs (sf.net 1273994) * Fixed slight vertical misalignment of bars/graphs (sf.net 1273994)
* Diskio fixes (sf.net 1274140) * Diskio fixes (sf.net 1274140)
* $alignr and $alignc now have 25% more goodness!
2005-08-25 2005-08-25
* More own_window fixes * More own_window fixes

View File

@ -839,7 +839,7 @@ struct text_object {
struct net_stat *net; struct net_stat *net;
struct fs_stat *fs; struct fs_stat *fs;
unsigned char loadavg[3]; unsigned char loadavg[3];
unsigned int diskio; //unsigned int diskio;
struct { struct {
struct fs_stat *fs; struct fs_stat *fs;
@ -2791,6 +2791,41 @@ static inline int get_string_width(const char *s)
#endif /* X11 */ #endif /* X11 */
} }
static inline int get_string_width_special(char *s)
{
if (!s) {
return 0;
}
#ifdef X11
char *p, *final;
p = strdup(s);
final = p;
int index = 1;
int width = 0;
unsigned int i;
while (*p) {
if (*p == SPECIAL_CHAR) {
/* shift everything over by 1 */
for (i = 0; i < strlen(p); i++) {
*(p + i) = *(p + i + 1);
}
if (specials[special_index+index].type == GRAPH || specials[special_index+index].type == BAR) {
width += specials[special_index+index].width;
}
index++;
} else {
p++;
}
}
if (strlen(final) > 1) {
width += calc_text_width(final, strlen(final));
}
return width;
#else
return strlen(s);
#endif /* X11 */
}
int fontchange = 0; int fontchange = 0;
#ifdef X11 #ifdef X11
@ -3393,8 +3428,8 @@ static void draw_line(char *s)
case ALIGNR: case ALIGNR:
{ {
int pos_x = text_width + gap_x - get_string_width(p) /*- border_margin*2 - 1*/; int pos_x = text_start_x + text_width - get_string_width_special(s) /*+ border_margin*/;
/*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(p), gap_x, specials[special_index].arg, border_margin, border_width);*/ /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width_special(s), gap_x, specials[special_index].arg, border_margin, border_width);*/
if (pos_x > specials[special_index].arg && pos_x > cur_x) { if (pos_x > specials[special_index].arg && pos_x > cur_x) {
cur_x = pos_x - specials[special_index].arg; cur_x = pos_x - specials[special_index].arg;
} }
@ -3403,8 +3438,9 @@ static void draw_line(char *s)
case ALIGNC: case ALIGNC:
{ {
int pos_x = (text_width)/2 - get_string_width(p)/2 - (cur_x - text_start_x); int pos_x = (text_width)/2 - get_string_width_special(s)/2 - (cur_x - text_start_x);
/*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(p), gap_x, specials[special_index].arg);*/ /*int pos_x = text_start_x + text_width/2 - get_string_width_special(s)/2;*/
/*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(s), gap_x, specials[special_index].arg);*/
if (pos_x > if (pos_x >
specials[special_index].arg) specials[special_index].arg)
w = pos_x - w = pos_x -