/* * Ache - 2017-08-14 - GPLv3 */ #include "wind.h" /* Managed windows */ extern int w_menuContact,h_menuContact; extern int x_WMessage,y_WMessage; extern int w_WMessage,h_WMessage; static short my_fg = COLOR_WHITE; static short my_bg = COLOR_BLACK; //extern char status[10]; extern WINDOW *cmd_win; //extern WINDOW *sep_win; // int showMessagePreview(int x, int y, int w, const char* txt, char onlyCount) { char line[w]; memset(line, 0, w); int X = 0, Y=0, iS= 0; while( txt[iS] ) { X = 0; while( X < w-1 && txt[iS]) { if( txt[iS] == '\n' ) { iS++; break; } line[X++] = txt[iS++]; } line[X] = 0; if( Y+1 >= h_WMessage -1 ) { break; } Y++; if( onlyCount ) { move(Y+y, x+2); printw("%s", line); } } return Y; } void resize() { h_menuContact = LINES-2; w_menuContact = COLS/5-1; x_WMessage = w_menuContact + 2; y_WMessage = 1; w_WMessage = (4*COLS)/5-2; h_WMessage = LINES-2; clear(); showContactListW(); move(1, x_WMessage-1); vline(ACS_VLINE, h_menuContact); showMessageWind(); cmd_win_redisplay(true); CHECK(doupdate); move(LINES-1, 1); } void runtimeHelp(void) { int x = COLS/8; int y = LINES/7; int w = COLS*2/7; int h = LINES/7; clear(); move(y,x); printw("This is the help"); y+=2; move(y,0); printw(RUNTIME_HELP_STRING); move(LINES*6/7,x); printw("Type h or q to exit"); int c = 0; while( (c = getch()) && c != EOF && !strchr("hHqQ", c) ) ; clear(); } void showConfirmSend(const char* txt, const char* autheur) { int x = COLS/6; int w = (COLS*2)/3; int nbLignes = showMessagePreview(x, 0, w, txt, 0); int y = (LINES - nbLignes - 2) / 2; clear(); refresh(); move(y,x); printw("Voulez-vous vraiment envoyé ce SMS de %d ligne%s à %s ?", nbLignes, nbLignes > 1 ? "s":"", autheur); y++; move(y,x); { char line[w]; memset(line, 0, w); int X = 0, Y=0, iS= 0; while( txt[iS] ) { X = 0; while( X < w-1 && txt[iS]) { if( txt[iS] == '\n' ) { iS++; break; } line[X++] = txt[iS++]; } line[X] = 0; if( Y+1 >= h_WMessage -1 ) { break; } Y++; move(Y+y, x+2); printw("%s", line); } } } int confirmSend(const char* txt, const char* autheur) { showConfirmSend(txt, autheur); int c = 0; while( (c = getch()) && c != EOF && !strchr("oyneqOYNEQ", c) ) { if (c == KEY_RESIZE) { showConfirmSend(txt, autheur); refresh(); continue; } } clear(); return (c == 'e' || c =='E') ? 2 : (!!strchr("yYoO", c)) ; }