Skip to content

Commit

Permalink
eliminados varios refrescos innecesarios
Browse files Browse the repository at this point in the history
  • Loading branch information
canuconde committed Dec 5, 2024
1 parent 048ec17 commit 9e85acd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ EQ for Moc is a terminal application to c and edit EQSET equalization files used

on debian like distro :

apt install mocp
apt install moc

* ncurses6 (v 6.4.20221231)

Expand Down
13 changes: 13 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* Mejorar el código de reescalado. Cada vez que se reescala el terminal recreamos todas las ventanas (esto no es bueno).-
* Limpiar todo el código repetido y pasar las cosas de C a C++.-
* Implementar el refresco en MOC. Haciendole un echo al stdin provoca que moc se enoje.-
* Permitir que el usuario cambie un tema por linea de comando
* Agregar la opción de "Guardar como" (buscar dialogs en ncurses)

/------------------------------------------------------------/

* Improve rescaling code. Every time the terminal is rescaled we recreate all windows (this is not good).-
* Clean up all the duplicate code and move things from C to C++.-
* Implement refresh in MOC. Echoing stdin makes moc angry.-
* Allow user to change theme via command line
* ​​Add "Save As" option (search dialogs in ncurses)
26 changes: 14 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// If not, see <https://www.gnu.org/licenses/>.

#define PACKAGE_NAME "eq4moc - EQ for MOC"
#define PACKAGE_VERSION 0.9

#define PACKAGE_VERSION "0.9.1"
#include <ncurses.h>
#include <string>
#include <iostream>
Expand Down Expand Up @@ -136,7 +135,7 @@ int main(int argc, char *argv[])
col_starty=2;
col_startx=width*1/10; //la decima parte del disply
for(int i=0;i<10;i++){
control[i] = create_eqbar(col_height, col_width, col_starty , col_startx*i+col_startx/2,
control[i] = create_eqbar(col_height, col_width, col_starty , col_startx*i+col_startx/3,
band_freq[i], eqSets[selectedeq].getbandvalue(i+1) );
}

Expand Down Expand Up @@ -175,12 +174,13 @@ int main(int argc, char *argv[])
case 'S':
eqSets[selectedeq].save();
break;
case KEY_RESIZE:
case 'e':
case 'E':
//system("echo 'e' | mocp &"); <-- TODO: NO borrar esto!!! lo necesitamos para refrescar moc
for(int i=0;i<10;i++){
destroy_win(control[i]);

}
break;
case KEY_RESIZE:
// Estoy seguro que hay una mejor manera de reescalar todo sin tener que destruir y volver a crear las ventanas
// TODO Investigar esto
destroy_win(main_win);
height = LINES;
width = COLS;
Expand All @@ -190,12 +190,13 @@ int main(int argc, char *argv[])
col_height=height-5;
col_width=5;
col_starty=2;
col_startx=width*1/10; //la decima parte del display
col_startx=width*1/10;
for(int i=0;i<10;i++){
// destroy_win(control[i]); <-- TODO v. seg.
control[i] = create_eqbar(col_height, col_width, col_starty , col_startx*i+col_startx/2,
band_freq[i], eqSets[selectedeq].getbandvalue(i+1) );
destroy_win(control[i]);
control[i] = create_eqbar(col_height, col_width, col_starty , col_startx*i+col_startx/3,
band_freq[i], eqSets[selectedeq].getbandvalue(i+1) );
}

break;
case '\t':
selectedeq++;
Expand All @@ -219,6 +220,7 @@ int main(int argc, char *argv[])
wattroff(control[selected], A_BLINK | A_REVERSE );
clean_window(main_win);
update_window(main_win,eqSets[selectedeq],ex_band_freq[selected],eqSets[selectedeq].getbandvalue(selected+1));

}
endwin();
return 0;
Expand Down
7 changes: 2 additions & 5 deletions src/ncFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ WINDOW *create_eqbar(int height, int width, int starty, int startx,const string
wattron(local_win,COLOR_PAIR(4) | A_BOLD );
mvwprintw(local_win,1,1,label.data());
wattroff(local_win,COLOR_PAIR(4) | A_BOLD );
update_control(local_win,value);
box(local_win, 0, 0);
update_control(local_win,value);
// mvwhline(local_win,2, 1, 0,3); // Linea en y=2 x=0 de tipo 0 (defecto) y longitud 3
wrefresh(local_win);
return local_win;
}

Expand All @@ -58,7 +57,6 @@ WINDOW *create_mainwin(int height, int width, int starty, int startx,eqSet &loca
wattroff(local_win, COLOR_PAIR(1) | A_BOLD );
wprintw(local_win,"|");
update_window(local_win,local_eqSet);
wrefresh(local_win);
return local_win;
}

Expand Down Expand Up @@ -171,6 +169,5 @@ void clean_control(WINDOW *local_win){
}

void destroy_win(WINDOW *local_win){
wrefresh(local_win);
delwin(local_win);
delwin(local_win);
}

0 comments on commit 9e85acd

Please sign in to comment.