Take care of one BSOD in NtGdiDdCreateDirectDrawObject, it is not correct fix, it...
[reactos.git] / rosapps / mc / edit / editoptions.c
1 /* editor options dialog box
2
3 Copyright (C) 1996, 1997 the Free Software Foundation
4
5 Authors: 1996, 1997 Paul Sheer
6
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.
11
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.
16
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #include <config.h>
22 #include "edit.h"
23
24 #define OPT_DLG_H 15
25 #define OPT_DLG_W 72
26
27 #ifndef USE_INTERNAL_EDIT
28 #define USE_INTERNAL_EDIT 1
29 #endif
30
31 #include "../src/main.h" /* extern int option_this_and_that ... */
32
33 char *key_emu_str[] =
34 {"Intuitive", "Emacs"};
35
36 char *wrap_str[] =
37 {N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap")};
38
39 extern int option_syntax_highlighting;
40
41 void edit_options_dialog (void)
42 {
43 char wrap_length[32], tab_spacing[32], *p, *q;
44 int wrap_mode = 0;
45 int tedit_key_emulation = edit_key_emulation;
46 int toption_fill_tabs_with_spaces = option_fill_tabs_with_spaces;
47 int tedit_confirm_save = edit_confirm_save;
48 int tedit_syntax_highlighting = option_syntax_highlighting;
49 int toption_return_does_auto_indent = option_return_does_auto_indent;
50 int toption_backspace_through_tabs = option_backspace_through_tabs;
51 int toption_fake_half_tabs = option_fake_half_tabs;
52
53 QuickWidget quick_widgets[] =
54 {
55 /*0 */
56 {quick_button, 6, 10, OPT_DLG_H - 3, OPT_DLG_H, "&Cancel", 0, B_CANCEL, 0,
57 0, XV_WLAY_DONTCARE, NULL},
58 /*1 */
59 {quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, "&Ok", 0, B_ENTER, 0,
60 0, XV_WLAY_DONTCARE, NULL},
61 /*2 */
62 {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 4, OPT_DLG_H, "Word wrap line length : ", 0, 0,
63 0, 0, XV_WLAY_DONTCARE, NULL},
64 /*3 */
65 {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 4, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0,
66 0, 0, XV_WLAY_DONTCARE, "i"},
67 /*4 */
68 {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, "Tab spacing : ", 0, 0,
69 0, 0, XV_WLAY_DONTCARE, NULL},
70 /*5 */
71 {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0,
72 0, 0, XV_WLAY_DONTCARE, "i"},
73 /*6 */
74 #if !defined(MIDNIGHT) || defined(HAVE_SYNTAXH)
75 #define OA 1
76 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, "syntax h&Ighlighting", 8, 0,
77 0, 0, XV_WLAY_DONTCARE, NULL},
78 #else
79 #define OA 0
80 #endif
81 /*7 */
82 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, "confir&M before saving", 6, 0,
83 0, 0, XV_WLAY_DONTCARE, NULL},
84 /*8 */
85 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H, "&Fill tabs with spaces", 0, 0,
86 0, 0, XV_WLAY_DONTCARE, NULL},
87 /*9 */
88 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H, "&Return does auto indent", 0, 0,
89 0, 0, XV_WLAY_DONTCARE, NULL},
90 /*10 */
91 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, "&Backspace through tabs", 0, 0,
92 0, 0, XV_WLAY_DONTCARE, NULL},
93 /*11 */
94 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, "&Fake half tabs", 0, 0,
95 0, 0, XV_WLAY_DONTCARE, NULL},
96 /*12 */
97 {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H, "", 3, 0,
98 0, wrap_str, XV_WLAY_DONTCARE, "wrapm"},
99 /*13 */
100 {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("Wrap mode"), 0, 0,
101 0, 0, XV_WLAY_DONTCARE, NULL},
102 /*14 */
103 {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, "", 2, 0,
104 0, key_emu_str, XV_WLAY_DONTCARE, "keyemu"},
105 /*15 */
106 {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, N_("Key emulation"), 0, 0,
107 0, 0, XV_WLAY_DONTCARE, NULL},
108 {0}};
109
110 sprintf (wrap_length, "%d", option_word_wrap_line_length);
111 sprintf (tab_spacing, "%d", option_tab_spacing);
112
113 quick_widgets[3].text = wrap_length;
114 quick_widgets[3].str_result = &p;
115 quick_widgets[5].text = tab_spacing;
116 quick_widgets[5].str_result = &q;
117 quick_widgets[5 + OA].result = &tedit_syntax_highlighting;
118 quick_widgets[6 + OA].result = &tedit_confirm_save;
119 quick_widgets[7 + OA].result = &toption_fill_tabs_with_spaces;
120 quick_widgets[8 + OA].result = &toption_return_does_auto_indent;
121 quick_widgets[9 + OA].result = &toption_backspace_through_tabs;
122 quick_widgets[10 + OA].result = &toption_fake_half_tabs;
123
124 if (option_auto_para_formatting)
125 wrap_mode = 1;
126 else if (option_typewriter_wrap)
127 wrap_mode = 2;
128 else
129 wrap_mode = 0;
130
131 quick_widgets[11 + OA].result = &wrap_mode;
132 quick_widgets[11 + OA].value = wrap_mode;
133
134 quick_widgets[13 + OA].result = &tedit_key_emulation;
135 quick_widgets[13 + OA].value = tedit_key_emulation;
136
137 {
138 QuickDialog Quick_options =
139 {OPT_DLG_W, OPT_DLG_H, -1, 0, " Editor Options ",
140 "", "quick_input", 0};
141
142 Quick_options.widgets = quick_widgets;
143
144 if (quick_dialog (&Quick_options) != B_CANCEL) {
145 if (p) {
146 option_word_wrap_line_length = atoi (p);
147 free (p);
148 }
149 if (q) {
150 option_tab_spacing = atoi (q);
151 if (option_tab_spacing < 0)
152 option_tab_spacing = 2;
153 option_tab_spacing += option_tab_spacing & 1;
154 free (q);
155 }
156 option_syntax_highlighting = *quick_widgets[5 + OA].result;
157 edit_confirm_save = *quick_widgets[6 + OA].result;
158 option_fill_tabs_with_spaces = *quick_widgets[7 + OA].result;
159 option_return_does_auto_indent = *quick_widgets[8 + OA].result;
160 option_backspace_through_tabs = *quick_widgets[9 + OA].result;
161 option_fake_half_tabs = *quick_widgets[10 + OA].result;
162
163 if (*quick_widgets[11 + OA].result == 1) {
164 option_auto_para_formatting = 1;
165 option_typewriter_wrap = 0;
166 } else if (*quick_widgets[11 + OA].result == 2) {
167 option_auto_para_formatting = 0;
168 option_typewriter_wrap = 1;
169 } else {
170 option_auto_para_formatting = 0;
171 option_typewriter_wrap = 0;
172 }
173
174 edit_key_emulation = *quick_widgets[13 + OA].result;
175
176 return;
177 } else {
178 return;
179 }
180 }
181 }
182