From 20a87184b1c06f63b2b3d8b9c48a68535b31b4bb Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 17 Nov 2017 11:21:12 +0100 Subject: New mesms --- contactWind.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 contactWind.c (limited to 'contactWind.c') diff --git a/contactWind.c b/contactWind.c new file mode 100644 index 0000000..e496e8a --- /dev/null +++ b/contactWind.c @@ -0,0 +1,91 @@ +#include +#include + +#include "contactWind.h" + +extern contact* contactList; +extern size_t nbContacts; + + +int x_menuContact = 1,y_menuContact = 1; +int w_menuContact,h_menuContact; + +int contactListSelection; +int firstConctactShow; + + +contact* getContactSelected(void) { + return contactListSelection+contactList; +} + + +void selectNextContact(void) { + if( contactListSelection < nbContacts - 1) + contactListSelection++; + clearContactListW(); +} +void selectPreviousContact(void) { + if( contactListSelection > 0) + contactListSelection--; + clearContactListW(); +} + + + +void clearContactListW(void) { + for(int i = firstConctactShow; i < h_menuContact && i < nbContacts; i++) { + move(y_menuContact+i,x_menuContact); + printw("%*s", w_menuContact, " "); + } +} + + +void showContactListW(void) { + + int x = x_menuContact; + int y = y_menuContact; + int w = w_menuContact; + int h = h_menuContact; + int s = nbContacts; + + if( contactListSelection < firstConctactShow ) { + firstConctactShow-=h/2; + if( firstConctactShow < 0 ) + firstConctactShow = 0; + + clearContactListW(); + } + + if( contactListSelection >= firstConctactShow + h ) { + attrset(0 | A_NORMAL ); + firstConctactShow+=h/2; + if( firstConctactShow > nbContacts-1 ) + firstConctactShow = nbContacts-1; + + clearContactListW(); + } + + + int i; + for(i = firstConctactShow ; i < (h+firstConctactShow) && i < s ; i++) { + int color = 0, attr = A_NORMAL; +// if( it[i].opt == 1 ) +// color = COLOR_BLUE+1; + if( contactList[i].conversation ) + attr |= A_BOLD; + if( i == contactListSelection ) { + attr |= A_REVERSE; + } + + attrset( COLOR_PAIR(color) | attr); + move(y,x); + printw("%*s", w, " "); + mvprintc(x,y++,contactList[i].display_name, w); + attrset(0 | A_NORMAL); + } + for( ; i < s ; i++){ // Clear + + } +} + + -- cgit v1.2.3