void Ide::ExportProject(const String& ep, bool all, bool gui, bool deletedir) { SaveFile(false); ::Workspace wspc; wspc.Scan(main); Index<String> used; HdependClearDependencies(); for(int i = 0; i < wspc.GetCount(); i++) { const Package& p = wspc.GetPackage(i); String pn = wspc[i]; for(int j = 0; j < p.GetCount(); j++) { const Package::File& f = p[j]; if(!f.separator) { String p = SourcePath(pn, f); used.FindAdd(p); Vector<String> d = HdependGetDependencies(p); for(int q = 0; q < d.GetCount(); q++) used.FindAdd(d[q]); for(int q = 0; q < f.depends.GetCount(); q++) used.FindAdd(SourcePath(pn, f.depends[q].text)); } } } if(FileExists(ep)) { if(gui && !PromptYesNo(DeQtf(ep) + " is existing file.&" "Do you want to delete it?")) return; FileDelete(ep); } if(deletedir && DirectoryExists(ep)) { if(gui && !PromptYesNo(DeQtf(ep) + " is existing directory.&" "Do you want to replace it?")) return; DeleteFolderDeep(ep); } Progress pi("Exporting project"); pi.SetTotal(wspc.GetCount()); for(int i = 0; i < wspc.GetCount(); i++) { if(gui && pi.StepCanceled()) return; CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true); } Vector<String> upp = GetUppDirs(); for(int i = 0; i < upp.GetCount(); i++) { if(gui && pi.StepCanceled()) return; String d = upp[i]; FindFile ff(AppendFileName(d, "*")); while(ff) { if(ff.IsFile()) { String fn = ff.GetName(); String path = AppendFileName(d, fn); if(all || used.Find(path) >= 0) CopyFile(AppendFileName(ep, fn), path, true); } ff.Next(); } CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true); } ExportMakefile(ep); }
String CreateQtf(const String& item, const String& name, const CppItem& m, const String& lang, bool onlyhdr = false) { String qtf; bool str = m.kind == STRUCT || m.kind == STRUCTTEMPLATE; if(!str) qtf << "[s4 &]"; String st = str ? "[s2;" : "[s1;"; String k = st + ':' + DeQtf(item) + ": "; if(m.IsTemplate() && str) { int q = 0; int w = 0; while(q < m.natural.GetLength()) { if(m.natural[q] == '<') w++; if(m.natural[q] == '>') { w--; if(w == 0) { q++; break; } } q++; } qtf << "[s2:noref: " << DecoratedItem(name, m, m.natural.Mid(0, q)) << "&][s2 " << k; if(q < m.natural.GetLength()) { while((byte)m.natural[q] <= 32) q++; qtf << DecoratedItem(name, m, m.natural.Mid(q)); } } else qtf << k << DecoratedItem(name, m, m.natural); qtf << "&]"; if(onlyhdr) return qtf; qtf << "[s3%" << lang << " "; String d; Vector<String> t = Split(m.tname, ';'); for(int i = 0; i < t.GetCount(); i++) { if(i) d << ' '; d << "[%-*@g " << DeQtf(t[i]) << "]"; } d.Clear(); d << "[%" << lang << " "; Vector<String> p = Split(m.pname, ';'); if(!str) for(int i = 0; i < p.GetCount(); i++) d << " [%-*@r " << DeQtf(p[i]) << "]"; if(!str && p.GetCount()) qtf << d << " ."; qtf << "&]"; qtf << "[s7 &]"; return qtf; }
void Pdb::Error(const char *s) { String txt = "Error!&"; if(s) txt << s << "&"; LLOG("ERROR: " << DeQtf(GetLastErrorMessage())); Exclamation(txt + DeQtf(GetLastErrorMessage())); running = false; Stop(); }
void Ide::Licenses() { Progress pi; const Workspace& wspc = IdeWorkspace(); pi.SetTotal(wspc.GetCount()); VectorMap<String, String> license_package; for(int i = 0; i < wspc.GetCount(); i++) { String n = wspc[i]; pi.SetText(n); if(pi.StepCanceled()) return; String l = LoadFile(SourcePath(n, "Copying")); if(l.GetCount()) MergeWith(license_package.GetAdd(l), ", ", n); } if(license_package.GetCount() == 0) { Exclamation("No license files ('Copying') have been found."); return; } String qtf; for(int i = 0; i < license_package.GetCount(); i++) { bool m = license_package[i].Find(',') >= 0; qtf << (m ? "Packages [* \1" : "Package [* \1") << license_package[i] << (m ? "\1] have" : "\1] has") << " following licence notice:&" << "{{@Y [C1 " << DeQtf(license_package.GetKey(i)) << "]}}&&"; } ShowQTF(qtf, "Licenses"); }
bool GuiPackageResolver(const String& error, const String& path, int line) { prompt: switch(Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(), error + "&while parsing package " + DeQtf(path), "Edit \\& Retry", "Ignore", "Stop")) { case 0: if(!PromptYesNo("Ignoring will damage package. Everything past the " "point of error will be lost.&Do you want to continue ?")) goto prompt; return false; case 1: { TopWindow win; LineEdit edit; edit.Set(LoadFile(path)); edit.SetCursor(edit.GetPos(line)); win.Title(path); win.Add(edit.SizePos()); win.Run(); SaveFile(path, edit.Get()); } return true;; case -1: exit(1); } return false; }
void sPut(const String& name, String& qtf, const FileStat& fs) { qtf << "::@W " << DeQtf(Nvl(name, ".<none>")) << ":: [> " << fs.count << ":: " << fs.lines << ":: " << (fs.count ? fs.lines / fs.count : 0) << ":: " << StatLen(fs.len) << ":: " << StatLen(fs.len ? fs.len / fs.count : 0) << ":: " << StatDate(fs.oldest) << ":: " << StatDate(fs.newest) << ":: " << (fs.count ? fs.days / fs.count : 0) << " days]"; }
void TopicEditor::InsertItem() { if(IsNull(topicpath)) return; Save(); ref.Title("Insert"); if(ref.item.IsCursor()) ref.item.SetFocus(); ref.item.MultiSelect(); ref.classlist.Show(); int c = ref.Execute(); if(c == IDCANCEL) return; if(c == IDYES) { String qtf = "&{{1 "; bool next = false; for(int i = 0; i < ref.scope.GetCount(); i++) { String s = ref.scope.Get(i, 1); if(*s != '<') { if(next) qtf << ":: "; qtf << DeQtf(s); next = true; } } qtf << "}}&"; editor.PasteText(ParseQTF(qtf)); return; } String qtf; if(ref.item.IsSelection()) { for(int i = 0; i < ref.item.GetCount(); i++) if(ref.item.IsSelected(i)) { const CppItemInfo& m = ref.GetItemInfo(i); qtf << CreateQtf(ref.GetCodeRef(i), m.name, m, GetLang()); } } else if(ref.item.IsCursor()) { const CppItemInfo& m = ref.GetItemInfo(); qtf << CreateQtf(ref.GetCodeRef(), m.name, m, GetLang()); } else return; editor.BeginOp(); editor.PasteText(ParseQTF(styles + qtf)); editor.PrevPara(); editor.PrevPara(); }
void Ide::Statistics() { Vector< ArrayMap<String, FileStat> > stat; Progress pi; const Workspace& wspc = IdeWorkspace(); pi.SetTotal(wspc.GetCount()); Date now = GetSysDate(); for(int i = 0; i < wspc.GetCount(); i++) { const Package& pk = wspc.GetPackage(i); String n = wspc[i]; pi.SetText(n); if(pi.StepCanceled()) return; ArrayMap<String, FileStat>& pfs = stat.Add(); for(int i = 0; i < pk.GetCount(); i++) if(!pk[i].separator) { String file = SourcePath(n, pk[i]); if(FileExists(file)) { FileStat& fs = pfs.GetAdd(GetFileExt(file)); int d = minmax(now - FileGetTime(file), 0, 9999); fs.oldest = max(d, fs.oldest); fs.newest = min(d, fs.newest); String data = LoadFile(file); for(const char *s = data; *s; s++) if(*s == '\n') fs.lines++; fs.len += data.GetCount(); fs.days += d; fs.count++; } } } String qtf = "[1 "; ArrayMap<String, FileStat> all; String tab = "{{45:20:25:20:35:30:30:30:30@L [* "; String hdr = "]:: [= Files:: Lines:: - avg.:: Length:: - avg.:: Oldest:: Newest:: Avg. age]"; for(int i = 0; i < wspc.GetCount(); i++) { qtf << tab << DeQtf(wspc[i]) << hdr; sPut(qtf, stat[i], all); } qtf << tab << "All packages" << hdr; sPut(qtf, all, all); WithStatLayout<TopWindow> dlg; CtrlLayoutOK(dlg, "Statistics"); dlg.stat = qtf; dlg.Sizeable().Zoomable(); dlg.Run(); }
void Ide::BuildAndExecute() { if(Build()) { int time = msecs(); One<Host> h = CreateHostRunDir(); h->ChDir(Nvl(rundir, GetFileFolder(target))); String cmdline; if(!runexternal) cmdline << '\"' << h->GetHostPath(target) << "\" "; cmdline << ToSystemCharset(runarg); int exitcode; switch(runmode) { case RUN_WINDOW: HideBottom(); h->Launch(cmdline, FindIndex(SplitFlags(mainconfigparam, true), "GUI") < 0); break; case RUN_CONSOLE: ShowConsole(); PutConsole(String().Cat() << "Executing: " << cmdline); console.Sync(); exitcode = h->ExecuteWithInput(cmdline); PutConsole("Finished in " + GetPrintTime(time) + ", exit code: " + AsString(exitcode)); break; case RUN_FILE: { HideBottom(); String fn; if(IsNull(stdout_file)) fn = ForceExt(target, ".ol"); else fn = stdout_file; FileOut out(fn); if(!out) { PromptOK("Unable to open output file [* " + DeQtf(stdout_file) + "] !"); return; } if(h->Execute(cmdline, out) >= 0) { out.Close(); EditFile(fn); } } } } }
void Pdb::MemoryGoto(const String& exp) { CParser p(exp); try { Val v = Exp(p); adr_t adr = 0; if(v.ref > 0) adr = GetRVal(v).address; else if(v.rvalue) adr = (adr_t)GetInt(v); else adr = v.address; memory.SetCursor(adr); memory.SetSc(adr); tab.Set(TAB_MEMORY); } catch(CParser::Error e) { Exclamation("Invalid expression!&" + DeQtf(e)); } }
void TemplateDlg::LoadNest(const char *path, bool main, bool recurse) { FindFile ff(AppendFileName(path, "*.*")); while(ff) { String p = AppendFileName(path, ff.GetName()); if(ff.IsFolder()) { if(recurse) LoadNest(p, main); } else if(ToLower(GetFileExt(ff.GetName())) == ".upt") { try { PackageTemplate t = ReadTemplate(p); if(main && t.main || !main && t.sub) pt.Add() = pick(t); } catch(CParser::Error e) { Exclamation("Package template [* " + DeQtf(p) + "] is invalid&[* " + e); } } ff.Next(); } }
void ShowExc(const Exc& exc, Callback HelpDlg, const char *help) { #ifdef PLATFORM_WIN32 MessageBeep(MB_ICONEXCLAMATION); #endif Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(), DeQtf(exc), HelpDlg, t_("OK"), NULL, NULL, help); }
bool FileTabsExample::OnCloseConfirm(Value v) { return PromptOKCancel(Format("Close '%s'?", DeQtf((String)v))) == 0; }
bool Pdb::RunToException() { DR_LOG("RunToException"); LLOG("RUN TO EXCEPTION"); TimeStop ts; bool disasfocus = disas.HasFocus(); bool locked = false; bool frestored = false; invalidpage.Clear(); mempage.Clear(); int opn = 0; for(;;) { if(terminated) { if(locked) Unlock(); return false; } opn++; DR_LOG("WaitForDebugEvent"); if(WaitForDebugEvent(&event, 0)) { DR_LOG("WaitForDebugEvent ended"); debug_threadid = event.dwThreadId; opn = 0; running = false; switch(event.dwDebugEventCode) { case EXCEPTION_DEBUG_EVENT: { DR_LOG("EXCEPTION_DEBUG_EVENT"); LLOG("Exception: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionCode) << " at: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionAddress) << " first: " << event.u.Exception.dwFirstChance); SaveForeground(); const EXCEPTION_RECORD& x = event.u.Exception.ExceptionRecord; if(findarg(x.ExceptionCode, EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP, STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP) < 0) { LLOG("Non-debug EXCEPTION"); if(event.u.Exception.dwFirstChance) { LLOG("First chance " << FormatIntHex(x.ExceptionCode)); break; } String desc = Format("Exception: [* %lX] at [* %16llX]&", (int64)x.ExceptionCode, (int64)x.ExceptionAddress); for(int i = 0; i < __countof(ex_desc); i++) if(ex_desc[i].code == x.ExceptionCode) desc << "[* " << DeQtf(ex_desc[i].text) << "]&"; if(x.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { desc << (x.ExceptionInformation[0] ? "[*@3 writing]" : "[*@4 reading]"); desc << Format(" at [* %08llX]", (int64)x.ExceptionInformation[1]); } ToForeground(); PromptOK(desc); } #ifdef CPU_64 if(!win64 && x.ExceptionCode == EXCEPTION_BREAKPOINT && !break_running) // Ignore x64 breakpoint in wow64 break; #endif if(break_running) debug_threadid = mainThreadId; break_running = false; ToForeground(); if(disasfocus) disas.SetFocus(); if(locked) Unlock(); if(refreshmodules) LoadModuleInfo(); LLOG("event.dwThreadId = " << event.dwThreadId); bool isbreakpoint = findarg(x.ExceptionCode, EXCEPTION_BREAKPOINT, STATUS_WX86_BREAKPOINT) >= 0; for(int i = 0; i < threads.GetCount(); i++) { Thread& t = threads[i]; (Context&)t = ReadContext(threads[i].hThread); if(event.dwThreadId == threads.GetKey(i)) { LLOG("Setting current context"); if(isbreakpoint #ifdef CPU_64 && bp_set.Find((win64 ? t.context64.Rip : t.context32.Eip) - 1) >= 0 #else && bp_set.Find(t.context32.Eip - 1) >= 0 #endif ) // We have stopped at breakpoint, need to move address back #ifdef CPU_64 if(win64) t.context64.Rip--; else #endif t.context32.Eip--; context = t; } } RemoveBp(); return true; } case CREATE_THREAD_DEBUG_EVENT: DR_LOG("CREATE_THREAD_DEBUG_EVENT"); LLOG("Create thread: " << event.dwThreadId); AddThread(event.dwThreadId, event.u.CreateThread.hThread); break; case EXIT_THREAD_DEBUG_EVENT: DR_LOG("EXIT_THREAD_DEBUG_EVENT"); LLOG("Exit thread: " << event.dwThreadId); RemoveThread(event.dwThreadId); break; case CREATE_PROCESS_DEBUG_EVENT: DR_LOG("CREATE_PROCESS_DEBUG_EVENT"); LLOG("Create process: " << event.dwProcessId); processid = event.dwProcessId; AddThread(event.dwThreadId, event.u.CreateProcessInfo.hThread); CloseHandle(event.u.CreateProcessInfo.hFile); CloseHandle(event.u.CreateProcessInfo.hProcess); break; case EXIT_PROCESS_DEBUG_EVENT: DR_LOG("EXIT_PROCESS_DEBUG_EVENT"); LLOG("Exit process: " << event.dwProcessId); if(locked) Unlock(); terminated = true; return false; case LOAD_DLL_DEBUG_EVENT: { DR_LOG("LOAD_DLL_DEBUG_EVENT"); LLOG("Load dll: " << event.u.LoadDll.lpBaseOfDll); CloseHandle(event.u.LoadDll.hFile); refreshmodules = true; break; } case UNLOAD_DLL_DEBUG_EVENT: DR_LOG("UNLOAD_DLL_DEBUG_EVENT"); LLOG("UnLoad dll: " << event.u.UnloadDll.lpBaseOfDll); refreshmodules = true; break; case RIP_EVENT: DR_LOG("RIP_EVENT"); LLOG("RIP!"); Exclamation("Process being debugged died unexpectedly!"); terminated = true; if(locked) Unlock(); return false; } DR_LOG("ContinueDebugEvent"); ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_EXCEPTION_NOT_HANDLED); running = true; } if(ts.Elapsed() > 200) { DR_LOG("ts.Elpsed() > 200"); if(!lock) { Lock(); locked = true; } if(!frestored) { RestoreForeground(); frestored = true; } } if(lock) { DR_LOG("GuiSleep"); GuiSleep(opn < 1000 ? 0 : 100); Ctrl::ProcessEvents(); } else { DR_LOG("Sleep"); Sleep(opn < 1000 ? 0 : 100); } } }
void ShowExc(const Exc& exc) { BeepExclamation(); Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(), DeQtf(exc), t_("OK")); }