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 // Open project, if it specified in command line 91 if (args.length > 0) 92 { 93 Action a = ACTION_FILE_OPEN_WORKSPACE.clone(); 94 a.stringParam = args[0].toAbsolutePath; 95 frame.handleAction(a); 96 // Mark that workspace opened to prevent auto open 97 frame.isOpenedWorkspace(true); 98 } 99 100 // open home screen tab 101 if (!frame.isOpenedWorkspace) 102 frame.showHomeScreen(); 103 // for testing: load workspace at startup 104 //frame.openFileOrWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews")); 105 106 // show window 107 window.show(); 108 109 //jsonTest(); 110 111 // run message loop 112 return Platform.instance.enterMessageLoop(); 113 } 114 } 115 116 /* 117 version(USE_WIN_DEBUG) { 118 void debuggerTest() { 119 import ddebug.windows.windebug; 120 WinDebugger debugger = new WinDebugger("test\\dmledit.exe", ""); 121 debugger.start(); 122 } 123 } 124 125 version(USE_GDB_DEBUG) { 126 void debuggerTestGDB() { 127 import ddebug.gdb.gdbinterface; 128 import core.thread; 129 Log.d("Testing GDB debugger"); 130 DebuggerBase debugger = new DebuggerBase(); 131 debugger.startDebugging("gdb", "test", [], "", delegate(ResponseCode code, string msg) { 132 Log.d("startDebugging result: ", code, " : ", msg); 133 //assert(code == ResponseCode.NotImplemented); 134 }); 135 debugger.stop(); 136 destroy(debugger); 137 138 // async 139 140 debugger = new GDBInterface(); 141 DebuggerProxy proxy = new DebuggerProxy(debugger, delegate(Runnable runnable) { 142 runnable(); 143 }); 144 Log.d("calling debugger.start()"); 145 debugger.start(); 146 Log.d("calling proxy.startDebugging()"); 147 proxy.startDebugging("gdb", "/home/lve/src/d/dlangide/test/gdbtest", ["param1", "param2"], "/home/lve/src/d/dlangide/test", delegate(ResponseCode code, string msg) { 148 Log.d("startDebugging result: ", code, " : ", msg); 149 //assert(code == ResponseCode.NotImplemented); 150 }); 151 Thread.sleep(dur!"msecs"(200000)); 152 debugger.stop(); 153 Thread.sleep(dur!"msecs"(200000)); 154 destroy(debugger); 155 Log.d("Testing of GDB debugger is finished"); 156 } 157 } 158 */ 159 160 unittest { 161 void jsonTest() { 162 import dlangui.core.settings; 163 Setting s = new Setting(); 164 s["param1_ulong"] = cast(ulong)1543453u; 165 s["param2_long"] = cast(long)-22934; 166 s["param3_double"] = -39.123e-10; 167 s["param4_string"] = "some string value"; 168 s["param5_bool_true"] = true; 169 s["param6_bool_false"] = false; 170 s["param7_null"] = new Setting(); 171 Setting a = new Setting(); 172 a[0] = cast(ulong)1u; 173 a[1] = cast(long)-2; 174 a[2] = 3.3; 175 a[3] = "some string value"; 176 a[4] = true; 177 a[5] = false; 178 a[6] = new Setting(); 179 Setting mm = new Setting(); 180 mm["n"] = cast(ulong)5u; 181 mm["name"] = "test"; 182 a[7] = mm; 183 s["param8_array"] = a; 184 Setting m = new Setting(); 185 m["aaa"] = "bbb"; 186 m["aaa2"] = cast(ulong)5u; 187 m["aaa3"] = false; 188 s["param9_object"] = m; 189 string json = s.toJSON(true); 190 s.save("test_file.json"); 191 192 Setting loaded = new Setting(); 193 loaded.load("test_file.json"); 194 string json2 = loaded.toJSON(true); 195 loaded.save("test_file2.json"); 196 } 197 198 }