From 040676f315af3564df897a8c9fae7eeec2c4b085 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 10 Feb 2019 23:51:30 +0100 Subject: Fix search focus --- contactWind.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contactWind.c b/contactWind.c index d353a43..f57465c 100644 --- a/contactWind.c +++ b/contactWind.c @@ -25,9 +25,22 @@ void selectNextContact(void) { contactListSelection++; } void setContactSelection(contact* c) { - int i = c - contactList; + int i = c - contactList ; + int h = h_menuContact; + if( i >= 0 && i < nbContacts ) contactListSelection = i; + + while( contactListSelection < firstConctactShow ) { + firstConctactShow-=h/2; + if( firstConctactShow < 0 ) + firstConctactShow = 0; + } + while( contactListSelection >= firstConctactShow + h ) { + firstConctactShow+=h/2; + if( firstConctactShow > nbContacts-1 ) + firstConctactShow = nbContacts-1; + } } void selectPreviousContact(void) { if( contactListSelection > 0) -- cgit v1.2.3