comparison menu.c @ 31:386649deb651

before leaning things up
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:04:38 +0200
parents e8f627998d6f
children
comparison
equal deleted inserted replaced
30:2e0fb4130bfb 31:386649deb651
10 10
11 #include <ctype.h> 11 #include <ctype.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <string.h> 14 #include <string.h>
15 #include <sys/stat.h>
16 #include <sys/wait.h>
17 #include <time.h>
18 #include <unistd.h> 15 #include <unistd.h>
19 #include <X11/cursorfont.h> 16 #include <X11/cursorfont.h>
20 #include <X11/Xutil.h> 17 #include <X11/Xutil.h>
21 #include <X11/keysym.h> 18 #include <X11/keysym.h>
22 19
56 static void kpress(XKeyEvent * e); 53 static void kpress(XKeyEvent * e);
57 54
58 static char version[] = "gridmenu - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 55 static char version[] = "gridmenu - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
59 56
60 static void 57 static void
61 usage() 58 usage() { error("usage: gridmenu [-v] [-t <title>]\n"); }
62 {
63 fprintf(stderr, "%s", "usage: gridmenu [-v] [-t <title>]\n");
64 exit(1);
65 }
66 59
67 static void 60 static void
68 update_offsets() 61 update_offsets()
69 { 62 {
70 unsigned int tw, w = cmdw + 2 * seek; 63 unsigned int tw, w = cmdw + 2 * seek;
211 return; 204 return;
212 205
213 /* first check if a control mask is omitted */ 206 /* first check if a control mask is omitted */
214 if(e->state & ControlMask) { 207 if(e->state & ControlMask) {
215 switch (ksym) { 208 switch (ksym) {
216 case XK_H: 209 default: /* ignore other control sequences */
210 return;
211 break;
217 case XK_h: 212 case XK_h:
218 ksym = XK_BackSpace; 213 ksym = XK_BackSpace;
219 break;
220 case XK_I:
221 case XK_i:
222 ksym = XK_Tab;
223 break;
224 case XK_J:
225 case XK_j:
226 ksym = XK_Return;
227 break;
228 case XK_N:
229 case XK_n:
230 ksym = XK_Right;
231 break;
232 case XK_P:
233 case XK_p:
234 ksym = XK_Left;
235 break; 214 break;
236 case XK_U: 215 case XK_U:
237 case XK_u: 216 case XK_u:
238 text[0] = 0; 217 text[0] = 0;
239 update_items(text); 218 update_items(text);
241 return; 220 return;
242 break; 221 break;
243 case XK_bracketleft: 222 case XK_bracketleft:
244 ksym = XK_Escape; 223 ksym = XK_Escape;
245 break; 224 break;
246 default: /* ignore other control sequences */ 225 }
247 return; 226 }
248 break; 227 switch(ksym) {
249 }
250 }
251 switch (ksym) {
252 case XK_Left: 228 case XK_Left:
253 if(!(sel && sel->left)) 229 if(!(sel && sel->left))
254 return; 230 return;
255 sel=sel->left; 231 sel=sel->left;
256 if(sel->right == curroff) { 232 if(sel->right == curroff) {
430 XMapRaised(dpy, win); 406 XMapRaised(dpy, win);
431 draw_menu(); 407 draw_menu();
432 XFlush(dpy); 408 XFlush(dpy);
433 409
434 /* main event loop */ 410 /* main event loop */
435 while(!XNextEvent(dpy, &ev)) { 411 while(!done && !XNextEvent(dpy, &ev)) {
436 switch (ev.type) { 412 switch (ev.type) {
437 case KeyPress: 413 case KeyPress:
438 kpress(&ev.xkey); 414 kpress(&ev.xkey);
439 break; 415 break;
440 case Expose: 416 case Expose:
441 if(ev.xexpose.count == 0) { 417 if(ev.xexpose.count == 0)
442 draw_menu(); 418 draw_menu();
443 } 419 break;
444 break; 420 default:
445 default: 421 break;
446 break; 422 }
447 }
448 if(done)
449 break;
450 } 423 }
451 424
452 XUngrabKeyboard(dpy, CurrentTime); 425 XUngrabKeyboard(dpy, CurrentTime);
453 XFreePixmap(dpy, brush.drawable); 426 XFreePixmap(dpy, brush.drawable);
454 XFreeGC(dpy, brush.gc); 427 XFreeGC(dpy, brush.gc);