#include #include #include #include // exit() WINDOW *create_newwin(int height, int width, int starty, int startx); int portada (int maxy, int maxx); int main(int argc, char **argv) { initscr(); // inicio ncurses cbreak(); // Opciones de CTRL a terminal, no a programa keypad (stdscr,TRUE); int maxy,maxx; getmaxyx(stdscr, maxy, maxx); WINDOW *win = create_newwin(0,0,0,0); int n ; n = portada(maxy,maxx); if (n!=0) { cout << "Error en portada()" << endl ; exit (1); }; //WINDOW *win1 = create_newwin(0,0,0,0); cout << "fuera de ncurses, (c) by " << endl; endwin (); // fin ncurses return 0; } WINDOW *create_newwin(int height, int width, int starty, int startx) { WINDOW *local_win; local_win = newwin(height, width, starty, startx); box(local_win, 0 , 0); /* 0, 0 gives default characters * for the vertical and horizontal * lines */ wrefresh(local_win); /* Show that box */ return local_win; } int portada (int maxy, int maxx) //Should put titulo, autor and anio centered { char titulo[]="Ncurses Bug v0.1"; char autor[]="(c) by Anonymous"; char anio[]="2002"; int ancho; if (strlen(titulo)>strlen(autor)) if (strlen(titulo)>strlen(anio)) { ancho = strlen(titulo); mvprintw(maxy/2,(maxx-ancho)/2,"%s",titulo); } else if (strlen(autor)>strlen(anio)) { ancho = strlen(autor); mvprintw(maxy/2,(maxx-ancho)/2,"%s",autor); } else { ancho = strlen (anio); mvprintw(maxy/2,(maxx-ancho)/2,"%s",anio);} //getch(); return 0; }