1 /*
2   FXiTe - The Free eXtensIble Text Editor
3   Copyright (c) 2009-2013 Jeffrey Pohlmeyer <yetanothergeek@gmail.com>
4 
5   This program is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License version 3 as
7   published by the Free Software Foundation.
8 
9   This software is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18 
19 
20 /*
21 Steps to adding a new preference:
22   1. Add the variable to the public interface of the SettingsBase class.
23   2. Add a corresponding ID_* entry to the class's selectors enumeration.
24   3. Be sure the ID_* is picked up by the SettingsMap macros in prefs.cpp
25   4. Add a case to the switch statement in Settings::onChangeSetting to catch the new selector.
26   5. Add a call in Settings::Settings to read your setting from the registry (or default value).
27   6. Add a call in Settings::~Settings to save your setting to the registry.
28   7. Add the variable name (as a string) to the appropriate *_keys[] array in prefs.cpp.
29   8. Add an adjustment widget to one of the tabs in PrefsDialog::Make*Tab() and set its target and selector, or...
30   9. In lieu of steps 2,3,4,8 you could add an item to the View menu and control the preference from there.
31 */
32 
33 
34 #ifndef PREFS_H
35 #define PREFS_H
36 
37 #include "prefs_base.h"
38 
39 
40 typedef enum {
41   AUTO_INDENT_NONE=0,
42   AUTO_INDENT_BASIC,
43   AUTO_INDENT_SMART
44 } AutoIndentPolicy;
45 
46 typedef enum {
47   REMEMBER_NEVER=0,
48   REMEMBER_SESSION,
49   REMEMBER_ALWAYS
50 } FileFilterPolicy;
51 
52 
53 typedef struct _ErrorPattern {
54   char pat[64];
55   char id[32];
56 } ErrorPattern;
57 
58 class Settings: public SettingsBase {
59   FXDECLARE(Settings);
60   static FXbool loaded;
61   FXApp*app;
62   FXRegistry*reg;
63   FXSettings*style_reg;
64   FXString style_file;
Settings()65   Settings() {}
66 public:
67   Settings(FXMainWindow* w, const FXString& configdir);
68   ~Settings();
69 
70   static const FXchar* CaretFG();
71   static const FXchar* CaretLineBG();
72   static const FXchar* RightMarginBG();
73   static const FXchar* WhiteSpaceBG();
74   static const FXchar* WhiteSpaceFG();
75   static const FXchar* SelectionBG();
76 
77   static StyleDef *globalStyle();
78   static StyleDef *whitespaceStyle();
79   static StyleDef *caretlineStyle();
80   static StyleDef *rightmarginStyle();
81   static StyleDef *selectionStyle();
82   static StyleDef *caretStyle();
83   static const FXchar *defaultFileFilters();
84 
85   static ErrorPattern* ErrorPatterns();
86   static ErrorPattern* DefaultErrorPatterns();
87   static int ErrorPatternCount();
88   static int MaxErrorPatterns();
89   static const FXString defaultSystemIncludePaths();
90   static const FXString SystemIncludePaths();
91   static void SystemIncludePaths(const FXString paths);
92 
93   long onChangeSetting(FXObject*o, FXSelector sel, void*p);
94 
95   enum {
96     ID_TOGGLE_SMART_HOME,
97     ID_TOGGLE_WRAP_AWARE,
98     ID_TOGGLE_USE_TABS,
99     ID_TOGGLE_ASK_CLOSE_MULTI_EXIT,
100     ID_TOGGLE_ASK_CLOSE_MULTI_MENU,
101     ID_TOGGLE_WATCH_EXTERN,
102     ID_TOGGLE_SMOOTH_SCROLL,
103     ID_TOGGLE_POSIX_SEARCH,
104     ID_TOGGLE_SEARCH_VERBOSE,
105     ID_TOGGLE_CARET_PAST_EOL,
106     ID_TOGGLE_AUTOSAVE,
107     ID_TOGGLE_VIEW_WHITESPACE_EOL,
108     ID_TOGGLE_WRAP_TOOLBAR,
109     ID_TOGGLE_ASCII_DEFAULT,
110     ID_TOGGLE_SBCS_DEFAULT,
111     ID_TOGGLE_WORD_WRAP,
112     ID_SAVE_ON_FILTER_SEL,
113     ID_SAVE_ON_INS_CMD,
114     ID_SAVE_ON_EXEC_CMD,
115     ID_CHOOSE_FONT,
116     ID_SET_FILETYPES,
117     ID_SET_SHABANGS,
118     ID_SET_MAX_FILES,
119     ID_SET_TAB_WIDTH,
120     ID_SET_TAB_WIDTH_FOR_LANG,
121     ID_SET_INDENT_WIDTH,
122     ID_SET_CARET_WIDTH,
123     ID_SET_WHEEL_LINES,
124     ID_SET_SPLIT_VIEW,
125     ID_SET_SEARCH_WRAP,
126     ID_SET_SEARCH_GUI,
127     ID_SET_RIGHT_EDGE,
128     ID_SET_SHELL_CMD,
129     ID_SET_AUTOSAVE_INT,
130     ID_SET_FILE_FORMAT,
131     ID_SET_TOOLBAR_BTN_SIZE,
132     ID_SET_SEARCH_OPTS,
133     ID_SET_KEEP_FILE_FILTER,
134     ID_SET_TAB_TITLE_MAX_WIDTH,
135     ID_SET_BRACE_MATCHING,
136     ID_SET_AUTO_INDENT,
137     ID_LAST
138   };
139   static Settings*instance();
140 };
141 
142 enum {
143   ToolbarUnchanged     = 0,
144   ToolbarChangedLayout = 1<<0,
145   ToolbarChangedFont   = 1<<1,
146   ToolbarChangedWrap   = 1<<2
147 };
148 
149 
150 #endif
151 
152