forked from Acode-Foundation/Acode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditorSettings.js
More file actions
216 lines (211 loc) · 4.67 KB
/
editorSettings.js
File metadata and controls
216 lines (211 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import settingsPage from "components/settingsPage";
import constants from "lib/constants";
import fonts from "lib/fonts";
import appSettings from "lib/settings";
import scrollSettings from "./scrollSettings";
export default function editorSettings() {
const title = strings["editor settings"];
const values = appSettings.value;
const items = [
{
key: "autosave",
text: strings.autosave,
value: values.autosave,
valueText: (value) => (value ? value : strings.no),
prompt: strings.delay + " (>=1000 || 0)",
promptType: "number",
promptOptions: {
test(value) {
value = Number.parseInt(value);
return value >= 1000 || value === 0;
},
},
},
{
key: "fontSize",
text: strings["font size"],
value: values.fontSize,
prompt: strings["font size"],
promptOptions: {
required: true,
match: constants.FONT_SIZE,
},
},
{
key: "shiftClickSelection",
text: strings["shift click selection"],
checkbox: values.shiftClickSelection,
},
{
key: "softTab",
text: strings["soft tab"],
checkbox: values.softTab,
},
{
key: "tabSize",
text: strings["tab size"],
value: values.tabSize,
prompt: strings["tab size"],
promptType: "number",
promptOptions: {
test(value) {
value = Number.parseInt(value);
return value >= 1 && value <= 8;
},
},
},
{
key: "linenumbers",
text: strings["show line numbers"],
checkbox: values.linenumbers,
},
{
key: "lintGutter",
text: strings["lint gutter"] || "Show lint gutter",
checkbox: values.lintGutter ?? true,
},
{
key: "lineHeight",
text: strings["line height"],
value: values.lineHeight,
prompt: strings["line height"],
promptType: "number",
promptOptions: {
test(value) {
value = Number.parseFloat(value);
return value >= 1 && value <= 2;
},
},
},
{
key: "formatOnSave",
text: strings["format on save"],
checkbox: values.formatOnSave,
},
{
key: "showSpaces",
text: strings["show spaces"],
checkbox: values.showSpaces,
},
{
key: "editorFont",
text: strings["editor font"],
value: values.editorFont,
get select() {
return fonts.getNames();
},
},
{
key: "liveAutoCompletion",
text: strings["live autocompletion"],
checkbox: values.liveAutoCompletion,
},
// {
// key: "showPrintMargin",
// text: strings["show print margin"].capitalize(),
// checkbox: values.showPrintMargin,
// },
// {
// key: "printMargin",
// text: strings["print margin"],
// value: values.printMargin,
// prompt: strings["print margin"],
// promptType: "number",
// promptOptions: {
// test(value) {
// value = Number.parseInt(value);
// return value >= 10 && value <= 200;
// },
// },
// },
{
key: "textWrap",
text: strings["text wrap"],
checkbox: values.textWrap,
},
{
key: "teardropSize",
text: strings["cursor controller size"],
value: values.teardropSize,
valueText(value) {
return this.select.find(([v]) => v === value)[1];
},
select: [
[0, strings.none],
[20, strings.small],
[30, strings.medium],
[60, strings.large],
],
},
{
key: "relativeLineNumbers",
text: strings["relative line numbers"],
checkbox: values.relativeLineNumbers,
},
// {
// key: "elasticTabstops",
// text: strings["elastic tabstops"],
// checkbox: values.elasticTabstops,
// },
{
key: "rtlText",
text: strings["line based rtl switching"],
checkbox: values.rtlText,
},
{
key: "hardWrap",
text: strings["hard wrap"],
checkbox: values.hardWrap,
},
// {
// key: "useTextareaForIME",
// text: strings["use textarea for ime"],
// checkbox: values.useTextareaForIME,
// },
{
key: "fadeFoldWidgets",
text: strings["fade fold widgets"],
checkbox: values.fadeFoldWidgets,
},
{
key: "rainbowBrackets",
text: strings["rainbow brackets"] || "Rainbow brackets",
checkbox: values.rainbowBrackets ?? true,
},
{
key: "indentGuides",
text: strings["indent guides"] || "Indent guides",
checkbox: values.indentGuides ?? true,
},
{
index: 0,
key: "scroll-settings",
text: strings["scroll settings"],
},
{
key: "colorPreview",
text: strings["color preview"],
checkbox: values.colorPreview,
},
];
return settingsPage(title, items, callback);
/**
* Callback for settings page when an item is clicked
* @param {string} key
* @param {string} value
*/
function callback(key, value) {
switch (key) {
case "scroll-settings":
appSettings.uiSettings[key].show();
break;
case "editorFont":
fonts.setFont(value);
default:
appSettings.update({
[key]: value,
});
break;
}
}
}