Add option to turn off automatic enabling of topo-order
[tig.git] / include / tig / options.h
blobd3899f0b07259717c84c651fc4cd7a1a7cb31bb3
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 _(cmdline_args, const char **, VIEW_NO_FLAGS) \
30 _(commit_order, enum commit_order, VIEW_LOG_LIKE) \
31 _(diff_context, int, VIEW_DIFF_LIKE) \
32 _(diff_options, const char **, VIEW_DIFF_LIKE) \
33 _(diff_view, const char **, VIEW_NO_FLAGS) \
34 _(editor_line_number, bool, VIEW_NO_FLAGS) \
35 _(file_args, const char **, VIEW_NO_FLAGS) \
36 _(file_filter, bool, VIEW_DIFF_LIKE | VIEW_LOG_LIKE) \
37 _(focus_child, bool, VIEW_NO_FLAGS) \
38 _(git_colors, const char **, VIEW_NO_FLAGS) \
39 _(grep_view, const char **, VIEW_NO_FLAGS) \
40 _(horizontal_scroll, double, VIEW_NO_FLAGS) \
41 _(id_width, int, VIEW_NO_FLAGS) \
42 _(ignore_case, bool, VIEW_NO_FLAGS) \
43 _(ignore_space, enum ignore_space, VIEW_DIFF_LIKE) \
44 _(line_graphics, enum graphic, VIEW_NO_FLAGS) \
45 _(log_options, const char **, VIEW_LOG_LIKE) \
46 _(log_view, const char **, VIEW_NO_FLAGS) \
47 _(main_view, const char **, VIEW_NO_FLAGS) \
48 _(mouse, bool, VIEW_NO_FLAGS) \
49 _(mouse_scroll, int, VIEW_NO_FLAGS) \
50 _(pager_view, const char **, VIEW_NO_FLAGS) \
51 _(refresh_interval, int, VIEW_NO_FLAGS) \
52 _(refresh_mode, enum refresh_mode, VIEW_NO_FLAGS) \
53 _(refs_view, const char **, VIEW_NO_FLAGS) \
54 _(rev_args, const char **, VIEW_NO_FLAGS) \
55 _(show_changes, bool, VIEW_NO_FLAGS) \
56 _(show_notes, bool, VIEW_NO_FLAGS) \
57 _(split_view_height, double, VIEW_RESET_DISPLAY) \
58 _(split_view_width, double, VIEW_RESET_DISPLAY) \
59 _(stage_view, const char **, VIEW_NO_FLAGS) \
60 _(stash_view, const char **, VIEW_NO_FLAGS) \
61 _(status_untracked_dirs, bool, VIEW_STATUS_LIKE) \
62 _(status_view, const char **, VIEW_NO_FLAGS) \
63 _(tab_size, int, VIEW_NO_FLAGS) \
64 _(tree_view, const char **, VIEW_NO_FLAGS) \
65 _(vertical_split, enum vertical_split, VIEW_RESET_DISPLAY | VIEW_DIFF_LIKE) \
66 _(wrap_lines, bool, VIEW_NO_FLAGS) \
68 #define DEFINE_OPTION_EXTERNS(name, type, flags) extern type opt_##name;
69 OPTION_INFO(DEFINE_OPTION_EXTERNS);
72 * View column options.
75 #define AUTHOR_COLUMN_OPTIONS(_) \
76 _(display, enum author, VIEW_NO_FLAGS) \
77 _(width, int, VIEW_NO_FLAGS) \
79 #define COMMIT_TITLE_COLUMN_OPTIONS(_) \
80 _(display, bool, VIEW_NO_FLAGS) \
81 _(graph, enum graph_display, VIEW_LOG_LIKE) \
82 _(refs, bool, VIEW_NO_FLAGS) \
83 _(overflow, int, VIEW_NO_FLAGS) \
84 _(width, int, VIEW_NO_FLAGS) \
86 #define DATE_COLUMN_OPTIONS(_) \
87 _(display, enum date, VIEW_NO_FLAGS) \
88 _(width, int, VIEW_NO_FLAGS) \
90 #define FILE_NAME_COLUMN_OPTIONS(_) \
91 _(display, enum filename, VIEW_GREP_LIKE) \
92 _(width, int, VIEW_NO_FLAGS) \
94 #define FILE_SIZE_COLUMN_OPTIONS(_) \
95 _(display, enum file_size, VIEW_NO_FLAGS) \
96 _(width, int, VIEW_NO_FLAGS) \
98 #define ID_COLUMN_OPTIONS(_) \
99 _(display, bool, VIEW_NO_FLAGS) \
100 _(color, bool, VIEW_NO_FLAGS) \
101 _(width, int, VIEW_NO_FLAGS) \
103 #define LINE_NUMBER_COLUMN_OPTIONS(_) \
104 _(display, bool, VIEW_NO_FLAGS) \
105 _(interval, int, VIEW_NO_FLAGS) \
106 _(width, int, VIEW_NO_FLAGS) \
108 #define MODE_COLUMN_OPTIONS(_) \
109 _(display, bool, VIEW_NO_FLAGS) \
110 _(width, int, VIEW_NO_FLAGS) \
112 #define REF_COLUMN_OPTIONS(_) \
113 _(display, bool, VIEW_NO_FLAGS) \
114 _(width, int, VIEW_NO_FLAGS) \
116 #define SECTION_COLUMN_OPTIONS(_) \
117 _(type, enum line_type, VIEW_NO_FLAGS) \
118 _(text, const char *, VIEW_NO_FLAGS) \
120 #define STATUS_COLUMN_OPTIONS(_) \
121 _(display, enum status_label, VIEW_NO_FLAGS) \
122 _(width, int, VIEW_NO_FLAGS) \
124 #define TEXT_COLUMN_OPTIONS(_) \
125 _(display, bool, VIEW_NO_FLAGS) \
126 _(commit_title_overflow, int, VIEW_NO_FLAGS) \
127 _(width, int, VIEW_NO_FLAGS) \
129 #define COLUMN_OPTIONS(_) \
130 _(author, AUTHOR, AUTHOR_COLUMN_OPTIONS) \
131 _(commit_title, COMMIT_TITLE, COMMIT_TITLE_COLUMN_OPTIONS) \
132 _(date, DATE, DATE_COLUMN_OPTIONS) \
133 _(file_name, FILE_NAME, FILE_NAME_COLUMN_OPTIONS) \
134 _(file_size, FILE_SIZE, FILE_SIZE_COLUMN_OPTIONS) \
135 _(id, ID, ID_COLUMN_OPTIONS) \
136 _(line_number, LINE_NUMBER, LINE_NUMBER_COLUMN_OPTIONS) \
137 _(mode, MODE, MODE_COLUMN_OPTIONS) \
138 _(ref, REF, REF_COLUMN_OPTIONS) \
139 _(section, SECTION, SECTION_COLUMN_OPTIONS) \
140 _(status, STATUS, STATUS_COLUMN_OPTIONS) \
141 _(text, TEXT, TEXT_COLUMN_OPTIONS) \
143 #define DEFINE_COLUMN_OPTIONS_STRUCT_VALUE(name, type, flags) type name;
145 #define DEFINE_COLUMN_OPTIONS_STRUCT(name, id, options) \
146 struct name##_options { \
147 options(DEFINE_COLUMN_OPTIONS_STRUCT_VALUE) \
148 } name;
150 union view_column_options {
151 COLUMN_OPTIONS(DEFINE_COLUMN_OPTIONS_STRUCT);
155 * Global state variables.
158 extern iconv_t opt_iconv_out;
159 extern char opt_editor[SIZEOF_STR];
160 extern char opt_env_lines[64];
161 extern char opt_env_columns[64];
162 extern char *opt_env[];
165 * Mapping between options and command argument mapping.
168 void update_options_from_argv(const char *argv[]);
170 const char *ignore_space_arg();
171 const char *commit_order_arg();
172 const char *commit_order_arg_with_graph(enum graph_display graph_display);
173 const char *diff_context_arg();
174 const char *show_notes_arg();
177 * Option loading and parsing.
180 struct option_info {
181 const char *name;
182 size_t namelen;
183 const char *type;
184 void *value;
185 bool seen;
188 struct option_info *find_option_info(struct option_info *option, size_t options, const char *name);
189 enum status_code parse_option(struct option_info *option, const char *prefix, const char *arg);
190 enum status_code parse_int(int *opt, const char *arg, int min, int max);
191 enum status_code parse_step(double *opt, const char *arg);
192 enum status_code set_option(const char *opt, int argc, const char *argv[]);
193 int load_options(void);
194 int load_git_config(void);
196 #endif
197 /* vim: set ts=8 sw=8 noexpandtab: */