Auto-refresh views when changes are detected in the repository
[tig.git] / include / tig / options.h
blob986baee7dde1ec6becf2915189fe444e8729a52b
1 /* Copyright (c) 2006-2014 Jonas Fonseca <jonas.fonseca@gmail.com>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef TIG_OPTIONS_H
15 #define TIG_OPTIONS_H
17 #include "tig/tig.h"
18 #include "tig/util.h"
19 #include "tig/line.h"
22 * Option variables.
25 #define OPTION_INFO(_) \
26 _(blame_options, const char **, VIEW_BLAME_LIKE) \
27 _(blame_view, const char **, VIEW_NO_FLAGS) \
28 _(blob_view, const char **, VIEW_NO_FLAGS) \
29 _(commit_order, enum commit_order, VIEW_LOG_LIKE) \
30 _(diff_context, int, VIEW_DIFF_LIKE) \
31 _(diff_options, const char **, VIEW_DIFF_LIKE) \
32 _(diff_view, const char **, VIEW_NO_FLAGS) \
33 _(editor_line_number, bool, VIEW_NO_FLAGS) \
34 _(file_filter, bool, VIEW_DIFF_LIKE | VIEW_LOG_LIKE) \
35 _(focus_child, bool, VIEW_NO_FLAGS) \
36 _(git_colors, const char **, VIEW_NO_FLAGS) \
37 _(grep_view, const char **, VIEW_NO_FLAGS) \
38 _(horizontal_scroll, double, VIEW_NO_FLAGS) \
39 _(id_width, int, VIEW_NO_FLAGS) \
40 _(ignore_case, bool, VIEW_NO_FLAGS) \
41 _(ignore_space, enum ignore_space, VIEW_DIFF_LIKE) \
42 _(line_graphics, enum graphic, VIEW_NO_FLAGS) \
43 _(log_view, const char **, VIEW_NO_FLAGS) \
44 _(main_view, const char **, VIEW_NO_FLAGS) \
45 _(mouse, bool, VIEW_NO_FLAGS) \
46 _(mouse_scroll, int, VIEW_NO_FLAGS) \
47 _(pager_view, const char **, VIEW_NO_FLAGS) \
48 _(refs_view, const char **, VIEW_NO_FLAGS) \
49 _(show_changes, bool, VIEW_NO_FLAGS) \
50 _(show_notes, bool, VIEW_NO_FLAGS) \
51 _(split_view_height, double, VIEW_RESET_DISPLAY) \
52 _(stage_view, const char **, VIEW_NO_FLAGS) \
53 _(status_untracked_dirs, bool, VIEW_STATUS_LIKE) \
54 _(status_view, const char **, VIEW_NO_FLAGS) \
55 _(stash_view, const char **, VIEW_NO_FLAGS) \
56 _(tab_size, int, VIEW_NO_FLAGS) \
57 _(tree_view, const char **, VIEW_NO_FLAGS) \
58 _(refresh_mode, enum refresh_mode, VIEW_NO_FLAGS) \
59 _(refresh_interval, int, VIEW_NO_FLAGS) \
60 _(vertical_split, enum vertical_split, VIEW_RESET_DISPLAY | VIEW_DIFF_LIKE) \
61 _(wrap_lines, bool, VIEW_NO_FLAGS) \
63 #define DEFINE_OPTION_EXTERNS(name, type, flags) extern type opt_##name;
64 OPTION_INFO(DEFINE_OPTION_EXTERNS);
67 * View column options.
70 #define AUTHOR_COLUMN_OPTIONS(_) \
71 _(display, enum author, VIEW_NO_FLAGS) \
72 _(width, int, VIEW_NO_FLAGS) \
74 #define COMMIT_TITLE_COLUMN_OPTIONS(_) \
75 _(display, bool, VIEW_NO_FLAGS) \
76 _(graph, bool, VIEW_LOG_LIKE) \
77 _(refs, bool, VIEW_NO_FLAGS) \
78 _(overflow, int, VIEW_NO_FLAGS) \
79 _(width, int, VIEW_NO_FLAGS) \
81 #define DATE_COLUMN_OPTIONS(_) \
82 _(display, enum date, VIEW_NO_FLAGS) \
83 _(width, int, VIEW_NO_FLAGS) \
85 #define FILE_NAME_COLUMN_OPTIONS(_) \
86 _(display, enum filename, VIEW_GREP_LIKE) \
87 _(width, int, VIEW_NO_FLAGS) \
89 #define FILE_SIZE_COLUMN_OPTIONS(_) \
90 _(display, enum file_size, VIEW_NO_FLAGS) \
91 _(width, int, VIEW_NO_FLAGS) \
93 #define ID_COLUMN_OPTIONS(_) \
94 _(display, bool, VIEW_NO_FLAGS) \
95 _(color, bool, VIEW_NO_FLAGS) \
96 _(width, int, VIEW_NO_FLAGS) \
98 #define LINE_NUMBER_COLUMN_OPTIONS(_) \
99 _(display, bool, VIEW_NO_FLAGS) \
100 _(interval, int, VIEW_NO_FLAGS) \
101 _(width, int, VIEW_NO_FLAGS) \
103 #define MODE_COLUMN_OPTIONS(_) \
104 _(display, bool, VIEW_NO_FLAGS) \
105 _(width, int, VIEW_NO_FLAGS) \
107 #define REF_COLUMN_OPTIONS(_) \
108 _(display, bool, VIEW_NO_FLAGS) \
109 _(width, int, VIEW_NO_FLAGS) \
111 #define SECTION_COLUMN_OPTIONS(_) \
112 _(type, enum line_type, VIEW_NO_FLAGS) \
113 _(text, const char *, VIEW_NO_FLAGS) \
115 #define STATUS_COLUMN_OPTIONS(_) \
116 _(display, enum status_label, VIEW_NO_FLAGS) \
117 _(width, int, VIEW_NO_FLAGS) \
119 #define TEXT_COLUMN_OPTIONS(_) \
120 _(display, bool, VIEW_NO_FLAGS) \
121 _(commit_title_overflow, int, VIEW_NO_FLAGS) \
122 _(width, int, VIEW_NO_FLAGS) \
124 #define COLUMN_OPTIONS(_) \
125 _(author, AUTHOR, AUTHOR_COLUMN_OPTIONS) \
126 _(commit_title, COMMIT_TITLE, COMMIT_TITLE_COLUMN_OPTIONS) \
127 _(date, DATE, DATE_COLUMN_OPTIONS) \
128 _(file_name, FILE_NAME, FILE_NAME_COLUMN_OPTIONS) \
129 _(file_size, FILE_SIZE, FILE_SIZE_COLUMN_OPTIONS) \
130 _(id, ID, ID_COLUMN_OPTIONS) \
131 _(line_number, LINE_NUMBER, LINE_NUMBER_COLUMN_OPTIONS) \
132 _(mode, MODE, MODE_COLUMN_OPTIONS) \
133 _(ref, REF, REF_COLUMN_OPTIONS) \
134 _(section, SECTION, SECTION_COLUMN_OPTIONS) \
135 _(status, STATUS, STATUS_COLUMN_OPTIONS) \
136 _(text, TEXT, TEXT_COLUMN_OPTIONS) \
138 #define DEFINE_COLUMN_OPTIONS_STRUCT_VALUE(name, type, flags) type name;
140 #define DEFINE_COLUMN_OPTIONS_STRUCT(name, id, options) \
141 struct name##_options { \
142 options(DEFINE_COLUMN_OPTIONS_STRUCT_VALUE) \
143 } name;
145 union view_column_options {
146 COLUMN_OPTIONS(DEFINE_COLUMN_OPTIONS_STRUCT);
150 * Global state variables.
153 extern iconv_t opt_iconv_out;
154 extern char opt_editor[SIZEOF_STR];
155 extern const char **opt_cmdline_argv;
156 extern const char **opt_rev_argv;
157 extern const char **opt_file_argv;
158 extern char opt_env_lines[64];
159 extern char opt_env_columns[64];
160 extern char *opt_env[];
163 * Mapping between options and command argument mapping.
166 void update_options_from_argv(const char *argv[]);
168 const char *ignore_space_arg();
169 const char *commit_order_arg();
170 const char *diff_context_arg();
171 const char *show_notes_arg();
174 * Option loading and parsing.
177 struct option_info {
178 const char *name;
179 size_t namelen;
180 const char *type;
181 void *value;
182 bool seen;
185 struct option_info *find_option_info(struct option_info *option, size_t options, const char *name);
186 enum status_code parse_option(struct option_info *option, const char *prefix, const char *arg);
187 enum status_code parse_int(int *opt, const char *arg, int min, int max);
188 enum status_code parse_step(double *opt, const char *arg);
189 enum status_code set_option(const char *opt, int argc, const char *argv[]);
190 int load_options(void);
191 int load_git_config(void);
193 #endif
194 /* vim: set ts=8 sw=8 noexpandtab: */