mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +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:
parent
c91e2ed38e
commit
c3df719716
18
src/conky.c
18
src/conky.c
@ -3940,7 +3940,6 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
#endif
|
||||
OBJ(execbar) {
|
||||
double barnum;
|
||||
int i = 0, j = 0;
|
||||
|
||||
read_exec(obj->data.s, p, text_buffer_size);
|
||||
barnum = get_barnum(p);
|
||||
@ -3953,22 +3952,7 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
}else{
|
||||
#endif
|
||||
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
|
||||
barnum = round_to_int( ( barnum * obj->a ) / 100);
|
||||
#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;
|
||||
new_bar_in_shell(p, p_max_size, barnum, obj->a);
|
||||
#ifdef X11
|
||||
}
|
||||
#endif
|
||||
|
@ -380,6 +380,29 @@ void new_bg(char *buf, long c)
|
||||
}
|
||||
#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)
|
||||
{
|
||||
new_special(buf, OUTLINE)->arg = c;
|
||||
|
@ -105,6 +105,7 @@ void new_graph(char *, int, int, unsigned int,
|
||||
void new_hr(char *, int);
|
||||
void new_stippled_hr(char *, int, int);
|
||||
#endif
|
||||
void new_bar_in_shell(char *, int, double, int);
|
||||
void new_fg(char *, long);
|
||||
void new_bg(char *, long);
|
||||
void new_outline(char *, long);
|
||||
|
Loading…
Reference in New Issue
Block a user