| @@ -30,12 +30,16 @@ |
| 30 | 30 | | #include <X11/Xutil.h> |
| 31 | 31 | | #include <X11/keysym.h> |
| 32 | 32 | | |
| 33 | + | #include "config.h" |
| 33 | 34 | | #include "image.h" |
| 34 | 35 | | #include "options.h" |
| 35 | 36 | | #include "thumbs.h" |
| 36 | 37 | | #include "util.h" |
| 37 | 38 | | #include "window.h" |
| 39 | + | |
| 40 | + | #ifdef EXT_COMMANDS |
| 38 | 41 | | #include "commands.h" |
| 42 | + | #endif |
| 39 | 43 | | |
| 40 | 44 | | typedef enum { |
| 41 | 45 | | MODE_NORMAL = 0, |
| @@ -273,6 +277,7 @@ void read_dir_rec(const char *dirname) { |
| 273 | 277 | | free(dirnames); |
| 274 | 278 | | } |
| 275 | 279 | | |
| 280 | + | #ifdef EXT_COMMANDS |
| 276 | 281 | | int run_command(const char *cline, Bool reload) { |
| 277 | 282 | | int fncnt, fnlen; |
| 278 | 283 | | char *cn, *cmdline; |
| @@ -328,6 +333,7 @@ int run_command(const char *cline, Bool reload) { |
| 328 | 333 | | free(cmdline); |
| 329 | 334 | | return ret; |
| 330 | 335 | | } |
| 336 | + | #endif /* EXT_COMMANDS */ |
| 331 | 337 | | |
| 332 | 338 | | |
| 333 | 339 | | /* event handling */ |
| @@ -352,7 +358,7 @@ void redraw() { |
| 352 | 358 | | } |
| 353 | 359 | | |
| 354 | 360 | | void on_keypress(XKeyEvent *kev) { |
| 355 | | − | int i, x, y; |
| 361 | + | int x, y; |
| 356 | 362 | | unsigned int w, h; |
| 357 | 363 | | char key; |
| 358 | 364 | | KeySym ksym; |
| @@ -364,24 +370,28 @@ void on_keypress(XKeyEvent *kev) { |
| 364 | 370 | | XLookupString(kev, &key, 1, &ksym, NULL); |
| 365 | 371 | | changed = 0; |
| 366 | 372 | | |
| 373 | + | #ifdef EXT_COMMANDS |
| 367 | 374 | | /* external commands from commands.h */ |
| 368 | | − | for (i = 0; i < LEN(commands); ++i) { |
| 369 | | − | if (commands[i].ksym == ksym) { |
| 370 | | − | win_set_cursor(&win, CURSOR_WATCH); |
| 371 | | − | if (run_command(commands[i].cmdline, commands[i].reload)) { |
| 372 | | − | if (mode == MODE_NORMAL) { |
| 373 | | − | img_close(&img, 1); |
| 374 | | − | load_image(fileidx); |
| 375 | | − | tns_load(&tns, &win, fileidx, filenames[fileidx]); |
| 376 | | − | } else { |
| 377 | | − | tns_load(&tns, &win, tns.sel, filenames[tns.sel]); |
| 375 | + | if (CLEANMASK(kev->state) & ControlMask) { |
| 376 | + | for (x = 0; x < LEN(commands); ++x) { |
| 377 | + | if (commands[x].ksym == ksym) { |
| 378 | + | win_set_cursor(&win, CURSOR_WATCH); |
| 379 | + | if (run_command(commands[x].cmdline, commands[x].reload)) { |
| 380 | + | if (mode == MODE_NORMAL) { |
| 381 | + | img_close(&img, 1); |
| 382 | + | load_image(fileidx); |
| 383 | + | tns_load(&tns, &win, fileidx, filenames[fileidx]); |
| 384 | + | } else { |
| 385 | + | tns_load(&tns, &win, tns.sel, filenames[tns.sel]); |
| 386 | + | } |
| 387 | + | redraw(); |
| 378 | 388 | | } |
| 379 | | − | redraw(); |
| 389 | + | win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW); |
| 390 | + | return; |
| 380 | 391 | | } |
| 381 | | − | win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW); |
| 382 | | − | return; |
| 383 | 392 | | } |
| 384 | 393 | | } |
| 394 | + | #endif |
| 385 | 395 | | |
| 386 | 396 | | if (mode == MODE_NORMAL) { |
| 387 | 397 | | switch (ksym) { |