Example #1
0
void Ide::Preprocess(bool asmout) {
    if(editfile.IsEmpty())
        return;
    int pi = GetPackageIndex();
    if(pi < 0) return;
    SwitchHeader();
    String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp");
    DeleteFile(pfn);
    const Workspace& wspc = IdeWorkspace();
    if(pi >= wspc.GetCount())
        return;
    One<Host> host = CreateHost(true);
    One<Builder> b = CreateBuilder(~host);
    Vector<String> linkfile;
    String linkopt;
    b->config = PackageConfig(wspc, pi, GetMethodVars(method), mainconfigparam, *host, *b);
    console.Clear();
    PutConsole((asmout ? "Compiling " : "Preprocessing ") + editfile);
    b->Preprocess(wspc[pi], editfile, pfn, asmout);
    HideBottom();
    if(FileExists(pfn)) {
        EditFile(pfn);
        if(!editor.IsReadOnly())
            ToggleReadOnly();
    }
}
Example #2
0
void Ide::ToggleBottom(int i)
{
	if(i == btabs.GetCursor() && IsBottomShown())
		HideBottom();
	else
		SetBottom(i);
}
Example #3
0
void Ide::IdeRemoveBottom(Ctrl& ctrl)
{
	ctrl.Remove();
	bottomctrl = NULL;
	BTabs();
	HideBottom();
}
Example #4
0
void Ide::SetMain(const String& package)
{
	FlushFile();
	SaveWorkspace();
	transferfilecache.Clear();
	main = package;
	export_dir = GetHomeDirFile(main);
	mainconfigname.Clear();
	mainconfigparam.Clear();
	ScanWorkspace();
	LoadFromFile(THISBACK(SerializeWorkspace), WorkspaceFile());
	editorsplit.Zoom(0);
	UpdateFormat();
	String e = editfile;
	editfile.Clear();
	MakeTitle();
	MakeIcon();
	SyncMainConfigList();
	AdjustMainConfig();
	SyncBuildMode();
	SetHdependDirs();
	SetBar();
	HideBottom();
	SyncUsc();
	NewCodeBase();
	if(IsNull(e))
		e = GetFirstFile();
	EditFile(e);
}
Example #5
0
void Ide::BuildAndDebug(bool runto)
{
	VectorMap<String, String> bm = GetMethodVars(method);
	String builder = bm.Get("BUILDER", "");
	if(!Build())
		return;
	if(!FileExists(target))
		return;
	if(designer)
		EditAsText();
	One<Host> host = CreateHostRunDir();
	host->ChDir(Nvl(rundir, GetFileFolder(target)));
	HideBottom();
	editor.Disable();
#ifdef COMPILER_MSC
	if(builder == "GCC")
		if(gdbSelector)
			debugger = Gdb_MI2Create(host, target, runarg);
		else
			debugger = GdbCreate(host, target, runarg);
	else
		debugger = PdbCreate(host, target, runarg);
#else
	if(gdbSelector)
		debugger = Gdb_MI2Create(host, target, runarg);
	else
		debugger = GdbCreate(host, target, runarg);
#endif
	if(!debugger) return;
	debuglock = 0;
	const Workspace& wspc = IdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pk = wspc.GetPackage(i);
		String n = wspc[i];
		for(int i = 0; i < pk.file.GetCount(); i++) {
			String file = SourcePath(n, pk.file[i]);
			LineInfo& ln = Filedata(file).lineinfo;
			for(int i = 0; i < ln.GetCount(); i++) {
				LineInfoRecord& lr = ln[i];
				if(!lr.breakpoint.IsEmpty())
					if(!debugger->SetBreakpoint(file, lr.lineno, lr.breakpoint)) {
						lr.breakpoint = "\xe";
						if(PathIsEqual(file, editfile))
							editor.SetBreakpoint(lr.lineno, "\xe");
					}
			}
		}
	}
	SetBar();
	editor.Enable();
	if(runto) {
		if(!debugger->RunTo())
			IdeEndDebug();
	}
	else
		debugger->Run();
}
Example #6
0
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);
				}
			}
		}
	}
}
Example #7
0
void Ide::CleanUppOut()
{
    String out = GetVar("OUTPUT");
    if(!PromptYesNo(NFormat("Erase the whole output directory [* \1%s\1]?", out)))
        return;
    console.Clear();
    PutConsole("UPPOUT cleanup...");
    DeleteFolderDeep(out);
    PutConsole("(done)");
    HideBottom();
}
Example #8
0
void Ide::SwapBottom()
{
	if(editor.Esc())
		return;
	if(editor.IsFindOpen())
		editor.FindClose();
	else
	if(!designer && !editor.HasFocusDeep())
		ActiveFocus(editor);
	else
	if(IsBottomShown())
		HideBottom();
	else {
		if(btabs.GetCursor() <= 0)
			btabs.SetCursor(1);
		SyncBottom();
	}
}
Example #9
0
void Ide::PreprocessInternal()
{
    if(editor.GetLength() >= 1000000) // Sanity...
        return;
    int l = editor.GetCurrentLine();
    PPSync(GetIncludePath());
    String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp");
    Cpp cpp;
    StringStream in(editor.Get());
    String p = NormalizeSourcePath(editfile);
    cpp.Preprocess(p, in, GetMasterFile(p));
    Upp::SaveFile(pfn, cpp.output);
    HideBottom();
    EditFile(pfn);
    EditAsText();
    if(!editor.IsReadOnly())
        ToggleReadOnly();
    editor.SetCursor(editor.GetPos(l));
}
Example #10
0
void Ide::SyncBottom()
{
	int q = btabs.GetCursor();
	if(q == BCLOSE) {
		HideBottom();
		return;
	}
	if(editor_bottom.GetZoom() >= 0)
		editor_bottom.NoZoom();
	console.Show(q == BCONSOLE);
	console2.Show(q == BCONSOLE2);
	calc.Show(q == BCALC);
	if(bottomctrl)
		bottomctrl->Show(q == BDEBUG);
	calc.LoadHlStyles(editor.StoreHlStyles());
	calc.SetFont(editorfont);
	SetBar();
	if(q == BCALC)
		ActiveFocus(calc);
}