1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#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;
int showName = 1;
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( contactList[i].conversation )
attr |= A_BOLD;
if( i == contactListSelection ) {
attr |= A_REVERSE;
}
attrset( COLOR_PAIR(color) | attr);
move(y,x);
printw("%*s", w, " ");
if( showName )
mvprintc(x,y++,contactList[i].display_name, w);
else
mvprintc(x,y++,contactList[i].number, w);
attrset(0 | A_NORMAL);
}
for( ; i < (h+firstConctactShow) ; i++){ // Clear
move(y++,x);
printw("%*s", w, " ");
}
}
|