2 Editor options dialog box
4 Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2007, 2011
5 The Free Software Foundation, Inc.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * \brief Source: editor options dialog box
34 #include <stdlib.h> /* atoi(), NULL */
36 #include "lib/global.h"
37 #include "lib/widget.h"
39 #include "edit-widget.h"
40 #include "edit-impl.h"
41 #include "src/setup.h" /* option_tab_spacing */
43 /*** global variables ****************************************************************************/
45 /*** file scope macro definitions ****************************************************************/
50 /*** file scope type declarations ****************************************************************/
52 /*** file scope variables ************************************************************************/
54 static const char *wrap_str
[] = {
56 N_("Dynamic paragraphing"),
57 N_("Type writer wrap"),
61 /*** file scope functions ************************************************************************/
62 /* --------------------------------------------------------------------------------------------- */
66 i18n_translate_array (const char *array
[])
68 while (*array
!= NULL
)
74 #endif /* ENABLE_NLS */
76 /* --------------------------------------------------------------------------------------------- */
77 /*** public functions ****************************************************************************/
78 /* --------------------------------------------------------------------------------------------- */
81 edit_options_dialog (WEdit
* edit
)
83 char wrap_length
[16], tab_spacing
[16], *p
, *q
;
87 QuickWidget quick_widgets
[] = {
88 /* 0 */ QUICK_BUTTON (6, 10, OPT_DLG_H
- 3, OPT_DLG_H
, N_("&Cancel"), B_CANCEL
, NULL
),
89 /* 1 */ QUICK_BUTTON (2, 10, OPT_DLG_H
- 3, OPT_DLG_H
, N_("&OK"), B_ENTER
, NULL
),
90 /* 2 */ QUICK_LABEL (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 12, OPT_DLG_H
,
91 N_("Word wrap line length:")),
92 /* 3 */ QUICK_INPUT (OPT_DLG_W
/ 2 + 25, OPT_DLG_W
, 12, OPT_DLG_H
,
93 wrap_length
, OPT_DLG_W
/ 2 - 4 - 24, 0, "edit-word-wrap", &p
),
94 /* 4 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 11, OPT_DLG_H
,
95 N_("&Group undo"), &option_group_undo
),
96 /* 5 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 10, OPT_DLG_H
,
97 N_("Cursor beyond end of line"), &option_cursor_beyond_eol
),
98 /* 6 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 9, OPT_DLG_H
,
99 N_("Pers&istent selection"), &option_persistent_selections
),
100 /* 7 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 8, OPT_DLG_H
,
101 N_("Synta&x highlighting"), &option_syntax_highlighting
),
102 /* 8 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 7, OPT_DLG_H
,
103 N_("Visible tabs"), &visible_tabs
),
104 /* 9 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 6, OPT_DLG_H
,
105 N_("Visible trailing spaces"), &visible_tws
),
106 /* 10 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 5, OPT_DLG_H
,
107 N_("Save file &position"), &option_save_position
),
108 /* 11 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 4, OPT_DLG_H
,
109 N_("Confir&m before saving"), &edit_confirm_save
),
110 /* 12 */ QUICK_CHECKBOX (OPT_DLG_W
/ 2 + 1, OPT_DLG_W
, 3, OPT_DLG_H
,
111 N_("&Return does autoindent"), &option_return_does_auto_indent
),
112 /* 13 */ QUICK_LABEL (3, OPT_DLG_W
, 11, OPT_DLG_H
, N_("Tab spacing:")),
113 /* 14 */ QUICK_INPUT (3 + 24, OPT_DLG_W
, 11, OPT_DLG_H
,
114 tab_spacing
, OPT_DLG_W
/ 2 - 4 - 24, 0, "edit-tab-spacing", &q
),
115 /* 15 */ QUICK_CHECKBOX (3, OPT_DLG_W
, 10, OPT_DLG_H
,
116 N_("Fill tabs with &spaces"), &option_fill_tabs_with_spaces
),
117 /* 16 */ QUICK_CHECKBOX (3, OPT_DLG_W
, 9, OPT_DLG_H
,
118 N_("&Backspace through tabs"), &option_backspace_through_tabs
),
119 /* 17 */ QUICK_CHECKBOX (3, OPT_DLG_W
, 8, OPT_DLG_H
,
120 N_("&Fake half tabs"), &option_fake_half_tabs
),
121 /* 18 */ QUICK_RADIO (4, OPT_DLG_W
, 4, OPT_DLG_H
, 3, wrap_str
, &wrap_mode
),
122 /* 19 */ QUICK_LABEL (3, OPT_DLG_W
, 3, OPT_DLG_H
, N_("Wrap mode")),
126 QuickDialog Quick_options
= {
127 OPT_DLG_W
, OPT_DLG_H
, -1, -1, N_("Editor options"),
128 "[Editor options]", quick_widgets
, NULL
, NULL
, FALSE
132 static gboolean i18n_flag
= FALSE
;
136 i18n_translate_array (wrap_str
);
139 #endif /* ENABLE_NLS */
141 g_snprintf (wrap_length
, sizeof (wrap_length
), "%d", option_word_wrap_line_length
);
142 g_snprintf (tab_spacing
, sizeof (tab_spacing
), "%d", option_tab_spacing
);
144 if (option_auto_para_formatting
)
146 else if (option_typewriter_wrap
)
151 if (quick_dialog (&Quick_options
) == B_CANCEL
)
154 old_syntax_hl
= option_syntax_highlighting
;
156 if (!option_cursor_beyond_eol
)
161 option_word_wrap_line_length
= atoi (p
);
162 if (option_word_wrap_line_length
<= 0)
163 option_word_wrap_line_length
= DEFAULT_WRAP_LINE_LENGTH
;
169 option_tab_spacing
= atoi (q
);
170 if (option_tab_spacing
<= 0)
171 option_tab_spacing
= DEFAULT_TAB_SPACING
;
177 option_auto_para_formatting
= 1;
178 option_typewriter_wrap
= 0;
180 else if (wrap_mode
== 2)
182 option_auto_para_formatting
= 0;
183 option_typewriter_wrap
= 1;
187 option_auto_para_formatting
= 0;
188 option_typewriter_wrap
= 0;
191 /* Load or unload syntax rules if the option has changed */
192 if (option_syntax_highlighting
!= old_syntax_hl
)
193 edit_load_syntax (edit
, NULL
, edit
->syntax_type
);
196 /* --------------------------------------------------------------------------------------------- */