diff options
Diffstat (limited to 'wind.c')
-rw-r--r-- | wind.c | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -15,7 +15,35 @@ 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; @@ -58,16 +86,15 @@ void runtimeHelp(void) { clear(); } -int confirmSend(char* txt, char* autheur) { +int confirmSend(const char* txt, const char* autheur) { int x = COLS/6; - int y = LINES/3; - - int w = COLS*2/3; - int h = LINES/3; + int w = (COLS*2)/3; + int nbLignes = showMessagePreview(x, 0, w, txt, 0); + int y = (LINES - nbLignes - 2) / 2; clear(); move(y,x); - printw("Voulez-vous vraiment envoyé ce SMS à %s ?", autheur); + printw("Voulez-vous vraiment envoyé ce SMS de %d ligne%s à %s ?", nbLignes, nbLignes > 1 ? "s":"", autheur); y++; move(y,x); |