1 module app;
2 
3 import dlangui;
4 import std.stdio;
5 import std.conv;
6 import dlangide.ui.frame;
7 import dlangide.ui.commands;
8 import dlangide.workspace.workspace;
9 import std.experimental.logger;
10 
11 mixin APP_ENTRY_POINT;
12 
13 /// entry point for dlangui based application
14 extern (C) int UIAppMain(string[] args) {
15 
16     debug(TestParser) {
17         import ddc.lexer.parser;
18         runParserTests();
19     }
20 
21     version(Windows) {
22         debug {
23             sharedLog = new FileLogger("dcd.log");
24         } else {
25             sharedLog = new NullLogger();
26         }
27     } else {
28         debug {
29             //sharedLog = new FileLogger("dcd.log");
30         } else {
31             sharedLog = new NullLogger();
32         }
33     }
34 
35     //version (Windows) {
36     //    import derelict.lldb.lldbtest;
37     //    runLldbTests();
38     //}
39 
40     // embed non-standard resources listed in views/resources.list into executable
41     embeddedResourceList.addResources(embedResourcesFromList!("resources.list")());
42 
43     Platform.instance.uiTheme = "ide_theme_default";
44 
45     // you can override default hinting mode here
46     //FontManager.hintingMode = HintingMode.Light;
47     //FontManager.hintingMode = HintingMode.AutoHint;
48     FontManager.hintingMode = HintingMode.Normal;
49     //FontManager.hintingMode = HintingMode.Disabled;
50     // you can override antialiasing setting here
51     FontManager.minAnitialiasedFontSize = 0;
52     /// set font gamma (1.0 is neutral, < 1.0 makes glyphs lighter, >1.0 makes glyphs bolder)
53     FontManager.fontGamma = 0.8;
54     version (USE_OPENGL) {
55         // you can turn on subpixel font rendering (ClearType) here
56         FontManager.subpixelRenderingMode = SubpixelRenderingMode.None; //
57         FontManager.fontGamma = 0.9;
58         FontManager.hintingMode = HintingMode.AutoHint;
59     } else {
60         version (USE_FREETYPE) {
61             // you can turn on subpixel font rendering (ClearType) here
62             FontManager.fontGamma = 0.8;
63             //FontManager.subpixelRenderingMode = SubpixelRenderingMode.BGR; //SubpixelRenderingMode.None; //
64             FontManager.hintingMode = HintingMode.AutoHint;
65         }
66     }
67 
68     //version(USE_WIN_DEBUG) {
69     //    debuggerTest();
70     //}
71     //version(USE_GDB_DEBUG) {
72     //    debuggerTestGDB();
73     //}
74     version(unittest) {
75         return 0;
76     } else {
77 
78         // create window
79         Window window = Platform.instance.createWindow("Dlang IDE", null, WindowFlag.Resizable, 900, 730);
80         static if (BACKEND_GUI) {
81             // set window icon
82             window.windowIcon = drawableCache.getImage("dlangui-logo1");
83         }
84     
85         //Widget w = new Widget();
86         //pragma(msg, w.click.return_t, "", w.click.params_t);
87 
88         IDEFrame frame = new IDEFrame(window);
89 
90 
91         // open home screen tab
92         frame.showHomeScreen();
93         // for testing: load workspace at startup
94         //frame.openFileOrWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));
95 
96         // show window
97         window.show();
98 
99         //jsonTest();
100 
101         // run message loop
102         return Platform.instance.enterMessageLoop();
103     }
104 }
105 
106 /*
107 version(USE_WIN_DEBUG) {
108     void debuggerTest() {
109         import ddebug.windows.windebug;
110         WinDebugger debugger = new WinDebugger("test\\dmledit.exe", "");
111         debugger.start();
112     }
113 }
114 
115 version(USE_GDB_DEBUG) {
116     void debuggerTestGDB() {
117         import ddebug.gdb.gdbinterface;
118         import core.thread;
119         Log.d("Testing GDB debugger");
120         DebuggerBase debugger = new DebuggerBase();
121         debugger.startDebugging("gdb", "test", [], "", delegate(ResponseCode code, string msg) {
122                 Log.d("startDebugging result: ", code, " : ", msg);
123                 //assert(code == ResponseCode.NotImplemented);
124             });
125         debugger.stop();
126         destroy(debugger);
127 
128         // async
129 
130         debugger = new GDBInterface();
131         DebuggerProxy proxy = new DebuggerProxy(debugger, delegate(Runnable runnable) {
132                 runnable();
133             });
134         Log.d("calling debugger.start()");
135         debugger.start();
136         Log.d("calling proxy.startDebugging()");
137         proxy.startDebugging("gdb", "/home/lve/src/d/dlangide/test/gdbtest", ["param1", "param2"], "/home/lve/src/d/dlangide/test", delegate(ResponseCode code, string msg) {
138                 Log.d("startDebugging result: ", code, " : ", msg);
139                 //assert(code == ResponseCode.NotImplemented);
140             });
141         Thread.sleep(dur!"msecs"(200000));
142         debugger.stop();
143         Thread.sleep(dur!"msecs"(200000));
144         destroy(debugger);
145         Log.d("Testing of GDB debugger is finished");
146     }
147 }
148 */
149 
150 unittest {
151     void jsonTest() {
152         import dlangui.core.settings;
153         Setting s = new Setting();
154         s["param1_ulong"] = cast(ulong)1543453u;
155         s["param2_long"] = cast(long)-22934;
156         s["param3_double"] = -39.123e-10;
157         s["param4_string"] = "some string value";
158         s["param5_bool_true"] = true;
159         s["param6_bool_false"] = false;
160         s["param7_null"] = new Setting();
161         Setting a = new Setting();
162         a[0] = cast(ulong)1u;
163         a[1] = cast(long)-2;
164         a[2] = 3.3;
165         a[3] = "some string value";
166         a[4] = true;
167         a[5] = false;
168         a[6] = new Setting();
169         Setting mm = new Setting();
170         mm["n"] = cast(ulong)5u;
171         mm["name"] = "test";
172         a[7] = mm;
173         s["param8_array"] = a;
174         Setting m = new Setting();
175         m["aaa"] = "bbb";
176         m["aaa2"] = cast(ulong)5u;
177         m["aaa3"] = false;
178         s["param9_object"] = m;
179         string json = s.toJSON(true);
180         s.save("test_file.json");
181 
182         Setting loaded = new Setting();
183         loaded.load("test_file.json");
184         string json2 = loaded.toJSON(true);
185         loaded.save("test_file2.json");
186     }
187 
188 }