1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2017-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_gui_preferences_ed_h)
27 #define octave_gui_preferences_ed_h 1
28 
29 #if defined (HAVE_QSCINTILLA)
30 #include <Qsci/qsciscintilla.h>
31 #endif
32 
33 #include "gui-preferences.h"
34 #include "localcharset-wrapper.h"
35 
36 // Editor preferences
37 
38 // Code completion
39 
40 const gui_pref
41 ed_code_completion_octave_builtins ("editor/codeCompletion_octave_builtins",
42                                     QVariant (true));
43 
44 const gui_pref
45 ed_code_completion_octave_functions ("editor/codeCompletion_octave_functions",
46                                      QVariant (true));
47 
48 const gui_pref
49 ed_code_completion_keywords ("editor/codeCompletion_keywords", QVariant (true));
50 
51 const gui_pref
52 ed_code_completion_document ("editor/codeCompletion_document", QVariant (true));
53 
54 const gui_pref
55 ed_code_completion_replace ("editor/codeCompletion_replace", QVariant (false));
56 
57 const gui_pref
58 ed_code_completion_case ("editor/codeCompletion_case", QVariant (true));
59 
60 const gui_pref
61 ed_code_completion ("editor/codeCompletion", QVariant (true));
62 
63 const gui_pref
64 ed_code_completion_threshold ("editor/codeCompletion_threshold", QVariant (2));
65 
66 // Code formatting
67 
68 const gui_pref
69 ed_code_folding ("editor/code_folding", QVariant (true));
70 
71 const gui_pref
72 ed_auto_indent ("editor/auto_indent", QVariant (true));
73 
74 const gui_pref
75 ed_tab_indents_line ("editor/tab_indents_line", QVariant (false));
76 
77 const gui_pref
78 ed_backspace_unindents_line ("editor/backspace_unindents_line",
79                              QVariant (false));
80 
81 const gui_pref
82 ed_show_indent_guides ("editor/show_indent_guides", QVariant (false));
83 
84 const gui_pref
85 ed_indent_uses_tabs ("editor/indent_uses_tabs", QVariant (false));
86 
87 const gui_pref
88 ed_indent_width ("editor/indent_width", QVariant (2));
89 
90 const gui_pref
91 ed_tab_width ("editor/tab_width", QVariant (2));
92 
93 const gui_pref
94 ed_auto_endif ("editor/auto_endif", QVariant (1));
95 
96 // Long line handling
97 
98 const gui_pref
99 ed_long_line_column ("editor/long_line_column", QVariant (80));
100 
101 const gui_pref
102 ed_long_line_marker ("editor/long_line_marker", QVariant (true));
103 
104 const gui_pref
105 ed_long_line_marker_line ("editor/long_line_marker_line", QVariant (true));
106 
107 const gui_pref
108 ed_long_line_marker_background ("editor/long_line_marker_background",
109                                 QVariant (false));
110 
111 const gui_pref
112 ed_wrap_lines ("editor/wrap_lines", QVariant (false));
113 
114 const gui_pref
115 ed_break_lines ("editor/break_lines", QVariant (false));
116 
117 const gui_pref
118 ed_break_lines_comments ("editor/break_lines_comments", QVariant (false));
119 
120 const gui_pref
121 ed_highlight_all_occurrences ("editor/highlight_all_occurrences",
122                               QVariant (true));
123 
124 const gui_pref
125 ed_show_Line_numbers ("editor/showLineNumbers", QVariant (true));
126 
127 const gui_pref
128 ed_line_numbers_size ("editor/line_numbers_size", QVariant ( 0));
129 
130 const gui_pref
131 ed_show_edit_status_bar ("editor/show_edit_status_bar", QVariant (true));
132 
133 const gui_pref
134 ed_highlight_current_line ("editor/highlightCurrentLine", QVariant (true));
135 
136 const gui_pref
137 ed_highlight_current_line_color ("editor/highlight_current_line_color",
138                                  QVariant (QColor (240, 240, 240)));
139 
140 const gui_pref
141 ed_show_white_space ("editor/show_white_space", QVariant (false));
142 
143 const gui_pref
144 ed_show_white_space_indent ("editor/show_white_space_indent", QVariant (false));
145 
146 const gui_pref
147 ed_show_line_numbers ("editor/showLineNumbers", QVariant (true));
148 
149 const gui_pref
150 ed_show_eol_chars ("editor/show_eol_chars", QVariant (false));
151 
152 const gui_pref
153 ed_show_toolbar ("editor/show_toolbar", QVariant (true));
154 
155 const gui_pref
156 ed_show_hscroll_bar ("editor/show_hscroll_bar", QVariant (true));
157 
158 
159 
160 // Octave comment strings
161 
162 const gui_pref
163 ed_comment_str_old ("editor/octave_comment_string", QVariant (0));
164 
165 const gui_pref
166 ed_comment_str ("editor/oct_comment_str", QVariant (0));
167 
168 const gui_pref
169 ed_uncomment_str ("editor/oct_uncomment_str", QVariant (1 + 2 + 4 + 8));
170 
171 const QString
172 ed_last_comment_str ("editor/oct_last_comment_str");
173 
174 const QStringList
175 ed_comment_strings (QStringList () << "##" << "#" << "%"<< "%%" << "%!");
176 
177 const int ed_comment_strings_count = 5;
178 
179 // Session data
180 
181 const gui_pref
182 ed_restore_session ("editor/restoreSession", QVariant (true));
183 
184 const gui_pref
185 ed_session_names ("editor/savedSessionTabs", QVariant (QStringList ()));
186 
187 const gui_pref
188 ed_session_enc ("editor/saved_session_encodings", QVariant (QStringList ()));
189 
190 const gui_pref
191 ed_session_ind ("editor/saved_session_tab_index", QVariant (QStringList ()));
192 
193 const gui_pref
194 ed_session_lines ("editor/saved_session_lines", QVariant (QStringList ()));
195 
196 // Tabs
197 const QStringList
198 ed_tab_position_names (QStringList ()
199                        << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Top")
200                        << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Bottom")
201                        << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Left")
202                        << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Right"));
203 
204 const gui_pref
205 ed_tab_position ("editor/tab_position", QVariant (QTabWidget::North));
206 
207 // File handling
208 
209 const gui_pref
210 ed_long_window_title ("editor/longWindowTitle", QVariant (false));
211 
212 const gui_pref
213 ed_notebook_tab_width_min ("editor/notebook_tab_width_min", QVariant (160));
214 
215 const gui_pref
216 ed_notebook_tab_width_max ("editor/notebook_tab_width_max", QVariant (300));
217 
218 #if defined (HAVE_QSCINTILLA)
219 #if defined (Q_OS_WIN32)
220 const int os_eol_mode = QsciScintilla::EolWindows;
221 #else
222 const int os_eol_mode = QsciScintilla::EolUnix;
223 #endif
224 #else
225 const int os_eol_mode = 2;
226 #endif
227 
228 const gui_pref
229 ed_default_eol_mode ("editor/default_eol_mode", QVariant (os_eol_mode));
230 
231 const gui_pref
232 ed_show_dbg_file ("editor/show_dbg_file", QVariant (true));
233 
234 const gui_pref
235 ed_default_enc ("editor/default_encoding",
236                 QVariant (QString ("SYSTEM (") +
237                           QString (octave_locale_charset_wrapper ()).toUpper () +
238                           QString (")")));
239 
240 const gui_pref
241 ed_create_new_file ("editor/create_new_file", QVariant (false));
242 
243 const gui_pref
244 ed_hiding_closes_files ("editor/hiding_closes_files", QVariant (false));
245 
246 const gui_pref
247 ed_always_reload_changed_files ("editor/always_reload_changed_files",
248                                 QVariant (false));
249 
250 const gui_pref
251 ed_mru_file_list ("editor/mru_file_list", QVariant ());
252 
253 const gui_pref
254 ed_mru_file_encodings ("editor/mru_file_encodings", QVariant ());
255 
256 // The find dialog
257 
258 enum find_dialog_options
259   {
260     FIND_DLG_MORE  = 1,
261     FIND_DLG_CASE  = 2,
262     FIND_DLG_START = 4,
263     FIND_DLG_WRAP  = 8,
264     FIND_DLG_REGX  = 16,
265     FIND_DLG_WORDS = 32,
266     FIND_DLG_BACK  = 64,
267     FIND_DLG_SEL   = 128
268   };
269 
270 // Dialog position, the default will be calculated from the editor's geometry
271 const gui_pref
272 ed_fdlg_pos ("editor/fdgl_pos", QVariant (QPoint (0,0)));
273 
274 const gui_pref
275 ed_fdlg_opts ("editor/fdgl_opts", QVariant (FIND_DLG_WRAP));
276 
277 const gui_pref
278 ed_fdlg_search ("editor/fdgl_search", QVariant ());
279 const gui_pref
280 ed_fdlg_replace ("editor/fdgl_replace", QVariant ());
281 
282 #endif
283