From b22a7c5fdad64636200d43219a47fca8a24cc16f Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 10 Mar 2012 23:01:59 +0000 Subject: [PATCH] Moved page off, and added search_attempts --- command.c | 3 +++ contact_list.c | 12 ++++++++++++ contact_list.h | 1 + profanity.c | 1 - 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/command.c b/command.c index 03d31e57..a448d55b 100644 --- a/command.c +++ b/command.c @@ -44,6 +44,7 @@ int process_input(char *inp) { int result = FALSE; + if (strlen(inp) > 0) history_append(inp); @@ -60,6 +61,8 @@ int process_input(char *inp) } inp_clear(); + reset_search_attempts(); + win_page_off(); return result; } diff --git a/contact_list.c b/contact_list.c index c1359d98..050ddc41 100644 --- a/contact_list.c +++ b/contact_list.c @@ -35,6 +35,9 @@ struct _contact_node_t { // the contact list static struct _contact_node_t *_contact_list = NULL; +// number of tabs pressed whilst searching +static int _search_attempts = 0; + static struct _contact_node_t * _make_contact_node(const char * const name, const char * const show, const char * const status); static contact_t * _new_contact(const char * const name, const char * const show, @@ -57,6 +60,11 @@ void contact_list_clear(void) } } +void reset_search_attempts(void) +{ + _search_attempts = 0; +} + int contact_list_remove(const char * const name) { if (!_contact_list) { @@ -173,9 +181,13 @@ char * find_contact(const char * const search_str) } else { while(curr) { contact_t *curr_contact = curr->contact; + + // match found if (strncmp(curr_contact->name, search_str, strlen(search_str)) == 0) { char *result = (char *) malloc((strlen(curr_contact->name) + 1) * sizeof(char)); + + // return the contact, must be free'd by caller strcpy(result, curr_contact->name); return result; } diff --git a/contact_list.h b/contact_list.h index 00f03c9d..e6653757 100644 --- a/contact_list.h +++ b/contact_list.h @@ -35,6 +35,7 @@ typedef struct _contact_list_t { } contact_list_t; void contact_list_clear(void); +void reset_search_attempts(void); int contact_list_add(const char * const name, const char * const show, const char * const status); int contact_list_remove(const char * const name); diff --git a/profanity.c b/profanity.c index ab54439d..e5318a68 100644 --- a/profanity.c +++ b/profanity.c @@ -53,7 +53,6 @@ void profanity_run(void) inp[size++] = '\0'; cmd_result = process_input(inp); - win_page_off(); } }