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
25 #include "../src/dialog.h" /* B_CANCEL */
26 #include "../src/wtools.h" /* QuickDialog */
31 #ifndef USE_INTERNAL_EDIT
32 #define USE_INTERNAL_EDIT 1
35 static char *key_emu_str
[] =
36 {N_("Intuitive"), N_("Emacs"), NULL
};
38 static char *wrap_str
[] =
39 {N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL
};
42 i18n_translate_array (char *array
[])
44 while (*array
!=NULL
) {
51 edit_options_dialog (void)
53 char wrap_length
[32], tab_spacing
[32], *p
, *q
;
56 int tedit_key_emulation
= edit_key_emulation
;
57 int toption_fill_tabs_with_spaces
= option_fill_tabs_with_spaces
;
58 int toption_save_position
= option_save_position
;
59 int tedit_confirm_save
= edit_confirm_save
;
60 int tedit_syntax_highlighting
= option_syntax_highlighting
;
61 int toption_return_does_auto_indent
= option_return_does_auto_indent
;
62 int toption_backspace_through_tabs
= option_backspace_through_tabs
;
63 int toption_fake_half_tabs
= option_fake_half_tabs
;
64 static int i18n_flag
= 0;
66 QuickWidget quick_widgets
[] = {
68 {quick_button
, 6, 10, OPT_DLG_H
- 3, OPT_DLG_H
, N_("&Cancel"), 0,
69 B_CANCEL
, 0, 0, NULL
},
71 {quick_button
, 2, 10, OPT_DLG_H
- 3, OPT_DLG_H
, N_("&OK"), 0,
74 {quick_label
, OPT_DLG_W
/ 2, OPT_DLG_W
, OPT_DLG_H
- 5, OPT_DLG_H
,
75 N_("Word wrap line length: "), 0, 0, 0, 0, NULL
},
77 {quick_input
, OPT_DLG_W
/ 2 + 24, OPT_DLG_W
, OPT_DLG_H
- 5,
78 OPT_DLG_H
, "", OPT_DLG_W
/ 2 - 4 - 24, 0, 0, 0, "edit-word-wrap"},
80 {quick_label
, OPT_DLG_W
/ 2, OPT_DLG_W
, OPT_DLG_H
- 6, OPT_DLG_H
,
81 N_("Tab spacing: "), 0, 0, 0, 0, NULL
},
83 {quick_input
, OPT_DLG_W
/ 2 + 24, OPT_DLG_W
, OPT_DLG_H
- 6,
84 OPT_DLG_H
, "", OPT_DLG_W
/ 2 - 4 - 24, 0, 0, 0,
87 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 8,
88 OPT_DLG_H
, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL
},
90 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 9,
91 OPT_DLG_H
, N_("Save file &position"), 0, 0, 0, 0, NULL
},
93 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 10,
94 OPT_DLG_H
, N_("Confir&m before saving"), 6, 0, 0, 0, NULL
},
96 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 11,
97 OPT_DLG_H
, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL
},
99 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 12,
100 OPT_DLG_H
, N_("&Return does autoindent"), 0, 0, 0, 0, NULL
},
102 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 13,
103 OPT_DLG_H
, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL
},
105 {quick_checkbox
, OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, OPT_DLG_H
- 14,
106 OPT_DLG_H
, N_("&Fake half tabs"), 0, 0, 0, 0, NULL
},
108 {quick_radio
, 5, OPT_DLG_W
, OPT_DLG_H
- 7, OPT_DLG_H
, "", 3, 0, 0,
111 {quick_label
, 4, OPT_DLG_W
, OPT_DLG_H
- 8, OPT_DLG_H
,
112 N_("Wrap mode"), 0, 0,
115 {quick_radio
, 5, OPT_DLG_W
, OPT_DLG_H
- 13, OPT_DLG_H
, "", 2, 0, 0,
116 key_emu_str
, "keyemu"},
118 {quick_label
, 4, OPT_DLG_W
, OPT_DLG_H
- 14, OPT_DLG_H
,
119 N_("Key emulation"), 0, 0, 0, 0, NULL
},
123 QuickDialog Quick_options
=
124 { OPT_DLG_W
, OPT_DLG_H
, -1, 0, N_(" Editor options "), "", 0 };
127 i18n_translate_array (key_emu_str
);
128 i18n_translate_array (wrap_str
);
132 g_snprintf (wrap_length
, sizeof (wrap_length
), "%d",
133 option_word_wrap_line_length
);
134 g_snprintf (tab_spacing
, sizeof (tab_spacing
), "%d",
137 quick_widgets
[3].text
= wrap_length
;
138 quick_widgets
[3].str_result
= &p
;
139 quick_widgets
[5].text
= tab_spacing
;
140 quick_widgets
[5].str_result
= &q
;
141 quick_widgets
[6].result
= &tedit_syntax_highlighting
;
142 quick_widgets
[7].result
= &toption_save_position
;
143 quick_widgets
[8].result
= &tedit_confirm_save
;
144 quick_widgets
[9].result
= &toption_fill_tabs_with_spaces
;
145 quick_widgets
[10].result
= &toption_return_does_auto_indent
;
146 quick_widgets
[11].result
= &toption_backspace_through_tabs
;
147 quick_widgets
[12].result
= &toption_fake_half_tabs
;
149 if (option_auto_para_formatting
)
151 else if (option_typewriter_wrap
)
156 quick_widgets
[13].result
= &wrap_mode
;
157 quick_widgets
[13].value
= wrap_mode
;
159 quick_widgets
[15].result
= &tedit_key_emulation
;
160 quick_widgets
[15].value
= tedit_key_emulation
;
162 Quick_options
.widgets
= quick_widgets
;
164 if (quick_dialog (&Quick_options
) == B_CANCEL
)
167 old_syntax_hl
= option_syntax_highlighting
;
170 option_word_wrap_line_length
= atoi (p
);
174 option_tab_spacing
= atoi (q
);
175 if (option_tab_spacing
<= 0)
176 option_tab_spacing
= 8;
180 option_syntax_highlighting
= tedit_syntax_highlighting
;
181 edit_confirm_save
= tedit_confirm_save
;
182 option_save_position
= toption_save_position
;
183 option_fill_tabs_with_spaces
= toption_fill_tabs_with_spaces
;
184 option_return_does_auto_indent
= toption_return_does_auto_indent
;
185 option_backspace_through_tabs
= toption_backspace_through_tabs
;
186 option_fake_half_tabs
= toption_fake_half_tabs
;
188 if (wrap_mode
== 1) {
189 option_auto_para_formatting
= 1;
190 option_typewriter_wrap
= 0;
191 } else if (wrap_mode
== 2) {
192 option_auto_para_formatting
= 0;
193 option_typewriter_wrap
= 1;
195 option_auto_para_formatting
= 0;
196 option_typewriter_wrap
= 0;
199 edit_key_emulation
= tedit_key_emulation
;
201 /* Load or unload syntax rules if the option has changed */
202 if (option_syntax_highlighting
!= old_syntax_hl
)
203 edit_load_syntax (wedit
, 0, 0);