1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Moved page off, and added search_attempts

This commit is contained in:
James Booth 2012-03-10 23:01:59 +00:00
parent b41808ae0f
commit b22a7c5fda
4 changed files with 16 additions and 1 deletions

View File

@ -44,6 +44,7 @@ int process_input(char *inp)
{ {
int result = FALSE; int result = FALSE;
if (strlen(inp) > 0) if (strlen(inp) > 0)
history_append(inp); history_append(inp);
@ -60,6 +61,8 @@ int process_input(char *inp)
} }
inp_clear(); inp_clear();
reset_search_attempts();
win_page_off();
return result; return result;
} }

View File

@ -35,6 +35,9 @@ struct _contact_node_t {
// the contact list // the contact list
static struct _contact_node_t *_contact_list = NULL; 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, static struct _contact_node_t * _make_contact_node(const char * const name,
const char * const show, const char * const status); const char * const show, const char * const status);
static contact_t * _new_contact(const char * const name, const char * const show, 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) int contact_list_remove(const char * const name)
{ {
if (!_contact_list) { if (!_contact_list) {
@ -173,9 +181,13 @@ char * find_contact(const char * const search_str)
} else { } else {
while(curr) { while(curr) {
contact_t *curr_contact = curr->contact; contact_t *curr_contact = curr->contact;
// match found
if (strncmp(curr_contact->name, search_str, strlen(search_str)) == 0) { if (strncmp(curr_contact->name, search_str, strlen(search_str)) == 0) {
char *result = char *result =
(char *) malloc((strlen(curr_contact->name) + 1) * sizeof(char)); (char *) malloc((strlen(curr_contact->name) + 1) * sizeof(char));
// return the contact, must be free'd by caller
strcpy(result, curr_contact->name); strcpy(result, curr_contact->name);
return result; return result;
} }

View File

@ -35,6 +35,7 @@ typedef struct _contact_list_t {
} contact_list_t; } contact_list_t;
void contact_list_clear(void); void contact_list_clear(void);
void reset_search_attempts(void);
int contact_list_add(const char * const name, const char * const show, int contact_list_add(const char * const name, const char * const show,
const char * const status); const char * const status);
int contact_list_remove(const char * const name); int contact_list_remove(const char * const name);

View File

@ -53,7 +53,6 @@ void profanity_run(void)
inp[size++] = '\0'; inp[size++] = '\0';
cmd_result = process_input(inp); cmd_result = process_input(inp);
win_page_off();
} }
} }