Krolyxon
Commit ff88908

Branches

Refs →

nsxivff88908

specify func argument and related cleanup (#183)

* specifies the function argument type in commands.h compared to leaving
  it unspecified. all the functions in cmd_t must have arg_t as it's
  argument.
* changes to commands.h will now trigger a rebuild - this restores old
  behavior prior to 12efa0e
* cg_quit now uses it's argument as exit status
* DestroyNotify invokes cg_quit rather than calling exit directly.
* Explicitly pass EXIT_SUCCESS to cgquit in keybinding
Author
N-R-K
Date
2021-12-19 23:05 +0600
Committer
GitHub · 2021-12-19 23:05 +0600
Parent
494578c
Commit
ff88908531a9d20667c6d08f01d7d887ebb60fe8

+40 −40

5 files changed

  1. M Makefile +1 −1
  2. M commands.c +2 −2
  3. M commands.h +34 −34
  4. M config.def.h +1 −1
  5. M main.c +2 −2
M Makefile View
@@ -64,7 +64,7 @@ nsxiv: $(OBJS)
6464 @echo "CC $@"
6565 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
6666
67−$(OBJS): Makefile nsxiv.h config.h
67+$(OBJS): Makefile nsxiv.h config.h commands.h
6868 options.o: version.h
6969 window.o: icon/data.h
7070
M commands.c View
@@ -52,7 +52,7 @@ extern int markidx;
5252 extern int prefix;
5353 extern bool extprefix;
5454
55−bool cg_quit(arg_t _)
55+bool cg_quit(arg_t status)
5656 {
5757 unsigned int i;
5858
@@ -62,7 +62,7 @@ bool cg_quit(arg_t _)
6262 printf("%s%c", files[i].name, options->using_null ? '\0' : '\n');
6363 }
6464 }
65− exit(EXIT_SUCCESS);
65+ exit(status);
6666 }
6767
6868 bool cg_switch_mode(arg_t _)
M commands.h View
@@ -3,42 +3,42 @@
33 #include <stdbool.h>
44
55 /* global */
6−bool cg_change_gamma();
7−bool cg_first();
8−bool cg_mark_range();
9−bool cg_n_or_last();
10−bool cg_navigate_marked();
11−bool cg_prefix_external();
12−bool cg_quit();
13−bool cg_reload_image();
14−bool cg_remove_image();
15−bool cg_reverse_marks();
16−bool cg_scroll_screen();
17−bool cg_switch_mode();
18−bool cg_toggle_bar();
19−bool cg_toggle_fullscreen();
20−bool cg_toggle_image_mark();
21−bool cg_unmark_all();
22−bool cg_zoom();
6+bool cg_change_gamma(arg_t);
7+bool cg_first(arg_t);
8+bool cg_mark_range(arg_t);
9+bool cg_n_or_last(arg_t);
10+bool cg_navigate_marked(arg_t);
11+bool cg_prefix_external(arg_t);
12+bool cg_quit(arg_t);
13+bool cg_reload_image(arg_t);
14+bool cg_remove_image(arg_t);
15+bool cg_reverse_marks(arg_t);
16+bool cg_scroll_screen(arg_t);
17+bool cg_switch_mode(arg_t);
18+bool cg_toggle_bar(arg_t);
19+bool cg_toggle_fullscreen(arg_t);
20+bool cg_toggle_image_mark(arg_t);
21+bool cg_unmark_all(arg_t);
22+bool cg_zoom(arg_t);
2323 /* image mode */
24−bool ci_alternate();
25−bool ci_cursor_navigate();
26−bool ci_drag();
27−bool ci_fit_to_win();
28−bool ci_flip();
29−bool ci_navigate();
30−bool ci_navigate_frame();
31−bool ci_rotate();
32−bool ci_scroll();
33−bool ci_scroll_to_edge();
34−bool ci_set_zoom();
35−bool ci_slideshow();
36−bool ci_toggle_alpha();
37−bool ci_toggle_animation();
24+bool ci_alternate(arg_t);
25+bool ci_cursor_navigate(arg_t);
26+bool ci_drag(arg_t);
27+bool ci_fit_to_win(arg_t);
28+bool ci_flip(arg_t);
29+bool ci_navigate(arg_t);
30+bool ci_navigate_frame(arg_t);
31+bool ci_rotate(arg_t);
32+bool ci_scroll(arg_t);
33+bool ci_scroll_to_edge(arg_t);
34+bool ci_set_zoom(arg_t);
35+bool ci_slideshow(arg_t);
36+bool ci_toggle_alpha(arg_t);
37+bool ci_toggle_animation(arg_t);
3838 bool ci_toggle_antialias();
3939 /* thumbnails mode */
40−bool ct_move_sel();
41−bool ct_reload_all();
40+bool ct_move_sel(arg_t);
41+bool ct_reload_all(arg_t);
4242
4343 /* global */
4444 #define g_change_gamma { cg_change_gamma, MODE_ALL }
@@ -80,4 +80,4 @@ bool ct_reload_all();
8080 #define t_move_sel { ct_move_sel, MODE_THUMB }
8181 #define t_reload_all { ct_reload_all, MODE_THUMB }
8282
83−#endif
83+#endif /* COMMANDS_H */
M config.def.h View
@@ -89,7 +89,7 @@ static const KeySym KEYHANDLER_ABORT = XK_Escape;
8989 /* keyboard mappings for image and thumbnail mode: */
9090 static const keymap_t keys[] = {
9191 /* modifiers key function argument */
92− { 0, XK_q, g_quit, None },
92+ { 0, XK_q, g_quit, EXIT_SUCCESS },
9393 { 0, XK_Return, g_switch_mode, None },
9494 { 0, XK_f, g_toggle_fullscreen, None },
9595 { 0, XK_b, g_toggle_bar, None },
M main.c View
@@ -802,10 +802,10 @@ static void run(void)
802802 break;
803803 case ClientMessage:
804804 if ((Atom) ev.xclient.data.l[0] == atoms[ATOM_WM_DELETE_WINDOW])
805− cg_quit();
805+ cg_quit(EXIT_SUCCESS);
806806 break;
807807 case DestroyNotify:
808− exit(EXIT_FAILURE);
808+ cg_quit(EXIT_FAILURE);
809809 break;
810810 case ConfigureNotify:
811811 if (win_configure(&win, &ev.xconfigure)) {