| 
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -35,13 +35,12 @@ typedef struct { | 
															
														
														
													
														
															
																 | 
																 | 
																typedef struct Item Item; | 
																 | 
																 | 
																typedef struct Item Item; | 
															
														
														
													
														
															
																 | 
																 | 
																struct Item { | 
																 | 
																 | 
																struct Item { | 
															
														
														
													
														
															
																 | 
																 | 
																	char *text; | 
																 | 
																 | 
																	char *text; | 
															
														
														
													
														
															
																 | 
																 | 
																	Bool matched; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	Item *next;		/* traverses all items */ | 
																 | 
																 | 
																	Item *next;		/* traverses all items */ | 
															
														
														
													
														
															
																 | 
																 | 
																	Item *left, *right;	/* traverses items matching current search pattern */ | 
																 | 
																 | 
																	Item *left, *right;	/* traverses items matching current search pattern */ | 
															
														
														
													
														
															
																 | 
																 | 
																}; | 
																 | 
																 | 
																}; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																/* forward declarations */ | 
																 | 
																 | 
																/* forward declarations */ | 
															
														
														
													
														
															
																 | 
																 | 
																Item *appenditem(Item *i, Item *last); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																void appenditem(Item *i, Item **list, Item **last); | 
															
														
														
													
														
															
																 | 
																 | 
																void calcoffsets(void); | 
																 | 
																 | 
																void calcoffsets(void); | 
															
														
														
													
														
															
																 | 
																 | 
																char *cistrstr(const char *s, const char *sub); | 
																 | 
																 | 
																char *cistrstr(const char *s, const char *sub); | 
															
														
														
													
														
															
																 | 
																 | 
																void cleanup(void); | 
																 | 
																 | 
																void cleanup(void); | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -92,17 +91,15 @@ Window root, win; | 
															
														
														
													
														
															
																 | 
																 | 
																int (*fstrncmp)(const char *, const char *, size_t n) = strncmp; | 
																 | 
																 | 
																int (*fstrncmp)(const char *, const char *, size_t n) = strncmp; | 
															
														
														
													
														
															
																 | 
																 | 
																char *(*fstrstr)(const char *, const char *) = strstr; | 
																 | 
																 | 
																char *(*fstrstr)(const char *, const char *) = strstr; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																Item * | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																appenditem(Item *i, Item *last) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	if(!last) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		item = i; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																void | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																appenditem(Item *i, Item **list, Item **last) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if(!(*last)) | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		*list = i; | 
															
														
														
													
														
															
																 | 
																 | 
																	else | 
																 | 
																 | 
																	else | 
															
														
														
													
														
															
																 | 
																 | 
																		last->right = i; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	i->left = last; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		(*last)->right = i; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	i->left = *last; | 
															
														
														
													
														
															
																 | 
																 | 
																	i->right = NULL; | 
																 | 
																 | 
																	i->right = NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																	last = i; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	nitem++; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	return last; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	*last = i; | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																void | 
																 | 
																 | 
																void | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -521,19 +518,47 @@ kpress(XKeyEvent * e) { | 
															
														
														
													
														
															
																 | 
																 | 
																void | 
																 | 
																 | 
																void | 
															
														
														
													
														
															
																 | 
																 | 
																match(char *pattern) { | 
																 | 
																 | 
																match(char *pattern) { | 
															
														
														
													
														
															
																 | 
																 | 
																	unsigned int plen; | 
																 | 
																 | 
																	unsigned int plen; | 
															
														
														
													
														
															
																 | 
																 | 
																	Item *i, *j; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	Item *i, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	if(!pattern) | 
																 | 
																 | 
																	if(!pattern) | 
															
														
														
													
														
															
																 | 
																 | 
																		return; | 
																 | 
																 | 
																		return; | 
															
														
														
													
														
															
																 | 
																 | 
																	plen = strlen(pattern); | 
																 | 
																 | 
																	plen = strlen(pattern); | 
															
														
														
													
														
															
																 | 
																 | 
																	item = j = NULL; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																	nitem = 0; | 
																 | 
																 | 
																	nitem = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																	for(i = allitems; i; i = i->next) | 
																 | 
																 | 
																	for(i = allitems; i; i = i->next) | 
															
														
														
													
														
															
																 | 
																 | 
																		if((i->matched = !fstrncmp(pattern, i->text, plen))) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																			j = appenditem(i, j); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	for(i = allitems; i; i = i->next) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		if(!i->matched && fstrstr(i->text, pattern)) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																			j = appenditem(i, j); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(!fstrncmp(pattern, i->text, plen + 1)) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			appenditem(i, &lexact, &exactend); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			nitem++; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		else if(!fstrncmp(pattern, i->text, plen)) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			appenditem(i, &lprefix, &prefixend); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			nitem++; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		else if(fstrstr(i->text, pattern)) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			appenditem(i, &lsubstr, &substrend); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			nitem++; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if(lexact) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		item = lexact; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		itemend = exactend; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if(lprefix) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(itemend) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			itemend->right - lprefix; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			lprefix->left = itemend; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		else | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			item = lprefix; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		itemend = prefixend; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if(lsubstr) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(itemend) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			itemend->right = lsubstr; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			lsubstr->left = itemend; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		else | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			item = lsubstr; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																	curr = prev = next = sel = item; | 
																 | 
																 | 
																	curr = prev = next = sel = item; | 
															
														
														
													
														
															
																 | 
																 | 
																	calcoffsets(); | 
																 | 
																 | 
																	calcoffsets(); | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																	
																 | 
																
  |