aboutsummaryrefslogtreecommitdiff
path: root/contactWind.c
diff options
context:
space:
mode:
authorache <ache@ache.one>2017-11-17 11:21:12 +0100
committerache <ache@ache.one>2017-11-17 11:21:12 +0100
commit20a87184b1c06f63b2b3d8b9c48a68535b31b4bb (patch)
treee3ad5a41ac00d71ef95bd58fd1c4d4bf3eaa07a7 /contactWind.c
parentNumber to contact option (diff)
New mesms
Diffstat (limited to 'contactWind.c')
-rw-r--r--contactWind.c91
1 files changed, 91 insertions, 0 deletions
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 <stdlib.h>
+#include <stdio.h>
+
+#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
+
+ }
+}
+
+