Codepage messages related translated & other stuff...
[midnight-commander.git] / gtkedit / editoptions.c
blob6fbe012087e5fc5c363804faa599b98f6803bc0b
1 /* editor options dialog box
3 Copyright (C) 1996, 1997 the Free Software Foundation
5 Authors: 1996, 1997 Paul Sheer
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307, USA.
23 #include <config.h>
24 #include "edit.h"
26 #define OPT_DLG_H 15
27 #define OPT_DLG_W 72
29 #ifndef USE_INTERNAL_EDIT
30 #define USE_INTERNAL_EDIT 1
31 #endif
33 #include "../src/main.h" /* extern int option_this_and_that ... */
35 char *key_emu_str[] =
36 {N_("Intuitive"), N_("Emacs"), NULL};
38 char *wrap_str[] =
39 {N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL};
41 extern int option_syntax_highlighting;
43 void i18n_translate_array (char *array[])
45 while (*array!=NULL) {
46 *array = _(*array);
47 array++;
51 void edit_options_dialog (void)
53 char wrap_length[32], tab_spacing[32], *p, *q;
54 int wrap_mode = 0;
55 int tedit_key_emulation = edit_key_emulation;
56 int toption_fill_tabs_with_spaces = option_fill_tabs_with_spaces;
57 int tedit_confirm_save = edit_confirm_save;
58 int tedit_syntax_highlighting = option_syntax_highlighting;
59 int toption_return_does_auto_indent = option_return_does_auto_indent;
60 int toption_backspace_through_tabs = option_backspace_through_tabs;
61 int toption_fake_half_tabs = option_fake_half_tabs;
63 QuickWidget quick_widgets[] =
65 /*0 */
66 {quick_button, 6, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Cancel"), 0, B_CANCEL, 0,
67 0, NULL},
68 /*1 */
69 {quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Ok"), 0, B_ENTER, 0,
70 0, NULL},
71 /*2 */
72 {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 4, OPT_DLG_H, N_("Word wrap line length : "), 0, 0,
73 0, 0, NULL},
74 /*3 */
75 {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 4, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0,
76 0, 0, "i"},
77 /*4 */
78 {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, N_("Tab spacing : "), 0, 0,
79 0, 0, NULL},
80 /*5 */
81 {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0,
82 0, 0, "i"},
83 /*6 */
84 #if !defined(MIDNIGHT) || defined(HAVE_SYNTAXH)
85 #define OA 1
86 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("synta&X highlighting"), 8, 0,
87 0, 0, NULL},
88 #else
89 #define OA 0
90 #endif
91 /*7 */
92 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, N_("confir&M before saving"), 6, 0,
93 0, 0, NULL},
94 /*8 */
95 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H, N_("fill tabs with &Spaces"), 0, 0,
96 0, 0, NULL},
97 /*9 */
98 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H, N_("&Return does autoindent"), 0, 0,
99 0, 0, NULL},
100 /*10 */
101 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, N_("&Backspace through tabs"), 0, 0,
102 0, 0, NULL},
103 /*11 */
104 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, N_("&Fake half tabs"), 0, 0,
105 0, 0, NULL},
106 /*12 */
107 {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H, "", 3, 0,
108 0, wrap_str, "wrapm"},
109 /*13 */
110 {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("Wrap mode"), 0, 0,
111 0, 0, NULL},
112 /*14 */
113 {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, "", 2, 0,
114 0, key_emu_str, "keyemu"},
115 /*15 */
116 {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, N_("Key emulation"), 0, 0,
117 0, 0, NULL},
118 {0}};
120 static int i18n_flag = 0;
122 if (!i18n_flag) {
123 i18n_translate_array (key_emu_str);
124 i18n_translate_array (wrap_str);
125 i18n_flag = 1;
128 sprintf (wrap_length, "%d", option_word_wrap_line_length);
129 sprintf (tab_spacing, "%d", option_tab_spacing);
131 quick_widgets[3].text = wrap_length;
132 quick_widgets[3].str_result = &p;
133 quick_widgets[5].text = tab_spacing;
134 quick_widgets[5].str_result = &q;
135 quick_widgets[5 + OA].result = &tedit_syntax_highlighting;
136 quick_widgets[6 + OA].result = &tedit_confirm_save;
137 quick_widgets[7 + OA].result = &toption_fill_tabs_with_spaces;
138 quick_widgets[8 + OA].result = &toption_return_does_auto_indent;
139 quick_widgets[9 + OA].result = &toption_backspace_through_tabs;
140 quick_widgets[10 + OA].result = &toption_fake_half_tabs;
142 if (option_auto_para_formatting)
143 wrap_mode = 1;
144 else if (option_typewriter_wrap)
145 wrap_mode = 2;
146 else
147 wrap_mode = 0;
149 quick_widgets[11 + OA].result = &wrap_mode;
150 quick_widgets[11 + OA].value = wrap_mode;
152 quick_widgets[13 + OA].result = &tedit_key_emulation;
153 quick_widgets[13 + OA].value = tedit_key_emulation;
156 QuickDialog Quick_options =
157 {OPT_DLG_W, OPT_DLG_H, -1, 0, N_(" Editor options "),
158 "", "quick_input", 0};
160 Quick_options.widgets = quick_widgets;
162 if (quick_dialog (&Quick_options) != B_CANCEL) {
163 if (p) {
164 option_word_wrap_line_length = atoi (p);
165 free (p);
167 if (q) {
168 option_tab_spacing = atoi (q);
169 if (option_tab_spacing < 0)
170 option_tab_spacing = 2;
171 option_tab_spacing += option_tab_spacing & 1;
172 free (q);
174 option_syntax_highlighting = *quick_widgets[5 + OA].result;
175 edit_confirm_save = *quick_widgets[6 + OA].result;
176 option_fill_tabs_with_spaces = *quick_widgets[7 + OA].result;
177 option_return_does_auto_indent = *quick_widgets[8 + OA].result;
178 option_backspace_through_tabs = *quick_widgets[9 + OA].result;
179 option_fake_half_tabs = *quick_widgets[10 + OA].result;
181 if (*quick_widgets[11 + OA].result == 1) {
182 option_auto_para_formatting = 1;
183 option_typewriter_wrap = 0;
184 } else if (*quick_widgets[11 + OA].result == 2) {
185 option_auto_para_formatting = 0;
186 option_typewriter_wrap = 1;
187 } else {
188 option_auto_para_formatting = 0;
189 option_typewriter_wrap = 0;
192 edit_key_emulation = *quick_widgets[13 + OA].result;
194 return;
195 } else {
196 return;