1 #include "ide.h"
2 
3 #define LLOG(x) // LOG(x)
4 
CharFilterVar(int c)5 int CharFilterVar(int c)
6 {
7 	return IsAlNum(c) || c == '_' ? c : 0;
8 }
9 
DlCharset(DropList & d)10 void DlCharset(DropList& d)
11 {
12 	d.Add(CHARSET_UTF8, "UTF8");
13 	d.Add(TextCtrl::CHARSET_UTF8_BOM, "UTF8 BOM");
14 	d.Add(TextCtrl::CHARSET_UTF16_LE, "UTF16 LE");
15 	d.Add(TextCtrl::CHARSET_UTF16_BE, "UTF16 BE");
16 	d.Add(TextCtrl::CHARSET_UTF16_LE_BOM, "UTF16 LE BOM");
17 	d.Add(TextCtrl::CHARSET_UTF16_BE_BOM, "UTF16 BE BOM");
18 	for(int i = 1; i < CharsetCount(); i++)
19 		d.Add(i, CharsetName(i));
20 }
21 
22 class FontSelectManager {
23 	DropList *face;
24 	DropList *height;
25 	Option   *bold;
26 	Option   *italic;
27 
28 	void FaceSelect();
29 	void Select();
30 
31 public:
32 	Event<>   WhenAction;
33 
34 	typedef FontSelectManager CLASSNAME;
35 
36 	void Set(DropList& _face, DropList& _height,
37 	         Option& _bold, Option& _italic, bool gui = false);
38 	void Set(Font f);
39 	Font Get();
40 };
41 
FaceSelect()42 void FontSelectManager::FaceSelect() {
43 	Select();
44 }
45 
Select()46 void FontSelectManager::Select() {
47 	WhenAction();
48 }
49 
LoadFonts(DropList * face,Index<String> & fni,bool fixed)50 void LoadFonts(DropList *face, Index<String>& fni, bool fixed)
51 {
52 	for(int i = 0; i < Font::GetFaceCount(); i++)
53 		if(!!(Font::GetFaceInfo(i) & Font::FIXEDPITCH) == fixed) {
54 			String n = Font::GetFaceName(i);
55 			if(fni.Find(n)
56 			 < 0) {
57 				fni.Add(n);
58 				face->Add(i, n);
59 			}
60 		}
61 }
62 
Set(DropList & _face,DropList & _height,Option & _bold,Option & _italic,bool gui)63 void FontSelectManager::Set(DropList& _face, DropList& _height,
64                             Option& _bold, Option& _italic, bool gui) {
65 	face = &_face;
66 	face->WhenAction = THISBACK(FaceSelect);
67 	height = &_height;
68 	height->WhenAction = THISBACK(Select);
69 	bold = &_bold;
70 	bold->WhenAction = THISBACK(Select);
71 	italic = &_italic;
72 	italic->WhenAction = THISBACK(Select);
73 	face->Clear();
74 	if(gui) {
75 		face->Add(Font::ARIAL);
76 		face->Add(Font::ROMAN);
77 		face->Add(Font::COURIER);
78 		for(int i = Font::COURIER + 1; i < Font::GetFaceCount(); i++)
79 			if(Font::GetFaceInfo(i) & Font::SCALEABLE)
80 				face->Add(i);
81 
82 		struct DisplayFace : public Display {
83 			void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const {
84 				int ii = q;
85 				Font fnt = StdFont();
86 				if(!(Font::GetFaceInfo(ii) & Font::SPECIAL))
87 					fnt.Face(ii);
88 				w.DrawRect(r, paper);
89 				w.DrawText(r.left, r.top + (r.Height() - fnt.Info().GetHeight()) / 2,
90 				           Font::GetFaceName((int)q), fnt, ink);
91 			}
92 		};
93 		face->SetDisplay(Single<DisplayFace>());
94 	}
95 	else {
96 		Index<String> fni;
97 		LoadFonts(face, fni, true);
98 		face->AddSeparator();
99 		LoadFonts(face, fni, false);
100 		face->SetIndex(0);
101 		height->ClearList();
102 	}
103 	for(int i = 6; i < 64; i++)
104 		height->Add(i);
105 	FaceSelect();
106 }
107 
Set(Font f)108 void FontSelectManager::Set(Font f) {
109 	int fi = f.GetFace();
110 	if(!face->HasKey(fi)) {
111 		fi = face->FindValue(f.GetFaceName());
112 		if(fi < 0)
113 			fi = Font::COURIER;
114 		else
115 			fi = face->GetKey(fi);
116 	}
117 	face->SetData(fi);
118 	FaceSelect();
119 	height->SetData(f.GetHeight());
120 	for(int i = 0; i < height->GetCount(); i++) {
121 		int q = height->GetKey(i);
122 		if(f.GetHeight() <= q) {
123 			height->SetData(q);
124 			break;
125 		}
126 	}
127 	*bold = f.IsBold();
128 	*italic = f.IsItalic();
129 }
130 
Get()131 Font FontSelectManager::Get() {
132 	Font f(face->GetData(), height->GetData());
133 	if(*bold) f.Bold();
134 	if(*italic) f.Italic();
135 	return f;
136 }
137 
UpdateFormat(CodeEditor & editor)138 void Ide::UpdateFormat(CodeEditor& editor)
139 {
140 	if(!IsActiveFile() || ActiveFile().tabsize <= 0)
141 		editor.TabSize(editortabsize);
142 	editor.IndentSpaces(indent_spaces);
143 	editor.IndentAmount(indent_amount);
144 	editor.ShowTabs(show_tabs);
145 	editor.ShowSpaces(show_spaces);
146 	editor.ShowLineEndings(show_tabs);
147 	editor.WarnWhiteSpace(warnwhitespace);
148 	editor.NoParenthesisIndent(no_parenthesis_indent);
149 	editor.HiliteScope(hilite_scope);
150 	editor.HiliteBracket(hilite_bracket);
151 	editor.HiliteIfDef(hilite_ifdef);
152 	editor.BarLine(barline);
153 	editor.HiliteIfEndif(hilite_if_endif);
154 	editor.ThousandsSeparator(thousands_separator);
155 	editor.ShowCurrentLine(hline ? HighlightSetup::GetHlStyle(HighlightSetup::SHOW_LINE).color : (Color)Null);
156 	editor.ShowCurrentColumn(vline ? HighlightSetup::GetHlStyle(HighlightSetup::SHOW_COLUMN).color : (Color)Null);
157 	editor.LineNumbers(line_numbers);
158 	editor.AutoEnclose(auto_enclose);
159 	editor.MarkLines(mark_lines);
160 	editor.BorderColumn(bordercolumn, bordercolor);
161 	editor.PersistentFindReplace(persistent_find_replace);
162 	editor.FindReplaceRestorePos(find_replace_restore_pos);
163 	editor.Refresh();
164 }
165 
UpdateFormat()166 void Ide::UpdateFormat() {
167 	SetupEditor();
168 	UpdateFormat(editor);
169 	UpdateFormat(editor2);
170 	console.SetFont(consolefont);
171 	console.WrapText(wrap_console_text);
172 	statusbar.Show(show_status_bar);
173 	SetupBars();
174 
175 	if(!designer) {
176 		if(filetabs >=0) {
177 			tabs.SetAlign(filetabs);
178 			editpane.SetFrame(tabs);
179 		}
180 		else
181 			editpane.SetFrame(NullFrame());
182 	}
183 
184 	tabs.Grouping(tabs_grouping);
185 	tabs.Stacking(tabs_stacking);
186 	tabs.FileIcons(tabs_icons, false);
187 	tabs.Crosses(tabs_crosses >= 0, tabs_crosses);
188 }
189 
EditorFontScroll(int d)190 void Ide::EditorFontScroll(int d)
191 {
192 	if(!IsActiveFile())
193 		return;
194 	Package::File& f = ActiveFile();
195 	if(f.font != 0 || editorsplit.GetZoom() < 0)
196 		return;
197 	int h = editorfont.GetCy();
198 	int q = editorfont.GetHeight();
199 	while(editorfont.GetCy() == h && (d < 0 ? editorfont.GetCy() > 5 : editorfont.GetCy() < 40))
200 		editorfont.Height(q += d);
201 	editor.SetFont(editorfont);
202 	editor.EditorBarLayout();
203 }
204 
205 struct FormatDlg : TabDlg {
206 	ColorPusher hl_color[CodeEditor::HL_COUNT];
207 };
208 
HlPusherFactory(One<Ctrl> & ctrl)209 void HlPusherFactory(One<Ctrl>& ctrl)
210 {
211 	ctrl.Create<ColorPusher>().NotNull().Track();
212 }
213 
ReadHlStyles(ArrayCtrl & hlstyle)214 void Ide::ReadHlStyles(ArrayCtrl& hlstyle)
215 {
216 	hlstyle.Clear();
217 	for(int i = 0; i < CodeEditor::HL_COUNT; i++) {
218 		const HlStyle& s = editor.GetHlStyle(i);
219 		hlstyle.Add(editor.GetHlName(i), s.color, s.bold, s.italic, s.underline);
220 	}
221 }
222 
223 class AStyleSetupDialog : public WithSetupAstyleLayout<ParentCtrl> {
224 	Ide *ide;
225 
226 	typedef AStyleSetupDialog CLASSNAME;
227 
228 public:
229 	AStyleSetupDialog(Ide *_ide);
230 	void AstyleTest();
231 	void UppDefaults();
232 };
233 
AStyleSetupDialog(Ide * _ide)234 AStyleSetupDialog::AStyleSetupDialog(Ide *_ide)
235 {
236 	ide = _ide;
237 
238 	BracketFormatMode.Add(astyle::NONE_MODE, "none");
239 	BracketFormatMode.Add(astyle::ATTACH_MODE, "attach");
240 	BracketFormatMode.Add(astyle::BREAK_MODE, "break");
241 	ParensPaddingMode.Add(astyle::PAD_NONE, "no space pad around parenthesis");
242 	ParensPaddingMode.Add(astyle::PAD_INSIDE, "pad parenthesis inside with space");
243 	ParensPaddingMode.Add(astyle::PAD_OUTSIDE, "pad parenthesis outside with space");
244 	ParensPaddingMode.Add(astyle::PAD_BOTH, "pad both parenthesis sides with spaces");
245 
246 	Test <<= THISBACK(AstyleTest);
247 	Defaults << THISBACK(UppDefaults);
248 
249 }
250 
AstyleTest()251 void AStyleSetupDialog::AstyleTest()
252 {
253 	astyle::ASFormatter Formatter;
254 
255 	// sets up parameters from astyle dialog
256 	Formatter.setBracketIndent(BracketIndent);
257 	Formatter.setNamespaceIndent(NamespaceIndent);
258 	Formatter.setBlockIndent(BlockIndent);
259 	Formatter.setCaseIndent(CaseIndent);
260 	Formatter.setClassIndent(ClassIndent);
261 	Formatter.setLabelIndent(LabelIndent);
262 	Formatter.setSwitchIndent(SwitchIndent);
263 	Formatter.setPreprocessorIndent(PreprocessorIndent);
264 	Formatter.setMaxInStatementIndentLength(MaxInStatementIndentLength);
265 	Formatter.setMinConditionalIndentLength(MinInStatementIndentLength);
266 	Formatter.setBreakClosingHeaderBracketsMode(BreakClosingHeaderBracketsMode);
267 	Formatter.setBreakElseIfsMode(BreakElseIfsMode);
268 	Formatter.setBreakOneLineBlocksMode(BreakOneLineBlocksMode);
269 	Formatter.setSingleStatementsMode(SingleStatementsMode);
270 	Formatter.setBreakBlocksMode(BreakBlocksMode);
271 	Formatter.setBreakClosingHeaderBlocksMode(BreakClosingHeaderBlocksMode);
272 	Formatter.setBracketFormatMode((astyle::BracketMode)BracketFormatMode.GetIndex());
273 	switch(ParensPaddingMode.GetIndex()) {
274 	case astyle::PAD_INSIDE :
275 		Formatter.setParensInsidePaddingMode(true);
276 		Formatter.setParensOutsidePaddingMode(false);
277 		break;
278 	case astyle::PAD_OUTSIDE :
279 		Formatter.setParensInsidePaddingMode(false);
280 		Formatter.setParensOutsidePaddingMode(true);
281 		break;
282 	case astyle::PAD_BOTH :
283 		Formatter.setParensInsidePaddingMode(true);
284 		Formatter.setParensOutsidePaddingMode(true);
285 		break;
286 	default :
287 		Formatter.setParensOutsidePaddingMode(false);
288 		Formatter.setParensInsidePaddingMode(false);
289 		break;
290 	}
291 	Formatter.setParensUnPaddingMode(ParensUnPaddingMode);
292 	Formatter.setOperatorPaddingMode(OperatorPaddingMode);
293 	Formatter.setEmptyLineFill(EmptyLineFill);
294 	Formatter.setTabSpaceConversionMode(TabSpaceConversionMode);
295 	Formatter.setTabIndentation(ide->editortabsize, ide->indent_spaces ? false : true);
296 	Formatter.setSpaceIndentation(ide->indent_spaces ? ide->indent_amount : ide->editortabsize);
297 
298 	// formats text in test box
299 	TestBox.Set(ide->FormatCodeString(TestBox.GetW(), Formatter));
300 }
301 
UppDefaults()302 void AStyleSetupDialog::UppDefaults()
303 {
304 	BracketIndent = false;
305 	NamespaceIndent = true;
306 	BlockIndent = false;
307 	CaseIndent = true;
308 	ClassIndent = true;
309 	LabelIndent = true;
310 	SwitchIndent = true;
311 	PreprocessorIndent = false;
312 	MaxInStatementIndentLength = 20;
313 	MinInStatementIndentLength = 2;
314 	BreakClosingHeaderBracketsMode = 0;
315 	BreakElseIfsMode = true;
316 	BreakOneLineBlocksMode = true;
317 	SingleStatementsMode = true;
318 	BreakBlocksMode = false;
319 	BreakClosingHeaderBlocksMode = false;
320 	BracketFormatMode.SetIndex(1);
321 	ParensPaddingMode.SetIndex(0);
322 	ParensUnPaddingMode = true;
323 	OperatorPaddingMode = false;
324 	EmptyLineFill = false;
325 	TabSpaceConversionMode = false;
326 }
327 
SetConsole(EditString * e,const char * text)328 void SetConsole(EditString *e, const char *text)
329 {
330 	*e <<= text;
331 }
332 
AddPath(EditString * es)333 void AddPath(EditString *es)
334 {
335 	String s = SelectDirectory();
336 	if(IsNull(s))
337 		return;
338 	String h = ~*es;
339 	if(h.GetCount() && *h.Last() != ';')
340 		h << ';';
341 	h << s;
342 	*es <<= h;
343 	es->SetWantFocus();
344 }
345 
InsertPath(EditString * es)346 void InsertPath(EditString *es)
347 {
348 	String s = SelectDirectory();
349 	if(IsNull(s))
350 		return;
351 	es->Clear();
352 	*es <<= s;
353 	es->SetWantFocus();
354 }
355 
DlSpellerLangs(DropList & dl)356 void DlSpellerLangs(DropList& dl)
357 {
358 	static Vector<int> lng;
359 	ONCELOCK {
360 		VectorMap<int, String> lngs;
361 		String path = GetExeDirFile("speller") + ';' + ConfigFile("speller") + ';' +
362 		              GetExeFolder() + ';' + GetConfigFolder() + ';' +
363 		              getenv("LIB") + ';' + getenv("PATH");
364 #ifdef PLATFORM_POSIX
365 		path << "/usr/local/share/upp/speller;/usr/local/share/upp;/usr/share/upp/speller;/usr/share/upp";
366 #endif
367 		Vector<String> p = Split(path, ';');
368 		for(auto dir : p) {
369 			FindFile ff(AppendFileName(dir, "*.udc"));
370 			while(ff) {
371 				int lang = LNGFromText(ff.GetName());
372 				if(lang)
373 					lngs.Add(lang, LNGAsText(lang));
374 				ff.Next();
375 			}
376 		}
377 		SortByValue(lngs);
378 		lng = lngs.PickKeys();
379 	}
380 	dl.Add(0, "Off");
381 	for(auto l : lng)
382 		dl.Add(l, LNGAsText(l));
383 }
384 
SetupFormat()385 void Ide::SetupFormat() {
386 	FormatDlg dlg;
387 	dlg.Title("Settings");
388 	WithSetupFontLayout<ParentCtrl> fnt;
389 	WithSetupHlLayout<ParentCtrl> hlt;
390 	WithSetupEditorLayout<ParentCtrl> edt;
391 	WithSetupIdeLayout<ParentCtrl> ide;
392 	WithSetupAssistLayout<ParentCtrl> assist;
393 	AStyleSetupDialog ast(this);
394 #ifdef PLATFORM_WIN32
395 	ide.console_txt.Hide();
396 	ide.console.Hide();
397 	ide.kde.Hide();
398 	ide.gnome.Hide();
399 	ide.xterm.Hide();
400 	ide.mate.Hide();
401 	ide.lxde.Hide();
402 #endif
403 	ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e");
404 	ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x");
405 	ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x");
406 	ide.lxde <<= callback2(SetConsole, &ide.console, "/usr/bin/lxterminal -e");
407 	ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e");
408 
409 	edt.lineends
410 		.Add(LF, "LF")
411 		.Add(CRLF, "CRLF")
412 		.Add(DETECT_LF, "Detect with default LF")
413 		.Add(DETECT_CRLF, "Detect with default CRLF");
414 
415 	edt.filetabs
416 		.Add(AlignedFrame::LEFT, "Left")
417 		.Add(AlignedFrame::TOP, "Top")
418 		.Add(AlignedFrame::RIGHT, "Right")
419 		.Add(AlignedFrame::BOTTOM, "Bottom")
420 		.Add(-1, "Off");
421 
422 	edt.tabs_crosses
423 		.Add(AlignedFrame::LEFT, "Left")
424 		.Add(AlignedFrame::RIGHT, "Right")
425 		.Add(-1, "Off");
426 
427 	dlg.Add(fnt, "Fonts");
428 	dlg.Add(hlt, "Syntax highlighting");
429 	dlg.Add(edt, "Editor");
430 	dlg.Add(assist, "Assist");
431 	dlg.Add(ide, "IDE");
432 	dlg.Add(ast, "Code formatting");
433 	dlg.WhenClose = dlg.Acceptor(IDEXIT);
434 
435 	FontSelectManager ed, vf, con, f1, f2, tf, gui;
436 	ed.Set(fnt.face, fnt.height, fnt.bold, fnt.italic);
437 	vf.Set(fnt.vface, fnt.vheight, fnt.vbold, fnt.vitalic);
438 	con.Set(fnt.cface, fnt.cheight, fnt.cbold, fnt.citalic);
439 	tf.Set(fnt.tface, fnt.theight, fnt.tbold, fnt.titalic);
440 	f1.Set(fnt.face1, fnt.height1, fnt.bold1, fnt.italic1);
441 	f2.Set(fnt.face2, fnt.height2, fnt.bold2, fnt.italic2);
442 	gui.Set(ide.face, ide.height, ide.bold, ide.italic, true);
443 
444 	ed.Set(editorfont);
445 	vf.Set(veditorfont);
446 	con.Set(consolefont);
447 	tf.Set(tfont);
448 	f1.Set(font1);
449 	f2.Set(font2);
450 	gui.Set(gui_font);
451 
452 	DlCharset(edt.charset);
453 	edt.tabsize.MinMax(1, 100).NotNull();
454 	edt.tabsize <<= editortabsize;
455 	edt.indent_amount.MinMax(1, 100).NotNull();
456 	edt.indent_amount <<= indent_spaces ? indent_amount : editortabsize;
457 	edt.indent_amount.Enable(indent_spaces);
458 	CtrlRetriever rtvr;
459 	int hs = hilite_scope;
460 
461 	DlSpellerLangs(edt.spellcheck_comments);
462 
463 	rtvr
464 		(hlt.hilite_scope, hs)
465 		(hlt.hilite_bracket, hilite_bracket)
466 		(hlt.hilite_ifdef, hilite_ifdef)
467 		(hlt.hilite_if_endif, hilite_if_endif)
468 		(hlt.thousands_separator, thousands_separator)
469 		(hlt.hline, hline)
470 		(hlt.vline, vline)
471 
472 		(edt.indent_spaces, indent_spaces)
473 		(edt.no_parenthesis_indent, no_parenthesis_indent)
474 		(edt.showtabs, show_tabs)
475 		(edt.showspaces, show_spaces)
476 		(edt.warnwhitespace, warnwhitespace)
477 		(edt.lineends, line_endings)
478 		(edt.numbers, line_numbers)
479 		(edt.bookmark_pos, bookmark_pos)
480 		(edt.bordercolumn, bordercolumn)
481 		(edt.bordercolor, bordercolor)
482 		(edt.findpicksel, find_pick_sel)
483 		(edt.findpicktext, find_pick_text)
484 		(edt.deactivate_save, deactivate_save)
485 		(edt.filetabs, filetabs)
486 		(edt.tabs_icons, tabs_icons)
487 		(edt.tabs_crosses, tabs_crosses)
488 		(edt.tabs_grouping, tabs_grouping)
489 		(edt.tabs_stacking, tabs_stacking)
490 		(edt.tabs_serialize, tabs_serialize)
491 		(edt.spellcheck_comments, spellcheck_comments)
492 		(edt.wordwrap_comments, wordwrap_comments)
493 		(edt.persistent_find_replace, persistent_find_replace)
494 		(edt.find_replace_restore_pos, find_replace_restore_pos)
495 
496 		(assist.barline, barline)
497 		(assist.auto_enclose, auto_enclose)
498 		(assist.commentdp, editor.commentdp)
499 		(assist.header_guards, header_guards)
500 		(assist.insert_include, insert_include)
501 		(assist.mark_lines, mark_lines)
502 		(assist.qtfsel, qtfsel)
503 		(assist.assist, editor.auto_assist)
504 		(assist.rescan, auto_rescan)
505 		(assist.check, auto_check)
506 		(assist.navigator_right, editor.navigator_right)
507 
508 		(ide.showtime, showtime)
509 		(ide.show_status_bar, show_status_bar)
510 		(ide.toolbar_in_row, toolbar_in_row)
511 		(ide.splash_screen, splash_screen)
512 		(ide.sort, sort)
513 		(ide.mute_sounds, mute_sounds)
514 		(ide.wrap_console_text, wrap_console_text)
515 		(ide.hydra1_threads, hydra1_threads)
516 		(ide.chstyle, chstyle)
517 		(ide.console, LinuxHostConsole)
518 		(ide.output_per_assembly, output_per_assembly)
519 		(ide.setmain_newide, setmain_newide)
520 		(ide.gui_font, gui_font_override)
521 
522 		(ast.BracketIndent,					astyle_BracketIndent)
523 		(ast.NamespaceIndent,               astyle_NamespaceIndent)
524 		(ast.BlockIndent,                   astyle_BlockIndent)
525 		(ast.CaseIndent,                    astyle_CaseIndent)
526 		(ast.ClassIndent,                   astyle_ClassIndent)
527 		(ast.LabelIndent,                   astyle_LabelIndent)
528 		(ast.SwitchIndent,                  astyle_SwitchIndent)
529 		(ast.PreprocessorIndent,            astyle_PreprocessorIndent)
530 		(ast.MinInStatementIndentLength,    astyle_MinInStatementIndentLength)
531 		(ast.MaxInStatementIndentLength,    astyle_MaxInStatementIndentLength)
532 		(ast.BreakClosingHeaderBracketsMode,astyle_BreakClosingHeaderBracketsMode)
533 		(ast.BreakElseIfsMode,              astyle_BreakElseIfsMode)
534 		(ast.BreakOneLineBlocksMode,        astyle_BreakOneLineBlocksMode)
535 		(ast.SingleStatementsMode,          astyle_SingleStatementsMode)
536 		(ast.BreakBlocksMode,               astyle_BreakBlocksMode)
537 		(ast.BreakClosingHeaderBlocksMode,  astyle_BreakClosingHeaderBlocksMode)
538 		(ast.BracketFormatMode,             astyle_BracketFormatMode)
539 		(ast.ParensPaddingMode,             astyle_ParensPaddingMode)
540 		(ast.ParensUnPaddingMode,           astyle_ParensUnPaddingMode)
541 		(ast.OperatorPaddingMode,           astyle_OperatorPaddingMode)
542 		(ast.EmptyLineFill,                 astyle_EmptyLineFill)
543 		(ast.TabSpaceConversionMode,        astyle_TabSpaceConversionMode)
544 		(ast.TestBox,						astyle_TestBox)
545 	;
546 	hlt.hlstyle.AddColumn("Style");
547 	hlt.hlstyle.AddColumn("Color").Ctrls(HlPusherFactory);
548 	hlt.hlstyle.AddColumn("Bold").Ctrls<Option>();
549 	hlt.hlstyle.AddColumn("Italic").Ctrls<Option>();
550 	hlt.hlstyle.AddColumn("Underline").Ctrls<Option>();
551 	hlt.hlstyle.ColumnWidths("211 80 45 45 80");
552 	hlt.hlstyle.EvenRowColor().NoHorzGrid().SetLineCy(EditField::GetStdHeight() + 2);
553 	ReadHlStyles(hlt.hlstyle);
554 	edt.charset <<= (int)default_charset;
555 	edt.tabsize.WhenAction = rtvr <<=
556 		hlt.hlstyle.WhenCtrlsAction = ed.WhenAction = tf.WhenAction =
557 		con.WhenAction = f1.WhenAction = f2.WhenAction = dlg.Breaker(222);
558 	ide.showtimeafter <<= Nvl((Date)FileGetTime(ConfigFile("version")), GetSysDate() - 1);
559 	hlt.hl_restore <<= dlg.Breaker(333);
560 	hlt.hl_restore_white <<= dlg.Breaker(334);
561 	hlt.hl_restore_dark <<= dlg.Breaker(335);
562 
563 	for(auto sk : GetAllChSkins())
564 		ide.chstyle.Add(ide.chstyle.GetCount(), sk.b);
565 
566 	FrameRight<Button> uscBrowse;
567 	uscBrowse.SetImage(CtrlImg::right_arrow());
568 	uscBrowse <<= callback1(AddPath, &ide.uscpath);
569 	ide.uscpath.AddFrame(uscBrowse);
570 	String usc_path = GetHomeDirFile("usc.path");
571 	ide.uscpath <<= LoadFile(usc_path);
572 
573 	fnt.defaults << [&] {
574 		Ide def;
575 
576 		ed.Set(def.editorfont);
577 		vf.Set(def.veditorfont);
578 		con.Set(def.consolefont);
579 		tf.Set(def.tfont);
580 		f1.Set(def.font1);
581 		f2.Set(def.font2);
582 	};
583 
584 	for(;;) {
585 		int c = dlg.Run();
586 		if(IsNull(ide.uscpath))
587 			FileDelete(usc_path);
588 		else
589 			Upp::SaveFile(GetHomeDirFile("usc.path"), ~ide.uscpath);
590 		editorfont = ed.Get();
591 		tfont = tf.Get();
592 		veditorfont = vf.Get();
593 		consolefont = con.Get();
594 		font1 = f1.Get();
595 		font2 = f2.Get();
596 		gui_font = gui.Get();
597 
598 		editortabsize = Nvl((int)~edt.tabsize, 4);
599 		rtvr.Retrieve();
600 		console.SetSlots(minmax(hydra1_threads, 1, 256));
601 		hilite_scope = hs;
602 		if(indent_spaces)
603 			indent_amount = ~edt.indent_amount;
604 		else {
605 			indent_amount = editortabsize;
606 			edt.indent_amount <<= editortabsize;
607 		}
608 		edt.indent_amount.Enable(indent_spaces);
609 		default_charset = (byte)(int)~edt.charset;
610 		for(int i = 0; i < CodeEditor::HL_COUNT; i++)
611 			editor.SetHlStyle(i, hlt.hlstyle.Get(i, 1), hlt.hlstyle.Get(i, 2),
612 			                     hlt.hlstyle.Get(i, 3), hlt.hlstyle.Get(i, 4));
613 		UpdateFormat();
614 		if(c == IDEXIT)
615 			break;
616 		if(c == 222)
617 			hlstyle_is_default = false;
618 		if(c == 333 && PromptYesNo("Restore default highlighting colors?")) {
619 			editor.DefaultHlStyles();
620 			SetupEditor();
621 			ReadHlStyles(hlt.hlstyle);
622 			hlstyle_is_default = true;
623 		}
624 		if(c == 334 && PromptYesNo("Set white theme?")) {
625 			editor.WhiteTheme();
626 			SetupEditor();
627 			ReadHlStyles(hlt.hlstyle);
628 			hlstyle_is_default = false;
629 		}
630 		if(c == 335 && PromptYesNo("Set dark theme?")) {
631 			editor.DarkTheme();
632 			SetupEditor();
633 			ReadHlStyles(hlt.hlstyle);
634 			hlstyle_is_default = false;
635 		}
636 	}
637 	FileSetTime(ConfigFile("version"), ToTime(~ide.showtimeafter));
638 	FinishConfig();
639 	SaveConfig();
640 }
641 
FinishConfig()642 void Ide::FinishConfig()
643 {
644 	if(filelist.IsCursor()) {
645 		FlushFile();
646 		FileCursor();
647 	}
648 	SaveLoadPackage();
649 }
650 
IsPersistentFindReplace()651 bool Ide::IsPersistentFindReplace()
652 {
653 	return persistent_find_replace;
654 }
655