This source file includes following definitions.
- i18n_translate_array
- edit_reset_over_col
- edit_reload_syntax
- edit_options_dialog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #include <config.h>
34
35 #include <stdlib.h>
36
37 #include "lib/global.h"
38 #include "lib/widget.h"
39
40 #include "editwidget.h"
41 #include "edit-impl.h"
42
43
44
45
46
47
48
49
50
51
52
53 static const char *wrap_str[] = {
54 N_("&None"),
55 N_("&Dynamic paragraphing"),
56 N_("Type &writer wrap"),
57 NULL
58 };
59
60
61
62
63
64 #ifdef ENABLE_NLS
65 static void
66 i18n_translate_array (const char *array[])
67 {
68 while (*array != NULL)
69 {
70 *array = _(*array);
71 array++;
72 }
73 }
74 #endif
75
76
77
78
79
80
81
82
83
84
85 static void
86 edit_reset_over_col (void *data, void *user_data)
87 {
88 (void) user_data;
89
90 if (edit_widget_is_editor (CONST_WIDGET (data)))
91 EDIT (data)->over_col = 0;
92 }
93
94
95
96
97
98
99
100
101
102
103 static void
104 edit_reload_syntax (void *data, void *user_data)
105 {
106 (void) user_data;
107
108 if (edit_widget_is_editor (CONST_WIDGET (data)))
109 {
110 WEdit *edit = EDIT (data);
111
112 edit_load_syntax (edit, NULL, edit->syntax_type);
113 }
114 }
115
116
117
118
119
120 void
121 edit_options_dialog (WDialog *h)
122 {
123 char wrap_length[16], tab_spacing[16];
124 char *p, *q;
125 int wrap_mode = 0;
126 gboolean old_syntax_hl;
127
128 #ifdef ENABLE_NLS
129 static gboolean i18n_flag = FALSE;
130
131 if (!i18n_flag)
132 {
133 i18n_translate_array (wrap_str);
134 i18n_flag = TRUE;
135 }
136 #endif
137
138 g_snprintf (wrap_length, sizeof (wrap_length), "%d", edit_options.word_wrap_line_length);
139 g_snprintf (tab_spacing, sizeof (tab_spacing), "%d", TAB_SIZE);
140
141 if (edit_options.auto_para_formatting)
142 wrap_mode = 1;
143 else if (edit_options.typewriter_wrap)
144 wrap_mode = 2;
145 else
146 wrap_mode = 0;
147
148 {
149 quick_widget_t quick_widgets[] = {
150
151 QUICK_START_COLUMNS,
152 QUICK_START_GROUPBOX (N_("Wrap mode")),
153 QUICK_RADIO (3, wrap_str, &wrap_mode, NULL),
154 QUICK_STOP_GROUPBOX,
155 QUICK_SEPARATOR (FALSE),
156 QUICK_SEPARATOR (FALSE),
157 QUICK_START_GROUPBOX (N_("Tabulation")),
158 QUICK_CHECKBOX (N_("&Fake half tabs"), &edit_options.fake_half_tabs, NULL),
159 QUICK_CHECKBOX (N_("&Backspace through tabs"),
160 &edit_options.backspace_through_tabs, NULL),
161 QUICK_CHECKBOX (N_("Fill tabs with &spaces"),
162 &edit_options.fill_tabs_with_spaces, NULL),
163 QUICK_LABELED_INPUT (N_("Tab spacing:"), input_label_left, tab_spacing,
164 "edit-tab-spacing", &q, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE),
165 QUICK_STOP_GROUPBOX,
166 QUICK_NEXT_COLUMN,
167 QUICK_START_GROUPBOX (N_("Other options")),
168 QUICK_CHECKBOX (N_("&Return does autoindent"), &edit_options.return_does_auto_indent, NULL),
169 QUICK_CHECKBOX (N_("Confir&m before saving"), &edit_options.confirm_save, NULL),
170 QUICK_CHECKBOX (N_("Save file &position"), &edit_options.save_position, NULL),
171 QUICK_CHECKBOX (N_("&Visible trailing spaces"), &edit_options.visible_tws, NULL),
172 QUICK_CHECKBOX (N_("Visible &tabs"), &edit_options.visible_tabs, NULL),
173 QUICK_CHECKBOX (N_("Synta&x highlighting"), &edit_options.syntax_highlighting, NULL),
174 QUICK_CHECKBOX (N_("C&ursor after inserted block"),
175 &edit_options.cursor_after_inserted_block, NULL),
176 QUICK_CHECKBOX (N_("Pers&istent selection"), &edit_options.persistent_selections, NULL),
177 QUICK_CHECKBOX (N_("Cursor be&yond end of line"), &edit_options.cursor_beyond_eol, NULL),
178 QUICK_CHECKBOX (N_("&Group undo"), &edit_options.group_undo, NULL),
179 QUICK_LABELED_INPUT (N_("Word wrap line length:"), input_label_left, wrap_length,
180 "edit-word-wrap", &p, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE),
181 QUICK_STOP_GROUPBOX,
182 QUICK_STOP_COLUMNS,
183 QUICK_BUTTONS_OK_CANCEL,
184 QUICK_END
185
186 };
187
188 WRect r = { -1, -1, 0, 74 };
189
190 quick_dialog_t qdlg = {
191 r, N_("Editor options"), "[Editor options]",
192 quick_widgets, NULL, NULL
193 };
194
195 if (quick_dialog (&qdlg) == B_CANCEL)
196 return;
197 }
198
199 old_syntax_hl = edit_options.syntax_highlighting;
200
201 if (!edit_options.cursor_beyond_eol)
202 g_list_foreach (GROUP (h)->widgets, edit_reset_over_col, NULL);
203
204 if (*p != '\0')
205 {
206 edit_options.word_wrap_line_length = atoi (p);
207 if (edit_options.word_wrap_line_length <= 0)
208 edit_options.word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
209 g_free (p);
210 }
211
212 if (*q != '\0')
213 {
214 TAB_SIZE = atoi (q);
215 if (TAB_SIZE <= 0)
216 TAB_SIZE = DEFAULT_TAB_SPACING;
217 g_free (q);
218 }
219
220 if (wrap_mode == 1)
221 {
222 edit_options.auto_para_formatting = TRUE;
223 edit_options.typewriter_wrap = FALSE;
224 }
225 else if (wrap_mode == 2)
226 {
227 edit_options.auto_para_formatting = FALSE;
228 edit_options.typewriter_wrap = TRUE;
229 }
230 else
231 {
232 edit_options.auto_para_formatting = FALSE;
233 edit_options.typewriter_wrap = FALSE;
234 }
235
236
237 if (edit_options.syntax_highlighting != old_syntax_hl)
238 g_list_foreach (GROUP (h)->widgets, edit_reload_syntax, NULL);
239 }
240
241