| 
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -3,6 +3,7 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																#include <stdio.h> | 
																 | 
																 | 
																#include <stdio.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <stdlib.h> | 
																 | 
																 | 
																#include <stdlib.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <string.h> | 
																 | 
																 | 
																#include <string.h> | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#include <strings.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <unistd.h> | 
																 | 
																 | 
																#include <unistd.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <X11/Xlib.h> | 
																 | 
																 | 
																#include <X11/Xlib.h> | 
															
														
														
													
														
															
																 | 
																 | 
																#include <X11/Xatom.h> | 
																 | 
																 | 
																#include <X11/Xatom.h> | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -231,13 +232,14 @@ insert(const char *str, ssize_t n) { | 
															
														
														
													
														
															
																 | 
																 | 
																void | 
																 | 
																 | 
																void | 
															
														
														
													
														
															
																 | 
																 | 
																keypress(XKeyEvent *ev) { | 
																 | 
																 | 
																keypress(XKeyEvent *ev) { | 
															
														
														
													
														
															
																 | 
																 | 
																	char buf[32]; | 
																 | 
																 | 
																	char buf[32]; | 
															
														
														
													
														
															
																 | 
																 | 
																	size_t len; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	KeySym ksym; | 
																 | 
																 | 
																	KeySym ksym; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	len = strlen(text); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	XLookupString(ev, buf, sizeof buf, &ksym, NULL); | 
																 | 
																 | 
																	XLookupString(ev, buf, sizeof buf, &ksym, NULL); | 
															
														
														
													
														
															
																 | 
																 | 
																	if(ev->state & ControlMask) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		switch(tolower(ksym)) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if(ev->state & ControlMask) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		KeySym lower, upper; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		XConvertCase(ksym, &lower, &upper); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		switch(lower) { | 
															
														
														
													
														
															
																 | 
																 | 
																		default: | 
																 | 
																 | 
																		default: | 
															
														
														
													
														
															
																 | 
																 | 
																			return; | 
																 | 
																 | 
																			return; | 
															
														
														
													
														
															
																 | 
																 | 
																		case XK_a: | 
																 | 
																 | 
																		case XK_a: | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -290,13 +292,14 @@ keypress(XKeyEvent *ev) { | 
															
														
														
													
														
															
																 | 
																 | 
																			XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); | 
																 | 
																 | 
																			XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); | 
															
														
														
													
														
															
																 | 
																 | 
																			return; | 
																 | 
																 | 
																			return; | 
															
														
														
													
														
															
																 | 
																 | 
																		} | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																	switch(ksym) { | 
																 | 
																 | 
																	switch(ksym) { | 
															
														
														
													
														
															
																 | 
																 | 
																	default: | 
																 | 
																 | 
																	default: | 
															
														
														
													
														
															
																 | 
																 | 
																		if(!iscntrl(*buf)) | 
																 | 
																 | 
																		if(!iscntrl(*buf)) | 
															
														
														
													
														
															
																 | 
																 | 
																			insert(buf, strlen(buf)); | 
																 | 
																 | 
																			insert(buf, strlen(buf)); | 
															
														
														
													
														
															
																 | 
																 | 
																		break; | 
																 | 
																 | 
																		break; | 
															
														
														
													
														
															
																 | 
																 | 
																	case XK_Delete: | 
																 | 
																 | 
																	case XK_Delete: | 
															
														
														
													
														
															
																 | 
																 | 
																		if(cursor == len) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(text[cursor] == '\0') | 
															
														
														
													
														
															
																 | 
																 | 
																			return; | 
																 | 
																 | 
																			return; | 
															
														
														
													
														
															
																 | 
																 | 
																		cursor = nextrune(+1); | 
																 | 
																 | 
																		cursor = nextrune(+1); | 
															
														
														
													
														
															
																 | 
																 | 
																	case XK_BackSpace: | 
																 | 
																 | 
																	case XK_BackSpace: | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -304,8 +307,8 @@ keypress(XKeyEvent *ev) { | 
															
														
														
													
														
															
																 | 
																 | 
																			insert(NULL, nextrune(-1) - cursor); | 
																 | 
																 | 
																			insert(NULL, nextrune(-1) - cursor); | 
															
														
														
													
														
															
																 | 
																 | 
																		break; | 
																 | 
																 | 
																		break; | 
															
														
														
													
														
															
																 | 
																 | 
																	case XK_End: | 
																 | 
																 | 
																	case XK_End: | 
															
														
														
													
														
															
																 | 
																 | 
																		if(cursor < len) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																			cursor = len; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(text[cursor] != '\0') { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																			cursor = strlen(text); | 
															
														
														
													
														
															
																 | 
																 | 
																			break; | 
																 | 
																 | 
																			break; | 
															
														
														
													
														
															
																 | 
																 | 
																		} | 
																 | 
																 | 
																		} | 
															
														
														
													
														
															
																 | 
																 | 
																		if(next) { | 
																 | 
																 | 
																		if(next) { | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -358,7 +361,7 @@ keypress(XKeyEvent *ev) { | 
															
														
														
													
														
															
																 | 
																 | 
																		fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout); | 
																 | 
																 | 
																		fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout); | 
															
														
														
													
														
															
																 | 
																 | 
																		exit(EXIT_SUCCESS); | 
																 | 
																 | 
																		exit(EXIT_SUCCESS); | 
															
														
														
													
														
															
																 | 
																 | 
																	case XK_Right: | 
																 | 
																 | 
																	case XK_Right: | 
															
														
														
													
														
															
																 | 
																 | 
																		if(cursor < len) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		if(text[cursor] != '\0') { | 
															
														
														
													
														
															
																 | 
																 | 
																			cursor = nextrune(+1); | 
																 | 
																 | 
																			cursor = nextrune(+1); | 
															
														
														
													
														
															
																 | 
																 | 
																			break; | 
																 | 
																 | 
																			break; | 
															
														
														
													
														
															
																 | 
																 | 
																		} | 
																 | 
																 | 
																		} | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -385,7 +388,7 @@ void | 
															
														
														
													
														
															
																 | 
																 | 
																match(Bool sub) { | 
																 | 
																 | 
																match(Bool sub) { | 
															
														
														
													
														
															
																 | 
																 | 
																	size_t len = strlen(text); | 
																 | 
																 | 
																	size_t len = strlen(text); | 
															
														
														
													
														
															
																 | 
																 | 
																	Item *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; | 
																 | 
																 | 
																	Item *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; | 
															
														
														
													
														
															
																 | 
																 | 
																	Item *item, *next = NULL; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	Item *item, *next; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	lexact = lprefix = lsubstr = exactend = prefixend = substrend = NULL; | 
																 | 
																 | 
																	lexact = lprefix = lsubstr = exactend = prefixend = substrend = NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																	for(item = sub ? matches : items; item && item->text; item = next) { | 
																 | 
																 | 
																	for(item = sub ? matches : items; item && item->text; item = next) { | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																	
																 | 
																
  |