removed check if in tty if ouput is raw ti fix #110

master
karlstav 10 years ago
parent 3487ca681e
commit 0360e8872e
  1. 35
      cava.c
  2. 4
      output/terminal_bcircle.c
  3. 10
      output/terminal_ncurses.c
  4. 8
      output/terminal_noncurses.c

@ -559,7 +559,7 @@ int main(int argc, char **argv)
int flast[200];
int flastd[200];
int sleep = 0;
int i, n, o, height, h, w, c, rest, inAVirtualConsole, silence, fp, fptest;
int i, n, o, height, h, w, c, rest, inAtty, silence, fp, fptest;
float temp;
double inr[2 * (M / 2 + 1)];
fftw_complex outr[M / 2 + 1][2];
@ -625,15 +625,7 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
n = 0;
}
// Check if we're running in a Virtual console todo: replace virtual console with terminal emulator
inAVirtualConsole = 1;
if (strncmp(ttyname(0), "/dev/tty", 8) == 0 || strcmp(ttyname(0), "/dev/console") == 0) inAVirtualConsole = 0;
if (!inAVirtualConsole) {
system("setfont cava.psf >/dev/null 2>&1");
system("echo yep > /tmp/testing123");
system("setterm -blank 0");
}
@ -645,6 +637,19 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
validate_config();
if (om != 4) {
// Check if we're running in a Virtual console todo: replace virtual console with terminal emulator
inAtty = 0;
if (strncmp(ttyname(0), "/dev/tty", 8) == 0 || strcmp(ttyname(0), "/dev/console") == 0) inAtty = 1;
if (inAtty) {
system("setfont cava.psf >/dev/null 2>&1");
system("echo yep > /tmp/testing123");
system("setterm -blank 0");
}
}
//input: init
audio.format = -1;
audio.rate = 0;
@ -740,10 +745,8 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
//output: start ncurses mode
if (om == 1 || om == 2) {
init_terminal_ncurses(col, bgcol);
get_terminal_dim_ncurses(&w, &h);
}
// output: get terminal's geometry
if (om == 1 || om == 2) get_terminal_dim_ncurses(&w, &h);
#endif
if (om == 3) get_terminal_dim_noncurses(&w, &h);
@ -1065,16 +1068,16 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
switch (om) {
case 1:
#ifdef NCURSES
rc = draw_terminal_ncurses(inAVirtualConsole, h, w, bars, bw, bs, rest, f, flastd);
rc = draw_terminal_ncurses(inAtty, h, w, bars, bw, bs, rest, f, flastd);
break;
#endif
case 2:
#ifdef NCURSES
rc = draw_terminal_bcircle(inAVirtualConsole, h, w, f);
rc = draw_terminal_bcircle(inAtty, h, w, f);
break;
#endif
case 3:
rc = draw_terminal_noncurses(inAVirtualConsole, h, w, bars, bw, bs, rest, f, flastd);
rc = draw_terminal_noncurses(inAtty, h, w, bars, bw, bs, rest, f, flastd);
break;
case 4:
rc = print_raw_out(bars, fp, is_bin, bit_format, ascii_range, bar_delim, frame_delim,f);

@ -36,12 +36,12 @@ void get_terminal_dim_bcircle(int *w, int *h) {
}
int draw_terminal_bcircle(int virt, int h, int w, int f[200]) {
int draw_terminal_bcircle(int tty, int h, int w, int f[200]) {
const wchar_t* bars[] = {L"\u2581", L"\u2582", L"\u2583", L"\u2584", L"\u2585", L"\u2586", L"\u2587", L"\u2588"};
// output: check if terminal has been resized
if (virt != 0) {
if (!tty) {
if ( LINES != h || COLS != w) {
return -1;
}

@ -30,13 +30,13 @@ void get_terminal_dim_ncurses(int *w, int *h) {
}
int draw_terminal_ncurses(int virt, int h, int w, int bars, int bw, int bs, int rest, int f[200], int flastd[200]) {
int draw_terminal_ncurses(int tty, int h, int w, int bars, int bw, int bs, int rest, int f[200], int flastd[200]) {
int i, n, q;
const wchar_t* bh[] = {L"\u2581", L"\u2582", L"\u2583", L"\u2584", L"\u2585", L"\u2586", L"\u2587", L"\u2588"};
// output: check if terminal has been resized
if (virt != 0) {
if (!tty) {
if ( LINES != h || COLS != w) {
return -1;
}
@ -47,16 +47,16 @@ int draw_terminal_ncurses(int virt, int h, int w, int bars, int bw, int bs, int
for (i = 0; i < bars; i++) {
if(f[i] > flastd[i]){//higher then last one
if (virt == 0) for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvprintw((h - n), i*bw + q + i*bs + rest, "%d",8);
if (tty) for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvprintw((h - n), i*bw + q + i*bs + rest, "%d",8);
else for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvaddwstr((h - n), i*bw + q + i*bs + rest, bh[7]);
if (f[i] % 8 != 0) {
if (virt == 0) for (q = 0; q < bw; q++) mvprintw( (h - n), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
if (tty) for (q = 0; q < bw; q++) mvprintw( (h - n), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
else for (q = 0; q < bw; q++) mvaddwstr( (h - n), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
}
}else if(f[i] < flastd[i]){//lower then last one
for (n = f[i] / 8; n < flastd[i]/8 + 1; n++) for (q = 0; q < bw; q++) mvaddstr( (h - n), i*bw + q + i*bs + rest, " ");
if (f[i] % 8 != 0) {
if (virt == 0) for (q = 0; q < bw; q++) mvprintw((h - f[i] / 8), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
if (tty) for (q = 0; q < bw; q++) mvprintw((h - f[i] / 8), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
else for (q = 0; q < bw; q++) mvaddwstr((h - f[i] / 8), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
}
}

@ -105,14 +105,14 @@ void get_terminal_dim_noncurses(int *w, int *h) {
}
int draw_terminal_noncurses(int virt, int h, int w, int bars, int bw, int bs, int rest, int f[200], int flastd[200]) {
int draw_terminal_noncurses(int tty, int h, int w, int bars, int bw, int bs, int rest, int f[200], int flastd[200]) {
int c, move, n, o;
struct winsize dim;
// output: check if terminal has been resized
if (virt != 0) {
if (!tty) {
ioctl(STDOUT_FILENO, TIOCGWINSZ, &dim);
@ -142,11 +142,11 @@ int draw_terminal_noncurses(int virt, int h, int w, int bars, int bw, int bs, in
else move += bw;
} else if (c > 7) {
if (n > flastd[o] / 8 - 1) {
if (virt == 0) printf("%d", ttybarstring[7]); // block tty
if (tty) printf("%d", ttybarstring[7]); // block tty
else printf("%ls", barstring[0]); //block
} else move += bw;
} else {
if (virt == 0) printf("%d", ttybarstring[c - 1]); // fractioned block tty
if (tty) printf("%d", ttybarstring[c - 1]); // fractioned block tty
else printf("%ls", barstring[c] ); // fractioned block vt
}

Loading…
Cancel
Save