nsxiv08ae25d
Refactored function definitions to use dangling brace
+247 −124
9 files changed
- M Makefile +1 −1
- M commands.c +56 −28
- M exif.c +8 −4
- M image.c +50 −25
- M main.c +40 −20
- M options.c +6 −3
- M thumbs.c +26 −13
- M util.c +24 −12
- M window.c +36 −18
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20130129 | |
| 1 | + | VERSION = git-20130208 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX = /usr/local | |
| 4 | 4 | MANPREFIX = $(PREFIX)/share/man | |
| @@ -54,12 +54,14 @@ const int ss_delays[] = { | |||
| 54 | 54 | 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600 | |
| 55 | 55 | }; | |
| 56 | 56 | ||
| 57 | − | bool it_quit(arg_t a) { | |
| 57 | + | bool it_quit(arg_t a) | |
| 58 | + | { | |
| 58 | 59 | cleanup(); | |
| 59 | 60 | exit(EXIT_SUCCESS); | |
| 60 | 61 | } | |
| 61 | 62 | ||
| 62 | − | bool it_switch_mode(arg_t a) { | |
| 63 | + | bool it_switch_mode(arg_t a) | |
| 64 | + | { | |
| 63 | 65 | if (mode == MODE_IMAGE) { | |
| 64 | 66 | if (tns.thumbs == NULL) | |
| 65 | 67 | tns_init(&tns, filecnt, &win); | |
| @@ -75,7 +77,8 @@ bool it_switch_mode(arg_t a) { | |||
| 75 | 77 | return true; | |
| 76 | 78 | } | |
| 77 | 79 | ||
| 78 | − | bool it_toggle_fullscreen(arg_t a) { | |
| 80 | + | bool it_toggle_fullscreen(arg_t a) | |
| 81 | + | { | |
| 79 | 82 | win_toggle_fullscreen(&win); | |
| 80 | 83 | /* redraw after next ConfigureNotify event */ | |
| 81 | 84 | set_timeout(redraw, TO_REDRAW_RESIZE, false); | |
| @@ -86,7 +89,8 @@ bool it_toggle_fullscreen(arg_t a) { | |||
| 86 | 89 | return false; | |
| 87 | 90 | } | |
| 88 | 91 | ||
| 89 | − | bool it_toggle_bar(arg_t a) { | |
| 92 | + | bool it_toggle_bar(arg_t a) | |
| 93 | + | { | |
| 90 | 94 | win_toggle_bar(&win); | |
| 91 | 95 | if (mode == MODE_IMAGE) | |
| 92 | 96 | img.checkpan = img.dirty = true; | |
| @@ -95,7 +99,8 @@ bool it_toggle_bar(arg_t a) { | |||
| 95 | 99 | return true; | |
| 96 | 100 | } | |
| 97 | 101 | ||
| 98 | − | bool t_reload_all(arg_t a) { | |
| 102 | + | bool t_reload_all(arg_t a) | |
| 103 | + | { | |
| 99 | 104 | if (mode == MODE_THUMB) { | |
| 100 | 105 | tns_free(&tns); | |
| 101 | 106 | tns_init(&tns, filecnt, &win); | |
| @@ -105,7 +110,8 @@ bool t_reload_all(arg_t a) { | |||
| 105 | 110 | } | |
| 106 | 111 | } | |
| 107 | 112 | ||
| 108 | − | bool it_reload_image(arg_t a) { | |
| 113 | + | bool it_reload_image(arg_t a) | |
| 114 | + | { | |
| 109 | 115 | if (mode == MODE_IMAGE) { | |
| 110 | 116 | load_image(fileidx); | |
| 111 | 117 | } else { | |
| @@ -120,7 +126,8 @@ bool it_reload_image(arg_t a) { | |||
| 120 | 126 | return true; | |
| 121 | 127 | } | |
| 122 | 128 | ||
| 123 | − | bool it_remove_image(arg_t a) { | |
| 129 | + | bool it_remove_image(arg_t a) | |
| 130 | + | { | |
| 124 | 131 | if (mode == MODE_IMAGE) { | |
| 125 | 132 | remove_file(fileidx, true); | |
| 126 | 133 | load_image(fileidx >= filecnt ? filecnt - 1 : fileidx); | |
| @@ -136,7 +143,8 @@ bool it_remove_image(arg_t a) { | |||
| 136 | 143 | } | |
| 137 | 144 | } | |
| 138 | 145 | ||
| 139 | − | bool i_navigate(arg_t a) { | |
| 146 | + | bool i_navigate(arg_t a) | |
| 147 | + | { | |
| 140 | 148 | long n = (long) a; | |
| 141 | 149 | ||
| 142 | 150 | if (mode == MODE_IMAGE) { | |
| @@ -156,7 +164,8 @@ bool i_navigate(arg_t a) { | |||
| 156 | 164 | return false; | |
| 157 | 165 | } | |
| 158 | 166 | ||
| 159 | − | bool i_alternate(arg_t a) { | |
| 167 | + | bool i_alternate(arg_t a) | |
| 168 | + | { | |
| 160 | 169 | if (mode == MODE_IMAGE) { | |
| 161 | 170 | load_image(alternate); | |
| 162 | 171 | return true; | |
| @@ -165,7 +174,8 @@ bool i_alternate(arg_t a) { | |||
| 165 | 174 | } | |
| 166 | 175 | } | |
| 167 | 176 | ||
| 168 | − | bool it_first(arg_t a) { | |
| 177 | + | bool it_first(arg_t a) | |
| 178 | + | { | |
| 169 | 179 | if (mode == MODE_IMAGE && fileidx != 0) { | |
| 170 | 180 | load_image(0); | |
| 171 | 181 | return true; | |
| @@ -178,7 +188,8 @@ bool it_first(arg_t a) { | |||
| 178 | 188 | } | |
| 179 | 189 | } | |
| 180 | 190 | ||
| 181 | − | bool it_n_or_last(arg_t a) { | |
| 191 | + | bool it_n_or_last(arg_t a) | |
| 192 | + | { | |
| 182 | 193 | int n = prefix != 0 && prefix - 1 < filecnt ? prefix - 1 : filecnt - 1; | |
| 183 | 194 | ||
| 184 | 195 | if (mode == MODE_IMAGE && fileidx != n) { | |
| @@ -193,14 +204,16 @@ bool it_n_or_last(arg_t a) { | |||
| 193 | 204 | } | |
| 194 | 205 | } | |
| 195 | 206 | ||
| 196 | − | bool i_navigate_frame(arg_t a) { | |
| 207 | + | bool i_navigate_frame(arg_t a) | |
| 208 | + | { | |
| 197 | 209 | if (mode == MODE_IMAGE && !img.multi.animate) | |
| 198 | 210 | return img_frame_navigate(&img, (long) a); | |
| 199 | 211 | else | |
| 200 | 212 | return false; | |
| 201 | 213 | } | |
| 202 | 214 | ||
| 203 | − | bool i_toggle_animation(arg_t a) { | |
| 215 | + | bool i_toggle_animation(arg_t a) | |
| 216 | + | { | |
| 204 | 217 | if (mode != MODE_IMAGE) | |
| 205 | 218 | return false; | |
| 206 | 219 | ||
| @@ -213,7 +226,8 @@ bool i_toggle_animation(arg_t a) { | |||
| 213 | 226 | return true; | |
| 214 | 227 | } | |
| 215 | 228 | ||
| 216 | − | bool it_scroll_move(arg_t a) { | |
| 229 | + | bool it_scroll_move(arg_t a) | |
| 230 | + | { | |
| 217 | 231 | direction_t dir = (direction_t) a; | |
| 218 | 232 | ||
| 219 | 233 | if (mode == MODE_IMAGE) | |
| @@ -222,7 +236,8 @@ bool it_scroll_move(arg_t a) { | |||
| 222 | 236 | return tns_move_selection(&tns, dir, prefix); | |
| 223 | 237 | } | |
| 224 | 238 | ||
| 225 | − | bool it_scroll_screen(arg_t a) { | |
| 239 | + | bool it_scroll_screen(arg_t a) | |
| 240 | + | { | |
| 226 | 241 | direction_t dir = (direction_t) a; | |
| 227 | 242 | ||
| 228 | 243 | if (mode == MODE_IMAGE) | |
| @@ -231,7 +246,8 @@ bool it_scroll_screen(arg_t a) { | |||
| 231 | 246 | return tns_scroll(&tns, dir, true); | |
| 232 | 247 | } | |
| 233 | 248 | ||
| 234 | − | bool i_scroll_to_edge(arg_t a) { | |
| 249 | + | bool i_scroll_to_edge(arg_t a) | |
| 250 | + | { | |
| 235 | 251 | direction_t dir = (direction_t) a; | |
| 236 | 252 | ||
| 237 | 253 | if (mode == MODE_IMAGE) | |
| @@ -241,11 +257,13 @@ bool i_scroll_to_edge(arg_t a) { | |||
| 241 | 257 | } | |
| 242 | 258 | ||
| 243 | 259 | /* Xlib helper function for i_drag() */ | |
| 244 | − | Bool is_motionnotify(Display *d, XEvent *e, XPointer a) { | |
| 260 | + | Bool is_motionnotify(Display *d, XEvent *e, XPointer a) | |
| 261 | + | { | |
| 245 | 262 | return e != NULL && e->type == MotionNotify; | |
| 246 | 263 | } | |
| 247 | 264 | ||
| 248 | − | bool i_drag(arg_t a) { | |
| 265 | + | bool i_drag(arg_t a) | |
| 266 | + | { | |
| 249 | 267 | int dx = 0, dy = 0, i, ox, oy, x, y; | |
| 250 | 268 | unsigned int ui; | |
| 251 | 269 | bool dragging = true, next = false; | |
| @@ -297,7 +315,8 @@ bool i_drag(arg_t a) { | |||
| 297 | 315 | return false; | |
| 298 | 316 | } | |
| 299 | 317 | ||
| 300 | − | bool i_zoom(arg_t a) { | |
| 318 | + | bool i_zoom(arg_t a) | |
| 319 | + | { | |
| 301 | 320 | long scale = (long) a; | |
| 302 | 321 | ||
| 303 | 322 | if (mode != MODE_IMAGE) | |
| @@ -311,14 +330,16 @@ bool i_zoom(arg_t a) { | |||
| 311 | 330 | return false; | |
| 312 | 331 | } | |
| 313 | 332 | ||
| 314 | − | bool i_set_zoom(arg_t a) { | |
| 333 | + | bool i_set_zoom(arg_t a) | |
| 334 | + | { | |
| 315 | 335 | if (mode == MODE_IMAGE) | |
| 316 | 336 | return img_zoom(&img, (prefix ? prefix : (long) a) / 100.0); | |
| 317 | 337 | else | |
| 318 | 338 | return false; | |
| 319 | 339 | } | |
| 320 | 340 | ||
| 321 | − | bool i_fit_to_win(arg_t a) { | |
| 341 | + | bool i_fit_to_win(arg_t a) | |
| 342 | + | { | |
| 322 | 343 | bool ret = false; | |
| 323 | 344 | scalemode_t sm = (scalemode_t) a; | |
| 324 | 345 | ||
| @@ -329,7 +350,8 @@ bool i_fit_to_win(arg_t a) { | |||
| 329 | 350 | return ret; | |
| 330 | 351 | } | |
| 331 | 352 | ||
| 332 | − | bool i_fit_to_img(arg_t a) { | |
| 353 | + | bool i_fit_to_img(arg_t a) | |
| 354 | + | { | |
| 333 | 355 | int x, y; | |
| 334 | 356 | unsigned int w, h; | |
| 335 | 357 | bool ret = false; | |
| @@ -348,7 +370,8 @@ bool i_fit_to_img(arg_t a) { | |||
| 348 | 370 | return ret; | |
| 349 | 371 | } | |
| 350 | 372 | ||
| 351 | − | bool i_rotate(arg_t a) { | |
| 373 | + | bool i_rotate(arg_t a) | |
| 374 | + | { | |
| 352 | 375 | direction_t dir = (direction_t) a; | |
| 353 | 376 | ||
| 354 | 377 | if (mode == MODE_IMAGE) { | |
| @@ -363,7 +386,8 @@ bool i_rotate(arg_t a) { | |||
| 363 | 386 | return false; | |
| 364 | 387 | } | |
| 365 | 388 | ||
| 366 | − | bool i_flip(arg_t a) { | |
| 389 | + | bool i_flip(arg_t a) | |
| 390 | + | { | |
| 367 | 391 | flipdir_t dir = (flipdir_t) a; | |
| 368 | 392 | ||
| 369 | 393 | if (mode == MODE_IMAGE) { | |
| @@ -374,7 +398,8 @@ bool i_flip(arg_t a) { | |||
| 374 | 398 | } | |
| 375 | 399 | } | |
| 376 | 400 | ||
| 377 | − | bool i_toggle_antialias(arg_t a) { | |
| 401 | + | bool i_toggle_antialias(arg_t a) | |
| 402 | + | { | |
| 378 | 403 | if (mode == MODE_IMAGE) { | |
| 379 | 404 | img_toggle_antialias(&img); | |
| 380 | 405 | return true; | |
| @@ -383,7 +408,8 @@ bool i_toggle_antialias(arg_t a) { | |||
| 383 | 408 | } | |
| 384 | 409 | } | |
| 385 | 410 | ||
| 386 | − | bool it_toggle_alpha(arg_t a) { | |
| 411 | + | bool it_toggle_alpha(arg_t a) | |
| 412 | + | { | |
| 387 | 413 | img.alpha = tns.alpha = !img.alpha; | |
| 388 | 414 | if (mode == MODE_IMAGE) | |
| 389 | 415 | img.dirty = true; | |
| @@ -392,7 +418,8 @@ bool it_toggle_alpha(arg_t a) { | |||
| 392 | 418 | return true; | |
| 393 | 419 | } | |
| 394 | 420 | ||
| 395 | − | bool it_open_with(arg_t a) { | |
| 421 | + | bool it_open_with(arg_t a) | |
| 422 | + | { | |
| 396 | 423 | const char *prog = (const char*) a; | |
| 397 | 424 | pid_t pid; | |
| 398 | 425 | ||
| @@ -410,7 +437,8 @@ bool it_open_with(arg_t a) { | |||
| 410 | 437 | return false; | |
| 411 | 438 | } | |
| 412 | 439 | ||
| 413 | − | bool it_shell_cmd(arg_t a) { | |
| 440 | + | bool it_shell_cmd(arg_t a) | |
| 441 | + | { | |
| 414 | 442 | int n, status; | |
| 415 | 443 | const char *cmdline = (const char*) a; | |
| 416 | 444 | pid_t pid; | |
| @@ -26,7 +26,8 @@ | |||
| 26 | 26 | #include "exif.h" | |
| 27 | 27 | #include "util.h" | |
| 28 | 28 | ||
| 29 | − | ssize_t s_read(int fd, const char *fn, void *buf, size_t n) { | |
| 29 | + | ssize_t s_read(int fd, const char *fn, void *buf, size_t n) | |
| 30 | + | { | |
| 30 | 31 | ssize_t ret; | |
| 31 | 32 | ||
| 32 | 33 | ret = read(fd, buf, n); | |
| @@ -38,7 +39,8 @@ ssize_t s_read(int fd, const char *fn, void *buf, size_t n) { | |||
| 38 | 39 | } | |
| 39 | 40 | } | |
| 40 | 41 | ||
| 41 | − | unsigned short btous(unsigned char *buf, byteorder_t order) { | |
| 42 | + | unsigned short btous(unsigned char *buf, byteorder_t order) | |
| 43 | + | { | |
| 42 | 44 | if (buf == NULL) | |
| 43 | 45 | return 0; | |
| 44 | 46 | if (order == BO_BIG_ENDIAN) | |
| @@ -47,7 +49,8 @@ unsigned short btous(unsigned char *buf, byteorder_t order) { | |||
| 47 | 49 | return buf[1] << 8 | buf[0]; | |
| 48 | 50 | } | |
| 49 | 51 | ||
| 50 | − | unsigned int btoui(unsigned char *buf, byteorder_t order) { | |
| 52 | + | unsigned int btoui(unsigned char *buf, byteorder_t order) | |
| 53 | + | { | |
| 51 | 54 | if (buf == NULL) | |
| 52 | 55 | return 0; | |
| 53 | 56 | if (order == BO_BIG_ENDIAN) | |
| @@ -56,7 +59,8 @@ unsigned int btoui(unsigned char *buf, byteorder_t order) { | |||
| 56 | 59 | return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]; | |
| 57 | 60 | } | |
| 58 | 61 | ||
| 59 | − | int exif_orientation(const fileinfo_t *file) { | |
| 62 | + | int exif_orientation(const fileinfo_t *file) | |
| 63 | + | { | |
| 60 | 64 | int fd; | |
| 61 | 65 | unsigned char data[EXIF_MAX_LEN]; | |
| 62 | 66 | byteorder_t order = BO_BIG_ENDIAN; | |
| @@ -38,11 +38,13 @@ enum { MIN_GIF_DELAY = 25 }; | |||
| 38 | 38 | float zoom_min; | |
| 39 | 39 | float zoom_max; | |
| 40 | 40 | ||
| 41 | − | int zoomdiff(float z1, float z2) { | |
| 41 | + | int zoomdiff(float z1, float z2) | |
| 42 | + | { | |
| 42 | 43 | return (int) (z1 * 1000.0 - z2 * 1000.0); | |
| 43 | 44 | } | |
| 44 | 45 | ||
| 45 | − | void img_init(img_t *img, win_t *win) { | |
| 46 | + | void img_init(img_t *img, win_t *win) | |
| 47 | + | { | |
| 46 | 48 | zoom_min = zoom_levels[0] / 100.0; | |
| 47 | 49 | zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; | |
| 48 | 50 | ||
| @@ -66,7 +68,8 @@ void img_init(img_t *img, win_t *win) { | |||
| 66 | 68 | img->multi.animate = false; | |
| 67 | 69 | } | |
| 68 | 70 | ||
| 69 | − | void exif_auto_orientate(const fileinfo_t *file) { | |
| 71 | + | void exif_auto_orientate(const fileinfo_t *file) | |
| 72 | + | { | |
| 70 | 73 | switch (exif_orientation(file)) { | |
| 71 | 74 | case 5: | |
| 72 | 75 | imlib_image_orientate(1); | |
| @@ -95,7 +98,8 @@ void exif_auto_orientate(const fileinfo_t *file) { | |||
| 95 | 98 | } | |
| 96 | 99 | ||
| 97 | 100 | #if HAVE_GIFLIB | |
| 98 | − | bool img_load_gif(img_t *img, const fileinfo_t *file) { | |
| 101 | + | bool img_load_gif(img_t *img, const fileinfo_t *file) | |
| 102 | + | { | |
| 99 | 103 | GifFileType *gif; | |
| 100 | 104 | GifRowType *rows = NULL; | |
| 101 | 105 | GifRecordType rec; | |
| @@ -266,7 +270,8 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 266 | 270 | } | |
| 267 | 271 | #endif /* HAVE_GIFLIB */ | |
| 268 | 272 | ||
| 269 | − | bool img_load(img_t *img, const fileinfo_t *file) { | |
| 273 | + | bool img_load(img_t *img, const fileinfo_t *file) | |
| 274 | + | { | |
| 270 | 275 | const char *fmt; | |
| 271 | 276 | ||
| 272 | 277 | if (img == NULL || file == NULL || file->name == NULL || file->path == NULL) | |
| @@ -303,7 +308,8 @@ bool img_load(img_t *img, const fileinfo_t *file) { | |||
| 303 | 308 | return true; | |
| 304 | 309 | } | |
| 305 | 310 | ||
| 306 | − | void img_close(img_t *img, bool decache) { | |
| 311 | + | void img_close(img_t *img, bool decache) | |
| 312 | + | { | |
| 307 | 313 | int i; | |
| 308 | 314 | ||
| 309 | 315 | if (img == NULL) | |
| @@ -326,7 +332,8 @@ void img_close(img_t *img, bool decache) { | |||
| 326 | 332 | } | |
| 327 | 333 | } | |
| 328 | 334 | ||
| 329 | − | void img_check_pan(img_t *img, bool moved) { | |
| 335 | + | void img_check_pan(img_t *img, bool moved) | |
| 336 | + | { | |
| 330 | 337 | win_t *win; | |
| 331 | 338 | int ox, oy; | |
| 332 | 339 | ||
| @@ -358,7 +365,8 @@ void img_check_pan(img_t *img, bool moved) { | |||
| 358 | 365 | img->dirty = true; | |
| 359 | 366 | } | |
| 360 | 367 | ||
| 361 | − | bool img_fit(img_t *img) { | |
| 368 | + | bool img_fit(img_t *img) | |
| 369 | + | { | |
| 362 | 370 | float z, zmax, zw, zh; | |
| 363 | 371 | ||
| 364 | 372 | if (img == NULL || img->im == NULL || img->win == NULL) | |
| @@ -394,7 +402,8 @@ bool img_fit(img_t *img) { | |||
| 394 | 402 | } | |
| 395 | 403 | } | |
| 396 | 404 | ||
| 397 | − | void img_render(img_t *img) { | |
| 405 | + | void img_render(img_t *img) | |
| 406 | + | { | |
| 398 | 407 | win_t *win; | |
| 399 | 408 | int sx, sy, sw, sh; | |
| 400 | 409 | int dx, dy, dw, dh; | |
| @@ -464,7 +473,8 @@ void img_render(img_t *img) { | |||
| 464 | 473 | img->dirty = false; | |
| 465 | 474 | } | |
| 466 | 475 | ||
| 467 | − | bool img_fit_win(img_t *img, scalemode_t sm) { | |
| 476 | + | bool img_fit_win(img_t *img, scalemode_t sm) | |
| 477 | + | { | |
| 468 | 478 | if (img == NULL || img->im == NULL) | |
| 469 | 479 | return false; | |
| 470 | 480 | ||
| @@ -472,7 +482,8 @@ bool img_fit_win(img_t *img, scalemode_t sm) { | |||
| 472 | 482 | return img_fit(img); | |
| 473 | 483 | } | |
| 474 | 484 | ||
| 475 | − | bool img_center(img_t *img) { | |
| 485 | + | bool img_center(img_t *img) | |
| 486 | + | { | |
| 476 | 487 | int ox, oy; | |
| 477 | 488 | ||
| 478 | 489 | if (img == NULL || img->im == NULL || img->win == NULL) | |
| @@ -492,7 +503,8 @@ bool img_center(img_t *img) { | |||
| 492 | 503 | } | |
| 493 | 504 | } | |
| 494 | 505 | ||
| 495 | − | bool img_zoom(img_t *img, float z) { | |
| 506 | + | bool img_zoom(img_t *img, float z) | |
| 507 | + | { | |
| 496 | 508 | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 497 | 509 | return false; | |
| 498 | 510 | ||
| @@ -513,7 +525,8 @@ bool img_zoom(img_t *img, float z) { | |||
| 513 | 525 | } | |
| 514 | 526 | } | |
| 515 | 527 | ||
| 516 | − | bool img_zoom_in(img_t *img) { | |
| 528 | + | bool img_zoom_in(img_t *img) | |
| 529 | + | { | |
| 517 | 530 | int i; | |
| 518 | 531 | float z; | |
| 519 | 532 | ||
| @@ -528,7 +541,8 @@ bool img_zoom_in(img_t *img) { | |||
| 528 | 541 | return false; | |
| 529 | 542 | } | |
| 530 | 543 | ||
| 531 | − | bool img_zoom_out(img_t *img) { | |
| 544 | + | bool img_zoom_out(img_t *img) | |
| 545 | + | { | |
| 532 | 546 | int i; | |
| 533 | 547 | float z; | |
| 534 | 548 | ||
| @@ -543,7 +557,8 @@ bool img_zoom_out(img_t *img) { | |||
| 543 | 557 | return false; | |
| 544 | 558 | } | |
| 545 | 559 | ||
| 546 | − | bool img_move(img_t *img, float dx, float dy) { | |
| 560 | + | bool img_move(img_t *img, float dx, float dy) | |
| 561 | + | { | |
| 547 | 562 | float ox, oy; | |
| 548 | 563 | ||
| 549 | 564 | if (img == NULL || img->im == NULL) | |
| @@ -565,7 +580,8 @@ bool img_move(img_t *img, float dx, float dy) { | |||
| 565 | 580 | } | |
| 566 | 581 | } | |
| 567 | 582 | ||
| 568 | − | bool img_pan(img_t *img, direction_t dir, int d) { | |
| 583 | + | bool img_pan(img_t *img, direction_t dir, int d) | |
| 584 | + | { | |
| 569 | 585 | /* d < 0: screen-wise | |
| 570 | 586 | * d = 0: 1/5 of screen | |
| 571 | 587 | * d > 0: num of pixels | |
| @@ -595,7 +611,8 @@ bool img_pan(img_t *img, direction_t dir, int d) { | |||
| 595 | 611 | return false; | |
| 596 | 612 | } | |
| 597 | 613 | ||
| 598 | − | bool img_pan_edge(img_t *img, direction_t dir) { | |
| 614 | + | bool img_pan_edge(img_t *img, direction_t dir) | |
| 615 | + | { | |
| 599 | 616 | int ox, oy; | |
| 600 | 617 | ||
| 601 | 618 | if (img == NULL || img->im == NULL || img->win == NULL) | |
| @@ -629,7 +646,8 @@ bool img_pan_edge(img_t *img, direction_t dir) { | |||
| 629 | 646 | } | |
| 630 | 647 | } | |
| 631 | 648 | ||
| 632 | − | void img_rotate(img_t *img, int d) { | |
| 649 | + | void img_rotate(img_t *img, int d) | |
| 650 | + | { | |
| 633 | 651 | win_t *win; | |
| 634 | 652 | int ox, oy, tmp; | |
| 635 | 653 | ||
| @@ -654,15 +672,18 @@ void img_rotate(img_t *img, int d) { | |||
| 654 | 672 | img->dirty = true; | |
| 655 | 673 | } | |
| 656 | 674 | ||
| 657 | − | void img_rotate_left(img_t *img) { | |
| 675 | + | void img_rotate_left(img_t *img) | |
| 676 | + | { | |
| 658 | 677 | img_rotate(img, 3); | |
| 659 | 678 | } | |
| 660 | 679 | ||
| 661 | − | void img_rotate_right(img_t *img) { | |
| 680 | + | void img_rotate_right(img_t *img) | |
| 681 | + | { | |
| 662 | 682 | img_rotate(img, 1); | |
| 663 | 683 | } | |
| 664 | 684 | ||
| 665 | − | void img_flip(img_t *img, flipdir_t d) { | |
| 685 | + | void img_flip(img_t *img, flipdir_t d) | |
| 686 | + | { | |
| 666 | 687 | if (img == NULL || img->im == NULL) | |
| 667 | 688 | return; | |
| 668 | 689 | ||
| @@ -679,7 +700,8 @@ void img_flip(img_t *img, flipdir_t d) { | |||
| 679 | 700 | img->dirty = true; | |
| 680 | 701 | } | |
| 681 | 702 | ||
| 682 | − | void img_toggle_antialias(img_t *img) { | |
| 703 | + | void img_toggle_antialias(img_t *img) | |
| 704 | + | { | |
| 683 | 705 | if (img == NULL || img->im == NULL) | |
| 684 | 706 | return; | |
| 685 | 707 | ||
| @@ -689,7 +711,8 @@ void img_toggle_antialias(img_t *img) { | |||
| 689 | 711 | img->dirty = true; | |
| 690 | 712 | } | |
| 691 | 713 | ||
| 692 | − | bool img_frame_goto(img_t *img, int n) { | |
| 714 | + | bool img_frame_goto(img_t *img, int n) | |
| 715 | + | { | |
| 693 | 716 | if (img == NULL || img->im == NULL) | |
| 694 | 717 | return false; | |
| 695 | 718 | if (n < 0 || n >= img->multi.cnt || n == img->multi.sel) | |
| @@ -707,7 +730,8 @@ bool img_frame_goto(img_t *img, int n) { | |||
| 707 | 730 | return true; | |
| 708 | 731 | } | |
| 709 | 732 | ||
| 710 | − | bool img_frame_navigate(img_t *img, int d) { | |
| 733 | + | bool img_frame_navigate(img_t *img, int d) | |
| 734 | + | { | |
| 711 | 735 | if (img == NULL|| img->im == NULL || img->multi.cnt == 0 || d == 0) | |
| 712 | 736 | return false; | |
| 713 | 737 | ||
| @@ -720,7 +744,8 @@ bool img_frame_navigate(img_t *img, int d) { | |||
| 720 | 744 | return img_frame_goto(img, d); | |
| 721 | 745 | } | |
| 722 | 746 | ||
| 723 | − | bool img_frame_animate(img_t *img, bool restart) { | |
| 747 | + | bool img_frame_animate(img_t *img, bool restart) | |
| 748 | + | { | |
| 724 | 749 | if (img == NULL || img->im == NULL || img->multi.cnt == 0) | |
| 725 | 750 | return false; | |
| 726 | 751 | ||
| @@ -85,7 +85,8 @@ timeout_t timeouts[] = { | |||
| 85 | 85 | { { 0, 0 }, false, clear_resize }, | |
| 86 | 86 | }; | |
| 87 | 87 | ||
| 88 | − | void cleanup(void) { | |
| 88 | + | void cleanup(void) | |
| 89 | + | { | |
| 89 | 90 | static bool in = false; | |
| 90 | 91 | ||
| 91 | 92 | if (!in) { | |
| @@ -96,7 +97,8 @@ void cleanup(void) { | |||
| 96 | 97 | } | |
| 97 | 98 | } | |
| 98 | 99 | ||
| 99 | − | void check_add_file(char *filename) { | |
| 100 | + | void check_add_file(char *filename) | |
| 101 | + | { | |
| 100 | 102 | const char *bn; | |
| 101 | 103 | ||
| 102 | 104 | if (filename == NULL || *filename == '\0') | |
| @@ -129,7 +131,8 @@ void check_add_file(char *filename) { | |||
| 129 | 131 | fileidx++; | |
| 130 | 132 | } | |
| 131 | 133 | ||
| 132 | − | void remove_file(int n, bool manual) { | |
| 134 | + | void remove_file(int n, bool manual) | |
| 135 | + | { | |
| 133 | 136 | if (n < 0 || n >= filecnt) | |
| 134 | 137 | return; | |
| 135 | 138 | ||
| @@ -157,7 +160,8 @@ void remove_file(int n, bool manual) { | |||
| 157 | 160 | tns.cnt--; | |
| 158 | 161 | } | |
| 159 | 162 | ||
| 160 | − | void set_timeout(timeout_f handler, int time, bool overwrite) { | |
| 163 | + | void set_timeout(timeout_f handler, int time, bool overwrite) | |
| 164 | + | { | |
| 161 | 165 | int i; | |
| 162 | 166 | ||
| 163 | 167 | for (i = 0; i < ARRLEN(timeouts); i++) { | |
| @@ -172,7 +176,8 @@ void set_timeout(timeout_f handler, int time, bool overwrite) { | |||
| 172 | 176 | } | |
| 173 | 177 | } | |
| 174 | 178 | ||
| 175 | − | void reset_timeout(timeout_f handler) { | |
| 179 | + | void reset_timeout(timeout_f handler) | |
| 180 | + | { | |
| 176 | 181 | int i; | |
| 177 | 182 | ||
| 178 | 183 | for (i = 0; i < ARRLEN(timeouts); i++) { | |
| @@ -183,7 +188,8 @@ void reset_timeout(timeout_f handler) { | |||
| 183 | 188 | } | |
| 184 | 189 | } | |
| 185 | 190 | ||
| 186 | − | bool check_timeouts(struct timeval *t) { | |
| 191 | + | bool check_timeouts(struct timeval *t) | |
| 192 | + | { | |
| 187 | 193 | int i = 0, tdiff, tmin = -1; | |
| 188 | 194 | struct timeval now; | |
| 189 | 195 | ||
| @@ -207,7 +213,8 @@ bool check_timeouts(struct timeval *t) { | |||
| 207 | 213 | return tmin > 0; | |
| 208 | 214 | } | |
| 209 | 215 | ||
| 210 | − | void read_info(void) { | |
| 216 | + | void read_info(void) | |
| 217 | + | { | |
| 211 | 218 | char cmd[4096]; | |
| 212 | 219 | FILE *outp; | |
| 213 | 220 | int c, i = 0, n = sizeof(bar.l) - 1; | |
| @@ -237,7 +244,8 @@ end: | |||
| 237 | 244 | bar.l[i] = '\0'; | |
| 238 | 245 | } | |
| 239 | 246 | ||
| 240 | − | void load_image(int new) { | |
| 247 | + | void load_image(int new) | |
| 248 | + | { | |
| 241 | 249 | if (new < 0 || new >= filecnt) | |
| 242 | 250 | return; | |
| 243 | 251 | ||
| @@ -262,7 +270,8 @@ void load_image(int new) { | |||
| 262 | 270 | reset_timeout(animate); | |
| 263 | 271 | } | |
| 264 | 272 | ||
| 265 | − | void update_info(void) { | |
| 273 | + | void update_info(void) | |
| 274 | + | { | |
| 266 | 275 | unsigned int i, fn, fw, n, len = sizeof(bar.r); | |
| 267 | 276 | int sel; | |
| 268 | 277 | char *t = bar.r, title[TITLE_LEN]; | |
| @@ -310,7 +319,8 @@ void update_info(void) { | |||
| 310 | 319 | win_set_bar_info(&win, bar.l, bar.r); | |
| 311 | 320 | } | |
| 312 | 321 | ||
| 313 | − | void redraw(void) { | |
| 322 | + | void redraw(void) | |
| 323 | + | { | |
| 314 | 324 | if (mode == MODE_IMAGE) | |
| 315 | 325 | img_render(&img); | |
| 316 | 326 | else | |
| @@ -321,7 +331,8 @@ void redraw(void) { | |||
| 321 | 331 | reset_cursor(); | |
| 322 | 332 | } | |
| 323 | 333 | ||
| 324 | − | void reset_cursor(void) { | |
| 334 | + | void reset_cursor(void) | |
| 335 | + | { | |
| 325 | 336 | int i; | |
| 326 | 337 | cursor_t cursor = CURSOR_NONE; | |
| 327 | 338 | ||
| @@ -342,27 +353,32 @@ void reset_cursor(void) { | |||
| 342 | 353 | win_set_cursor(&win, cursor); | |
| 343 | 354 | } | |
| 344 | 355 | ||
| 345 | − | void animate(void) { | |
| 356 | + | void animate(void) | |
| 357 | + | { | |
| 346 | 358 | if (img_frame_animate(&img, false)) { | |
| 347 | 359 | redraw(); | |
| 348 | 360 | set_timeout(animate, img.multi.frames[img.multi.sel].delay, true); | |
| 349 | 361 | } | |
| 350 | 362 | } | |
| 351 | 363 | ||
| 352 | − | void clear_resize(void) { | |
| 364 | + | void clear_resize(void) | |
| 365 | + | { | |
| 353 | 366 | resized = false; | |
| 354 | 367 | } | |
| 355 | 368 | ||
| 356 | − | bool keymask(const keymap_t *k, unsigned int state) { | |
| 369 | + | bool keymask(const keymap_t *k, unsigned int state) | |
| 370 | + | { | |
| 357 | 371 | return (k->ctrl ? ControlMask : 0) == (state & ControlMask); | |
| 358 | 372 | } | |
| 359 | 373 | ||
| 360 | − | bool buttonmask(const button_t *b, unsigned int state) { | |
| 374 | + | bool buttonmask(const button_t *b, unsigned int state) | |
| 375 | + | { | |
| 361 | 376 | return ((b->ctrl ? ControlMask : 0) | (b->shift ? ShiftMask : 0)) == | |
| 362 | 377 | (state & (ControlMask | ShiftMask)); | |
| 363 | 378 | } | |
| 364 | 379 | ||
| 365 | − | void on_keypress(XKeyEvent *kev) { | |
| 380 | + | void on_keypress(XKeyEvent *kev) | |
| 381 | + | { | |
| 366 | 382 | int i; | |
| 367 | 383 | KeySym ksym; | |
| 368 | 384 | char key; | |
| @@ -390,7 +406,8 @@ void on_keypress(XKeyEvent *kev) { | |||
| 390 | 406 | } | |
| 391 | 407 | } | |
| 392 | 408 | ||
| 393 | − | void on_buttonpress(XButtonEvent *bev) { | |
| 409 | + | void on_buttonpress(XButtonEvent *bev) | |
| 410 | + | { | |
| 394 | 411 | int i, sel; | |
| 395 | 412 | ||
| 396 | 413 | if (bev == NULL) | |
| @@ -437,7 +454,8 @@ void on_buttonpress(XButtonEvent *bev) { | |||
| 437 | 454 | } | |
| 438 | 455 | } | |
| 439 | 456 | ||
| 440 | − | void run(void) { | |
| 457 | + | void run(void) | |
| 458 | + | { | |
| 441 | 459 | int xfd; | |
| 442 | 460 | fd_set fds; | |
| 443 | 461 | struct timeval timeout; | |
| @@ -532,11 +550,13 @@ void run(void) { | |||
| 532 | 550 | } | |
| 533 | 551 | } | |
| 534 | 552 | ||
| 535 | − | int fncmp(const void *a, const void *b) { | |
| 553 | + | int fncmp(const void *a, const void *b) | |
| 554 | + | { | |
| 536 | 555 | return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name); | |
| 537 | 556 | } | |
| 538 | 557 | ||
| 539 | − | int main(int argc, char **argv) { | |
| 558 | + | int main(int argc, char **argv) | |
| 559 | + | { | |
| 540 | 560 | int i, start; | |
| 541 | 561 | size_t n; | |
| 542 | 562 | ssize_t len; | |
| @@ -31,16 +31,19 @@ | |||
| 31 | 31 | options_t _options; | |
| 32 | 32 | const options_t *options = (const options_t*) &_options; | |
| 33 | 33 | ||
| 34 | − | void print_usage(void) { | |
| 34 | + | void print_usage(void) | |
| 35 | + | { | |
| 35 | 36 | printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] " | |
| 36 | 37 | "[-N name] [-z ZOOM] FILES...\n"); | |
| 37 | 38 | } | |
| 38 | 39 | ||
| 39 | − | void print_version(void) { | |
| 40 | + | void print_version(void) | |
| 41 | + | { | |
| 40 | 42 | printf("sxiv %s - Simple X Image Viewer\n", VERSION); | |
| 41 | 43 | } | |
| 42 | 44 | ||
| 43 | − | void parse_options(int argc, char **argv) { | |
| 45 | + | void parse_options(int argc, char **argv) | |
| 46 | + | { | |
| 44 | 47 | int opt, t; | |
| 45 | 48 | ||
| 46 | 49 | _options.recursive = false; | |
| @@ -36,14 +36,16 @@ static const int thumb_dim = THUMB_SIZE + 10; | |||
| 36 | 36 | static const char * const CACHE_DIR = ".sxiv/cache"; | |
| 37 | 37 | static char *cache_dir = NULL; | |
| 38 | 38 | ||
| 39 | − | bool tns_cache_enabled(void) { | |
| 39 | + | bool tns_cache_enabled(void) | |
| 40 | + | { | |
| 40 | 41 | struct stat stats; | |
| 41 | 42 | ||
| 42 | 43 | return cache_dir != NULL && stat(cache_dir, &stats) == 0 && | |
| 43 | 44 | S_ISDIR(stats.st_mode) && access(cache_dir, W_OK) == 0; | |
| 44 | 45 | } | |
| 45 | 46 | ||
| 46 | − | char* tns_cache_filepath(const char *filepath) { | |
| 47 | + | char* tns_cache_filepath(const char *filepath) | |
| 48 | + | { | |
| 47 | 49 | size_t len; | |
| 48 | 50 | char *cfile = NULL; | |
| 49 | 51 | ||
| @@ -59,7 +61,8 @@ char* tns_cache_filepath(const char *filepath) { | |||
| 59 | 61 | return cfile; | |
| 60 | 62 | } | |
| 61 | 63 | ||
| 62 | − | Imlib_Image* tns_cache_load(const char *filepath) { | |
| 64 | + | Imlib_Image* tns_cache_load(const char *filepath) | |
| 65 | + | { | |
| 63 | 66 | char *cfile; | |
| 64 | 67 | struct stat cstats, fstats; | |
| 65 | 68 | Imlib_Image *im = NULL; | |
| @@ -77,7 +80,8 @@ Imlib_Image* tns_cache_load(const char *filepath) { | |||
| 77 | 80 | return im; | |
| 78 | 81 | } | |
| 79 | 82 | ||
| 80 | − | void tns_cache_write(thumb_t *t, bool force) { | |
| 83 | + | void tns_cache_write(thumb_t *t, bool force) | |
| 84 | + | { | |
| 81 | 85 | char *cfile, *dirend; | |
| 82 | 86 | struct stat cstats, fstats; | |
| 83 | 87 | struct utimbuf times; | |
| @@ -118,7 +122,8 @@ void tns_cache_write(thumb_t *t, bool force) { | |||
| 118 | 122 | } | |
| 119 | 123 | } | |
| 120 | 124 | ||
| 121 | − | void tns_clean_cache(tns_t *tns) { | |
| 125 | + | void tns_clean_cache(tns_t *tns) | |
| 126 | + | { | |
| 122 | 127 | int dirlen; | |
| 123 | 128 | bool delete; | |
| 124 | 129 | char *cfile, *filename, *tpos; | |
| @@ -154,7 +159,8 @@ void tns_clean_cache(tns_t *tns) { | |||
| 154 | 159 | } | |
| 155 | 160 | ||
| 156 | 161 | ||
| 157 | − | void tns_init(tns_t *tns, int cnt, win_t *win) { | |
| 162 | + | void tns_init(tns_t *tns, int cnt, win_t *win) | |
| 163 | + | { | |
| 158 | 164 | int len; | |
| 159 | 165 | char *homedir; | |
| 160 | 166 | ||
| @@ -185,7 +191,8 @@ void tns_init(tns_t *tns, int cnt, win_t *win) { | |||
| 185 | 191 | } | |
| 186 | 192 | } | |
| 187 | 193 | ||
| 188 | − | void tns_free(tns_t *tns) { | |
| 194 | + | void tns_free(tns_t *tns) | |
| 195 | + | { | |
| 189 | 196 | int i; | |
| 190 | 197 | ||
| 191 | 198 | if (tns == NULL) | |
| @@ -282,7 +289,8 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file, | |||
| 282 | 289 | return true; | |
| 283 | 290 | } | |
| 284 | 291 | ||
| 285 | − | void tns_check_view(tns_t *tns, bool scrolled) { | |
| 292 | + | void tns_check_view(tns_t *tns, bool scrolled) | |
| 293 | + | { | |
| 286 | 294 | int r; | |
| 287 | 295 | ||
| 288 | 296 | if (tns == NULL) | |
| @@ -309,7 +317,8 @@ void tns_check_view(tns_t *tns, bool scrolled) { | |||
| 309 | 317 | } | |
| 310 | 318 | } | |
| 311 | 319 | ||
| 312 | − | void tns_render(tns_t *tns) { | |
| 320 | + | void tns_render(tns_t *tns) | |
| 321 | + | { | |
| 313 | 322 | thumb_t *t; | |
| 314 | 323 | win_t *win; | |
| 315 | 324 | int i, cnt, r, x, y; | |
| @@ -364,7 +373,8 @@ void tns_render(tns_t *tns) { | |||
| 364 | 373 | tns_highlight(tns, tns->sel, true); | |
| 365 | 374 | } | |
| 366 | 375 | ||
| 367 | − | void tns_highlight(tns_t *tns, int n, bool hl) { | |
| 376 | + | void tns_highlight(tns_t *tns, int n, bool hl) | |
| 377 | + | { | |
| 368 | 378 | thumb_t *t; | |
| 369 | 379 | win_t *win; | |
| 370 | 380 | int x, y; | |
| @@ -392,7 +402,8 @@ void tns_highlight(tns_t *tns, int n, bool hl) { | |||
| 392 | 402 | } | |
| 393 | 403 | } | |
| 394 | 404 | ||
| 395 | − | bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) { | |
| 405 | + | bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) | |
| 406 | + | { | |
| 396 | 407 | int old, max; | |
| 397 | 408 | ||
| 398 | 409 | if (tns == NULL || tns->thumbs == NULL) | |
| @@ -427,7 +438,8 @@ bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) { | |||
| 427 | 438 | return tns->sel != old; | |
| 428 | 439 | } | |
| 429 | 440 | ||
| 430 | − | bool tns_scroll(tns_t *tns, direction_t dir, bool screen) { | |
| 441 | + | bool tns_scroll(tns_t *tns, direction_t dir, bool screen) | |
| 442 | + | { | |
| 431 | 443 | int d, max, old; | |
| 432 | 444 | ||
| 433 | 445 | if (tns == NULL) | |
| @@ -452,7 +464,8 @@ bool tns_scroll(tns_t *tns, direction_t dir, bool screen) { | |||
| 452 | 464 | return tns->first != old; | |
| 453 | 465 | } | |
| 454 | 466 | ||
| 455 | − | int tns_translate(tns_t *tns, int x, int y) { | |
| 467 | + | int tns_translate(tns_t *tns, int x, int y) | |
| 468 | + | { | |
| 456 | 469 | int n; | |
| 457 | 470 | ||
| 458 | 471 | if (tns == NULL || tns->thumbs == NULL) | |
| @@ -36,7 +36,8 @@ enum { | |||
| 36 | 36 | ||
| 37 | 37 | void cleanup(void); | |
| 38 | 38 | ||
| 39 | − | void* s_malloc(size_t size) { | |
| 39 | + | void* s_malloc(size_t size) | |
| 40 | + | { | |
| 40 | 41 | void *ptr; | |
| 41 | 42 | ||
| 42 | 43 | ptr = malloc(size); | |
| @@ -45,14 +46,16 @@ void* s_malloc(size_t size) { | |||
| 45 | 46 | return ptr; | |
| 46 | 47 | } | |
| 47 | 48 | ||
| 48 | − | void* s_realloc(void *ptr, size_t size) { | |
| 49 | + | void* s_realloc(void *ptr, size_t size) | |
| 50 | + | { | |
| 49 | 51 | ptr = realloc(ptr, size); | |
| 50 | 52 | if (ptr == NULL) | |
| 51 | 53 | die("could not allocate memory"); | |
| 52 | 54 | return ptr; | |
| 53 | 55 | } | |
| 54 | 56 | ||
| 55 | − | char* s_strdup(char *s) { | |
| 57 | + | char* s_strdup(char *s) | |
| 58 | + | { | |
| 56 | 59 | char *d = NULL; | |
| 57 | 60 | ||
| 58 | 61 | if (s != NULL) { | |
| @@ -64,7 +67,8 @@ char* s_strdup(char *s) { | |||
| 64 | 67 | return d; | |
| 65 | 68 | } | |
| 66 | 69 | ||
| 67 | − | void warn(const char* fmt, ...) { | |
| 70 | + | void warn(const char* fmt, ...) | |
| 71 | + | { | |
| 68 | 72 | va_list args; | |
| 69 | 73 | ||
| 70 | 74 | if (fmt == NULL || options->quiet) | |
| @@ -77,7 +81,8 @@ void warn(const char* fmt, ...) { | |||
| 77 | 81 | va_end(args); | |
| 78 | 82 | } | |
| 79 | 83 | ||
| 80 | − | void die(const char* fmt, ...) { | |
| 84 | + | void die(const char* fmt, ...) | |
| 85 | + | { | |
| 81 | 86 | va_list args; | |
| 82 | 87 | ||
| 83 | 88 | if (fmt == NULL) | |
| @@ -93,7 +98,8 @@ void die(const char* fmt, ...) { | |||
| 93 | 98 | exit(EXIT_FAILURE); | |
| 94 | 99 | } | |
| 95 | 100 | ||
| 96 | − | ssize_t get_line(char **buf, size_t *n, FILE *stream) { | |
| 101 | + | ssize_t get_line(char **buf, size_t *n, FILE *stream) | |
| 102 | + | { | |
| 97 | 103 | size_t len; | |
| 98 | 104 | char *s; | |
| 99 | 105 | ||
| @@ -125,7 +131,8 @@ ssize_t get_line(char **buf, size_t *n, FILE *stream) { | |||
| 125 | 131 | return s - *buf + len; | |
| 126 | 132 | } | |
| 127 | 133 | ||
| 128 | − | void size_readable(float *size, const char **unit) { | |
| 134 | + | void size_readable(float *size, const char **unit) | |
| 135 | + | { | |
| 129 | 136 | const char *units[] = { "", "K", "M", "G" }; | |
| 130 | 137 | int i; | |
| 131 | 138 | ||
| @@ -134,7 +141,8 @@ void size_readable(float *size, const char **unit) { | |||
| 134 | 141 | *unit = units[MIN(i, ARRLEN(units) - 1)]; | |
| 135 | 142 | } | |
| 136 | 143 | ||
| 137 | − | char* absolute_path(const char *filename) { | |
| 144 | + | char* absolute_path(const char *filename) | |
| 145 | + | { | |
| 138 | 146 | size_t len; | |
| 139 | 147 | const char *basename; | |
| 140 | 148 | char *dir, *dirname = NULL, *path = NULL, *s; | |
| @@ -206,7 +214,8 @@ end: | |||
| 206 | 214 | return path; | |
| 207 | 215 | } | |
| 208 | 216 | ||
| 209 | − | int r_opendir(r_dir_t *rdir, const char *dirname) { | |
| 217 | + | int r_opendir(r_dir_t *rdir, const char *dirname) | |
| 218 | + | { | |
| 210 | 219 | if (rdir == NULL || dirname == NULL || *dirname == '\0') | |
| 211 | 220 | return -1; | |
| 212 | 221 | ||
| @@ -226,7 +235,8 @@ int r_opendir(r_dir_t *rdir, const char *dirname) { | |||
| 226 | 235 | return 0; | |
| 227 | 236 | } | |
| 228 | 237 | ||
| 229 | − | int r_closedir(r_dir_t *rdir) { | |
| 238 | + | int r_closedir(r_dir_t *rdir) | |
| 239 | + | { | |
| 230 | 240 | int ret = 0; | |
| 231 | 241 | ||
| 232 | 242 | if (rdir == NULL) | |
| @@ -252,7 +262,8 @@ int r_closedir(r_dir_t *rdir) { | |||
| 252 | 262 | return ret; | |
| 253 | 263 | } | |
| 254 | 264 | ||
| 255 | − | char* r_readdir(r_dir_t *rdir) { | |
| 265 | + | char* r_readdir(r_dir_t *rdir) | |
| 266 | + | { | |
| 256 | 267 | size_t len; | |
| 257 | 268 | char *filename; | |
| 258 | 269 | struct dirent *dentry; | |
| @@ -304,7 +315,8 @@ char* r_readdir(r_dir_t *rdir) { | |||
| 304 | 315 | return NULL; | |
| 305 | 316 | } | |
| 306 | 317 | ||
| 307 | − | int r_mkdir(const char *path) { | |
| 318 | + | int r_mkdir(const char *path) | |
| 319 | + | { | |
| 308 | 320 | char *dir, *d; | |
| 309 | 321 | struct stat stats; | |
| 310 | 322 | int err = 0; | |
| @@ -52,7 +52,8 @@ static struct { | |||
| 52 | 52 | static int fontheight; | |
| 53 | 53 | static int barheight; | |
| 54 | 54 | ||
| 55 | − | void win_init_font(Display *dpy, const char *fontstr) { | |
| 55 | + | void win_init_font(Display *dpy, const char *fontstr) | |
| 56 | + | { | |
| 56 | 57 | int n; | |
| 57 | 58 | char *def, **missing; | |
| 58 | 59 | ||
| @@ -84,7 +85,8 @@ void win_init_font(Display *dpy, const char *fontstr) { | |||
| 84 | 85 | barheight = fontheight + 2 * V_TEXT_PAD; | |
| 85 | 86 | } | |
| 86 | 87 | ||
| 87 | − | unsigned long win_alloc_color(win_t *win, const char *name) { | |
| 88 | + | unsigned long win_alloc_color(win_t *win, const char *name) | |
| 89 | + | { | |
| 88 | 90 | XColor col; | |
| 89 | 91 | ||
| 90 | 92 | if (win == NULL) | |
| @@ -98,7 +100,8 @@ unsigned long win_alloc_color(win_t *win, const char *name) { | |||
| 98 | 100 | return col.pixel; | |
| 99 | 101 | } | |
| 100 | 102 | ||
| 101 | − | void win_init(win_t *win) { | |
| 103 | + | void win_init(win_t *win) | |
| 104 | + | { | |
| 102 | 105 | win_env_t *e; | |
| 103 | 106 | ||
| 104 | 107 | if (win == NULL) | |
| @@ -132,7 +135,8 @@ void win_init(win_t *win) { | |||
| 132 | 135 | wm_delete_win = XInternAtom(e->dpy, "WM_DELETE_WINDOW", False); | |
| 133 | 136 | } | |
| 134 | 137 | ||
| 135 | − | void win_set_sizehints(win_t *win) { | |
| 138 | + | void win_set_sizehints(win_t *win) | |
| 139 | + | { | |
| 136 | 140 | XSizeHints sizehints; | |
| 137 | 141 | ||
| 138 | 142 | if (win == NULL || win->xwin == None) | |
| @@ -146,7 +150,8 @@ void win_set_sizehints(win_t *win) { | |||
| 146 | 150 | XSetWMNormalHints(win->env.dpy, win->xwin, &sizehints); | |
| 147 | 151 | } | |
| 148 | 152 | ||
| 149 | − | void win_open(win_t *win) { | |
| 153 | + | void win_open(win_t *win) | |
| 154 | + | { | |
| 150 | 155 | win_env_t *e; | |
| 151 | 156 | XClassHint classhint; | |
| 152 | 157 | XColor col; | |
| @@ -229,7 +234,8 @@ void win_open(win_t *win) { | |||
| 229 | 234 | win_toggle_fullscreen(win); | |
| 230 | 235 | } | |
| 231 | 236 | ||
| 232 | − | void win_close(win_t *win) { | |
| 237 | + | void win_close(win_t *win) | |
| 238 | + | { | |
| 233 | 239 | if (win == NULL || win->xwin == None) | |
| 234 | 240 | return; | |
| 235 | 241 | ||
| @@ -244,7 +250,8 @@ void win_close(win_t *win) { | |||
| 244 | 250 | XCloseDisplay(win->env.dpy); | |
| 245 | 251 | } | |
| 246 | 252 | ||
| 247 | − | bool win_configure(win_t *win, XConfigureEvent *c) { | |
| 253 | + | bool win_configure(win_t *win, XConfigureEvent *c) | |
| 254 | + | { | |
| 248 | 255 | bool changed; | |
| 249 | 256 | ||
| 250 | 257 | if (win == NULL || c == NULL) | |
| @@ -266,7 +273,8 @@ bool win_configure(win_t *win, XConfigureEvent *c) { | |||
| 266 | 273 | return changed; | |
| 267 | 274 | } | |
| 268 | 275 | ||
| 269 | − | void win_expose(win_t *win, XExposeEvent *e) { | |
| 276 | + | void win_expose(win_t *win, XExposeEvent *e) | |
| 277 | + | { | |
| 270 | 278 | if (win == NULL || win->xwin == None || win->pm == None || e == NULL) | |
| 271 | 279 | return; | |
| 272 | 280 | ||
| @@ -274,7 +282,8 @@ void win_expose(win_t *win, XExposeEvent *e) { | |||
| 274 | 282 | e->x, e->y, e->width, e->height, e->x, e->y); | |
| 275 | 283 | } | |
| 276 | 284 | ||
| 277 | − | bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) { | |
| 285 | + | bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) | |
| 286 | + | { | |
| 278 | 287 | if (win == NULL || win->xwin == None) | |
| 279 | 288 | return false; | |
| 280 | 289 | ||
| @@ -299,7 +308,8 @@ bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) { | |||
| 299 | 308 | return true; | |
| 300 | 309 | } | |
| 301 | 310 | ||
| 302 | − | void win_toggle_fullscreen(win_t *win) { | |
| 311 | + | void win_toggle_fullscreen(win_t *win) | |
| 312 | + | { | |
| 303 | 313 | XEvent ev; | |
| 304 | 314 | XClientMessageEvent *cm; | |
| 305 | 315 | ||
| @@ -323,7 +333,8 @@ void win_toggle_fullscreen(win_t *win) { | |||
| 323 | 333 | SubstructureNotifyMask | SubstructureRedirectMask, &ev); | |
| 324 | 334 | } | |
| 325 | 335 | ||
| 326 | − | void win_toggle_bar(win_t *win) { | |
| 336 | + | void win_toggle_bar(win_t *win) | |
| 337 | + | { | |
| 327 | 338 | if (win == NULL || win->xwin == None) | |
| 328 | 339 | return; | |
| 329 | 340 | ||
| @@ -336,7 +347,8 @@ void win_toggle_bar(win_t *win) { | |||
| 336 | 347 | } | |
| 337 | 348 | } | |
| 338 | 349 | ||
| 339 | − | void win_clear(win_t *win) { | |
| 350 | + | void win_clear(win_t *win) | |
| 351 | + | { | |
| 340 | 352 | int h; | |
| 341 | 353 | win_env_t *e; | |
| 342 | 354 | ||
| @@ -353,7 +365,8 @@ void win_clear(win_t *win) { | |||
| 353 | 365 | XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h); | |
| 354 | 366 | } | |
| 355 | 367 | ||
| 356 | − | void win_draw_bar(win_t *win) { | |
| 368 | + | void win_draw_bar(win_t *win) | |
| 369 | + | { | |
| 357 | 370 | int len, olen, x, y, w, tw; | |
| 358 | 371 | char rest[3]; | |
| 359 | 372 | const char *dots = "..."; | |
| @@ -408,7 +421,8 @@ void win_draw_bar(win_t *win) { | |||
| 408 | 421 | } | |
| 409 | 422 | } | |
| 410 | 423 | ||
| 411 | − | void win_draw(win_t *win) { | |
| 424 | + | void win_draw(win_t *win) | |
| 425 | + | { | |
| 412 | 426 | if (win == NULL || win->xwin == None || win->pm == None) | |
| 413 | 427 | return; | |
| 414 | 428 | ||
| @@ -437,7 +451,8 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h, | |||
| 437 | 451 | XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h); | |
| 438 | 452 | } | |
| 439 | 453 | ||
| 440 | − | int win_textwidth(const char *text, unsigned int len, bool with_padding) { | |
| 454 | + | int win_textwidth(const char *text, unsigned int len, bool with_padding) | |
| 455 | + | { | |
| 441 | 456 | XRectangle r; | |
| 442 | 457 | int padding = with_padding ? 2 * H_TEXT_PAD : 0; | |
| 443 | 458 | ||
| @@ -449,7 +464,8 @@ int win_textwidth(const char *text, unsigned int len, bool with_padding) { | |||
| 449 | 464 | } | |
| 450 | 465 | } | |
| 451 | 466 | ||
| 452 | − | void win_set_title(win_t *win, const char *title) { | |
| 467 | + | void win_set_title(win_t *win, const char *title) | |
| 468 | + | { | |
| 453 | 469 | if (win == NULL || win->xwin == None) | |
| 454 | 470 | return; | |
| 455 | 471 | ||
| @@ -469,14 +485,16 @@ void win_set_title(win_t *win, const char *title) { | |||
| 469 | 485 | PropModeReplace, (unsigned char *) title, strlen(title)); | |
| 470 | 486 | } | |
| 471 | 487 | ||
| 472 | − | void win_set_bar_info(win_t *win, char *linfo, char *rinfo) { | |
| 488 | + | void win_set_bar_info(win_t *win, char *linfo, char *rinfo) | |
| 489 | + | { | |
| 473 | 490 | if (win != NULL) { | |
| 474 | 491 | win->bar.l = linfo; | |
| 475 | 492 | win->bar.r = rinfo; | |
| 476 | 493 | } | |
| 477 | 494 | } | |
| 478 | 495 | ||
| 479 | − | void win_set_cursor(win_t *win, cursor_t cursor) { | |
| 496 | + | void win_set_cursor(win_t *win, cursor_t cursor) | |
| 497 | + | { | |
| 480 | 498 | if (win == NULL || win->xwin == None) | |
| 481 | 499 | return; | |
| 482 | 500 | ||