3 SyntaxColorScheme colorScheme
5 keywordColors = [ skyBlue, skyBlue ];
6 commentColor = Color { 125, 125, 125 };
7 charLiteralColor = Color { 245, 50, 245 };
8 stringLiteralColor = Color { 245, 50, 245 };
9 preprocessorColor = { 120, 220, 140 };
10 numberColor = Color { 0, 192, 192 };
13 Array<float> sizes { [ 6, 7, 8.25f, 9, 10, 10.5f, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, 36, 40, 44, 48, 54, 60, 66, 72, 80, 88, 96 ] };
15 Array<const String> fonts
17 "Bitstream Vera Sans Mono",
30 const String sampleText = //"The Quick Brown Fox Jumps Over The Lazy Dog";
33 "class HelloForm : Window\n"
35 " caption = $\"My First eC Application\";\n"
36 " borderStyle = sizable;\n"
37 " size = { 280, 100 };\n"
39 " displayDriver = \"OpenGL\";\n"
41 " bool OnKeyDown(Key key, unichar ch)\n"
49 " this, position = { 10, 10 }, font = { \"Arial\", 30 },\n"
50 " caption = $\"Hello, World!!\"\n"
54 "HelloForm hello { };\n";
56 Array<FontResource> fontResources { };
58 class DisplayedFace : FontResource
60 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
63 faceName.OnDisplay(surface, x, y, width, fieldData, alignment, displayFlags);
67 class FontPicker : Window
71 background = formColor;
72 caption = $"Font Picker";
73 borderStyle = sizable;
78 anchor = { horz = 9, vert = -26 };
80 virtual bool Window::NotifyChanged();
82 property float fontSize
84 get { return curFont.size; }
86 property const String faceName
88 get { return curFont.faceName; }
91 FontResource curFont { "Consolas", 12};
92 DataField dfSize { class(float) };
95 this, size = { 56, 24 }, anchor = { left = 4, bottom = 4 };
97 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
99 curFont.size = row.GetData(dfSize);
100 for(f : fontResources)
103 f.size = Min(20, curFont.size);
106 listFonts.font = fontResources[0];
108 listFonts.OnLoadGraphics();
109 listFonts.size = listFonts.size; // Fix for scrollbar?
110 listFonts.Update(null);
111 sample.font = curFont;
113 modifiedDocument = true;
114 NotifyChanged(master);
120 this, isCheckbox = true, caption = $"Fixed pitch only", anchor = { left = 68, bottom = 8 };
123 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
125 ideSettings.showFixedPitchFontsOnly = button.checked;
133 this, anchor = { left = 0.439024, top = 16, right = 4, bottom = 8 }, font = curFont;
134 textVertScroll = true;
135 hasVertScroll = true;
136 hasHorzScroll = true;
139 syntaxHighlighting = true;
140 syntaxColorScheme = colorScheme;
143 selectionText = Color { 30, 40, 50 };
145 selectionColor = lightYellow;
147 contents = sampleText;
151 this, anchor = { left = 4, top = 16, right = 0.591463, bottom = 30 }, alwaysHighLight = true;
152 hasVertScroll = true;
153 dontHideScroll = true;
155 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
159 FontResource fr = row.GetData(dfFace);
160 curFont.faceName = fr.faceName;
162 modifiedDocument = true;
163 NotifyChanged(master);
165 sample.font = curFont;
169 DataField dfFace { class(DisplayedFace) };
171 bool OnLoadGraphics()
174 float size = dbSize.GetData(dfSize);
175 int maxSize = (int)(size * 96 / 72 * 1.5);
176 for(f : fontResources)
180 // const String n = f.faceName;
181 displaySystem.FontExtent(font, "W", 1, null, &h);
184 h = font.ascent + font.descent + 5;
185 if(h > maxSize) h = maxSize;
188 listFonts.rowHeight = maxH;
194 dbSize.AddField(dfSize);
197 DataRow row = dbSize.AddRow();
198 row.SetData(dfSize, s);
199 if(s == curFont.size)
200 dbSize.currentRow = row;
202 listFonts.AddField(dfFace);
207 for(f : fontResources)
210 fontResources.RemoveAll();
215 Map<String, FontInfo> fonts = ListAvailableFonts();
218 bool fixedPitchOnly = ideSettings.showFixedPitchFontsOnly;
220 curFont.faceName = ideSettings.codeEditorFont;
221 curFont.size = fontSize = ideSettings.codeEditorFontSize;
223 cbFixedPitch.checked = fixedPitchOnly;
224 fontResources.minAllocSize = fonts.GetCount();
226 for(sRow = dbSize.firstRow; sRow; sRow = sRow.next)
228 float s = sRow.GetData(dfSize);
229 if(fontSize - s < 0.5 || s > fontSize)
231 dbSize.currentRow = sRow;
236 for(f : fonts; f.defaultOrAnsiCharSet && (!fixedPitchOnly || f.fixedPitch))
238 FontResource fr { &f, curFont.size, window = this };
239 DataRow row = listFonts.AddRow();
241 row.SetData(dfFace, fr);
242 if(!strcmp(&f, curFont.faceName))
243 listFonts.currentRow = row;
244 fontResources.Add(fr);
251 //FontPicker fontPicker { };
254 Color selectionColor = lightYellow;
255 Color selectionText = Color { 30, 40, 50 };
256 Color viewsBackground = Color { 30, 40, 50 };
257 Color viewsText = lightGray;
258 Color outputBackground = black;
259 Color outputText = lime;
260 Color projectViewBackground = Color { 30, 40, 50 };
261 Color projectViewText = lightGray;
262 Color codeEditorBG = black;
263 Color codeEditorFG = ivory;
264 Color marginColor = Color {24, 24, 24};
265 Color selectedMarginColor = Color {64, 64, 64};
266 Color lineNumbersColor = Color {160, 160, 160};