1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

Created a function to call bars in shell (not only execbar)

TODO use this function in other places
This commit is contained in:
Nikolas Garofil 2009-06-01 02:23:47 +02:00
parent c91e2ed38e
commit c3df719716
3 changed files with 25 additions and 17 deletions

View File

@ -3940,7 +3940,6 @@ static void generate_text_internal(char *p, int p_max_size,
#endif #endif
OBJ(execbar) { OBJ(execbar) {
double barnum; double barnum;
int i = 0, j = 0;
read_exec(obj->data.s, p, text_buffer_size); read_exec(obj->data.s, p, text_buffer_size);
barnum = get_barnum(p); barnum = get_barnum(p);
@ -3953,22 +3952,7 @@ static void generate_text_internal(char *p, int p_max_size,
}else{ }else{
#endif #endif
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X; if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
barnum = round_to_int( ( barnum * obj->a ) / 100); new_bar_in_shell(p, p_max_size, barnum, obj->a);
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif /* HAVE_OPENMP */
for(i=0; i<(int)barnum; i++) {
*(p+i)='#';
}
/* gcc seems to think i is not initialized properly :/ */
j = i;
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif /* HAVE_OPENMP */
for(i = j/* cheats */; i < obj->a; i++) {
*(p+i)='_';
}
*(p+i)=0;
#ifdef X11 #ifdef X11
} }
#endif #endif

View File

@ -380,6 +380,29 @@ void new_bg(char *buf, long c)
} }
#endif #endif
void new_bar_in_shell(char* buffer, int buf_max_size, double usage, int width)
{
if(width<=buf_max_size){
int i = 0, j = 0, scaledusage = round_to_int( usage * width / 100);
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif /* HAVE_OPENMP */
for(i=0; i<(int)scaledusage; i++) {
*(buffer+i)='#';
}
/* gcc seems to think i is not initialized properly :/ */
j = i;
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif /* HAVE_OPENMP */
for(i = j/* cheats */; i < width; i++) {
*(buffer+i)='_';
}
*(buffer+i)=0;
}
}
void new_outline(char *buf, long c) void new_outline(char *buf, long c)
{ {
new_special(buf, OUTLINE)->arg = c; new_special(buf, OUTLINE)->arg = c;

View File

@ -105,6 +105,7 @@ void new_graph(char *, int, int, unsigned int,
void new_hr(char *, int); void new_hr(char *, int);
void new_stippled_hr(char *, int, int); void new_stippled_hr(char *, int, int);
#endif #endif
void new_bar_in_shell(char *, int, double, int);
void new_fg(char *, long); void new_fg(char *, long);
void new_bg(char *, long); void new_bg(char *, long);
void new_outline(char *, long); void new_outline(char *, long);