From a7ec793bf9814be7ea8d331ca3d1d35f58b17da1 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 13 Sep 2019 00:36:54 +0200 Subject: Search in conv feature --- main.c | 13 +++++++++++-- messageWind.c | 11 ++++++++++- messageWind.h | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c3b90df..791c6b2 100644 --- a/main.c +++ b/main.c @@ -292,6 +292,17 @@ int main(int argc, char* argv[]){ } curs_set(0); showContactListW(); + } else { + move(LINES-1,0); + readline_n("/ ", ""); + int res = searchSMS(msg_win_str); + + if( res >= 0 ) { + canAugment = 1; + firstSMSIndex = res; + clearWind(); + showMessageWind(); + } } break; case 'n': @@ -436,5 +447,3 @@ end: return 0; } - - diff --git a/messageWind.c b/messageWind.c index 73d1182..5b71b5e 100644 --- a/messageWind.c +++ b/messageWind.c @@ -6,7 +6,6 @@ extern contact* contactList; extern size_t nbContacts; - conversation* currentConv; int x_WMessage = 1,y_WMessage = 1; @@ -127,6 +126,16 @@ void showMessageWind(void) { } +int searchSMS( const char* toSearch ) { + if( !currentConv ) + return -1; + for(int i = firstSMSIndex - 1; i >= 0 ; --i) { + if(strstr(currentConv->listSMS[i].text, toSearch) != NULL) + return i; + } + + return -1; +} diff --git a/messageWind.h b/messageWind.h index 99f0f57..b1b4550 100644 --- a/messageWind.h +++ b/messageWind.h @@ -11,6 +11,8 @@ void clearWind(void); void toTheEnd(void); +int searchSMS(const char*); + #endif -- cgit v1.2.3