Ejemplo n.º 1
0
void SerializePPFiles(Stream& s)
{
	s % sAllMacros % sPPfile % sPPserial;
	if(s.IsLoading())
		LoadPPConfig();

#if 0
	if(s.IsLoading()) { _DBG_
		DDUMP(sPPfile.GetCount());
		DDUMP(sAllMacros.GetCount());
		DDUMP(sPPserial);
		
		Index<int> psegment;
		for(int i = 0; i < sPPfile.GetCount(); i++) {
			const PPFile& p = sPPfile[i];
			for(int j = 0; j < p.item.GetCount(); j++)
				psegment.FindAdd(p.item[j].segment_id);
		}
		DDUMP(psegment.GetCount());
			
		int n = 0; _DBG_
		Index<int> msegment;
		for(int i = 0; i < sAllMacros.GetCount(); i++) { _DBG_
			if(sAllMacros.IsUnlinked(i))
				n++;
			else
				msegment.FindAdd(sAllMacros[i].segment_id);
		}
		DLOG("UNLINKED " << n);
		DLOG("Segments " << msegment.GetCount());
	}
Ejemplo n.º 2
0
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
                        const VectorMap<String, ClipData>& data)
{
	LLOG("------------------------------");
	LLOG("DoDragAndDrop " << fmts);
	TopWindow *w = GetTopWindow();
	if(!w || !w->top)
		return DND_NONE;
	int gdk_actions = 0;
	if(actions & DND_MOVE)
		gdk_actions |= GDK_ACTION_MOVE;
	if(actions & DND_COPY)
		gdk_actions |= GDK_ACTION_COPY;
	GtkTargetList *list = CreateTargetList(data);
	dnd_fmts.Clear();
	for(int i = 0; i < data.GetCount(); i++)
		AddFmt(list, data.GetKey(i), i);
	Vector<String> f = Split(fmts, ';');
	for(int i = 0; i < f.GetCount(); i++) {
		AddFmt(list, f[i], data.GetCount() + i);
		dnd_fmts.Add(f[i]);
	}
	dnd_source_data = &data;
	dnd_result = DND_NONE;
	dnd_source = this;
	if(IsNull(sample))
		dnd_icon = Null;
	else {
		Size sz = sample.GetSize();
		if(sz.cx > 128)
			sz.cx = 128;
		if(sz.cy > 128)
			sz.cy = 128;
		sz += 2;
		ImageDraw iw(sz);
		iw.DrawRect(sz, White());
		DrawFrame(iw, sz, Black());
		iw.DrawImage(1, 1, sz.cx, sz.cy, sample);
		ImageBuffer b(128, 128);
		dnd_icon = iw;
	}
	gtk_drag_begin(w->top->window, list, GdkDragAction(gdk_actions),
	               GetMouseLeft() ? 1 : GetMouseMiddle() ? 2 : 3, CurrentEvent.event);
	while(dnd_source && GetTopCtrls().GetCount())
		ProcessEvents();
	dnd_source_data = NULL;
	gtk_target_list_unref (list);
	LLOG("-------- DoDragAndDrop");
	return dnd_result;
}
Ejemplo n.º 3
0
void OutMode::CmdOptions()
{
	const Workspace& wspc = ide.IdeWorkspace();
	int pi = wspc.GetCount() > 0 ? 0 : -1;
	if (pi < 0) {
		PromptOK("No main package");
		return;
	}
	VectorMap<String, String> bm = ide.GetMethodVars(~method);
	if (bm.GetCount() == 0) {
		PromptOK("Invalid build method");
		return;
	}
	One<Host> host = ide.CreateHost(false);
	One<Builder> b = ide.CreateBuilder(~host);
	const String& p = wspc[pi];
	String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true));
	if (output.Right(1) == ".")
		output = output.Left(output.GetCount() - 1);
	const ModePane& pane = ~mode == 0 ? debug : release;
	int blitzpackage = pane.package.Get(0, 2);
	bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz
		&& (IsNull(blitzpackage) ? true : blitzpackage);
	CmdBuildOptionsWindow window(p, ~method, ~config, output,
		~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild);
	LoadFromGlobal(window, "CmdBuildOptionsWindow");
	window.GenerateCmd();
	window.Run();
	StoreToGlobal(window, "CmdBuildOptionsWindow");
}
Ejemplo n.º 4
0
int  GetClipboardFormatCode(const char *format_id)
{
	GuiLock ___;
	int x = (int)(intptr_t)format_id;
	if(x >= 0 && x < 65535)
		return x;
	String fmt = format_id;
	if(fmt == "text")
		return CF_TEXT;
	if(fmt == "wtext")
		return CF_UNICODETEXT;
	if(fmt == "dib")
		return CF_DIB;
	if(fmt == "files")
		return CF_HDROP;
	static StaticMutex m;
	Mutex::Lock __(m);
	static VectorMap<String, int> format_map;
	int f = format_map.Find(format_id);
	if(f < 0) {
		f = format_map.GetCount();
		format_map.Add(format_id,
#ifdef PLATFORM_WINCE
			::RegisterClipboardFormat(ToSystemCharset(format_id))
#else
			::RegisterClipboardFormat(format_id)
#endif
		);
	}
	return format_map[f];
}
Ejemplo n.º 5
0
void HelpWin::SyncDocTree() {
	ClearTree();
	VectorMap<String, Vector<String> > map;
	String pdir = GetFileFolder(GetExeFilePath()) + "/";
	for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next())
		if(ff.IsFolder()) {
			String group = GetFileTitle(ff.GetName());
			String dir = AppendFileName(pdir, ff.GetName());
			for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) {
				if(ft.IsFile()) {
					if(String(ft.GetName()).Mid(0, 1) != "_") map.GetAdd(group).Add(GetFileTitle(ft.GetName()));
				}
			}
		}
	for(int i = 0; i < map.GetCount(); i++) {
		Vector<String>& group = map[i];
		int pid;
		pid = AddTree(0, commonImg::group_1_16(), "topic://" + GetExeTitle() + "/" + map.GetKey(i), map.GetKey(i));
		for(int j = 0; j < group.GetCount(); j++) {
			String t = "topic://" + GetExeTitle() + "/" + map.GetKey(i) + "/" + group[j];
			String u = GetTopicTitle(GetFileFolder(GetExeFilePath()) + "/" + map.GetKey(i) + ".tpp/" + group[j] + ".tpp");
			AddTree(pid, commonImg::commonImg::commonImg::topic_1_16(), t, u);
		}
	}
	FinishTree();
}
Ejemplo n.º 6
0
bool SaveVarFile(const char *filename, const VectorMap<String, String>& var)
{
	FileOut out(filename);
	for(int i = 0; i < var.GetCount(); i++)
		out << var.GetKey(i) << " = " << AsCString(var[i]) << ";\n";
	out.Close();
	return !out.IsError();
}
Ejemplo n.º 7
0
void sOptimizedTextRenderer::Flush()
{
	if(cache.GetCount() == 0)
		return;
	LTIMING("Flush");
	for(int i = 0; i < cache.GetCount(); i++) {
		Chrs& c = cache[i];
		if(c.x.GetCount()) {
			Tuple2<Font, Color> fc = cache.GetKey(i);
			int x = c.x[0];
			for(int i = 0; i < c.x.GetCount() - 1; i++)
				c.x[i] = c.x[i + 1] - c.x[i];
			c.x.Top() = 0;
			w.DrawText(x, y, c.text, fc.a, fc.b, c.x);
		}
	}
	cache.Clear();
}
Ejemplo n.º 8
0
void   Data::Dump()
{
	DUMP(sz);
	DUMP(text);
	LOG("lang: " << LNGAsText(lang));
	DUMPC(vector);
	LOG("score: ");
	for(int i = 0; i < score.GetCount(); i++)
		LOG("   " << score.GetKey(i) << " ..... " << score[i]);
	LOG("map: ");
	for(int i = 0; i < map.GetCount(); i++)
		LOG("   " << map.GetKey(i) << " ..... " << map[i]);
	LOG("sizemap: ");
	for(int i = 0; i < sizemap.GetCount(); i++)
		LOG("   " << sizemap.GetKey(i) << " ..... " << sizemap[i]);
	DUMP(number);
	DUMP(option);
}
Ejemplo n.º 9
0
static VectorMap<String, String>& sIniKeys()
{
	static VectorMap<String, String> key;
	static int version;
	if(version != ini_version__) {
		version = ini_version__;
		key = LoadIniFile(GetIniFile());
	#ifdef PLATFORM_WIN32
		if(key.GetCount() == 0)
			key = LoadIniFile(~GetExeDirFile("q.ini"));
		if(key.GetCount() == 0)
			key = LoadIniFile("c:\\q.ini");
	#endif
	#ifdef PLATFORM_POSIX
		if(key.GetCount() == 0)
			key = LoadIniFile(GetHomeDirFile("q.ini"));
	#endif
	}
	return key;
}
Ejemplo n.º 10
0
void ForceSchemaUpdate(SqlId table, Fields nf, Fields of, SqlId key, const Value& keyval, Sql& cursor)
{
    String tbl;
    VectorMap<Id, Value> nmap = GetValueMap(nf, &tbl);
    VectorMap<Id, Value> omap = GetValueMap(of);
    SqlUpdate update(SqlId(SchemaTableName(Nvl(~table, tbl))));
    for(int i = 0; i < nmap.GetCount(); i++)
        if(nmap[i] != omap.Get(nmap.GetKey(i), Value()))
            update(SqlId(nmap.GetKey(i)), nmap[i]);
    if(update)
        update.Where(key == keyval).Force(cursor);
}
Ejemplo n.º 11
0
void SaveImages(const char *dir, const char *prefix, const VectorMap<String, Image>& img)
{
	for(int i = 0; i < img.GetCount(); i++) {
		String fn;
		if(prefix)
			fn << prefix;
		Point p1 = img[i].GetHotSpot();
		Point p2 = img[i].Get2ndSpot();
		fn << img.GetKey(i) << '.' << p1.x << '.' << p1.y << '.' << p2.x << '.' << p2.y << ".png";
		PNGEncoder().SaveFile(AppendFileName(dir, fn), img[i]);
	}
}
Ejemplo n.º 12
0
ValueMap Result::LoadPage(const CommitFilter& f) {
	SQLR * Select(SqlAll(RESULT),UID,CMT,BRANCH,CLIENT_ID)
	       .From(
	           Select(UID.As("FILTER"))
	           .From(COMMITS)
	           .Where(f)
	           .OrderBy(Descending(DT))
	           .Limit(f.offset, f.limit)
	           .AsTable("FILTER_TABLE")
	       )
	       .InnerJoin(COMMITS).On(SqlId("FILTER")==UID)
	       .LeftJoin(RESULT).On(CMT_UID == UID)
	       .LeftJoin(CLIENT).On(ID == CLIENT_ID)
	       .OrderBy(Descending(DT));
	VectorMap<Tuple2<String, int>,ValueMap> rows;
	SortedIndex<int> clients;
	VectorMap<String, ValueMap> commits;
	ValueArray v_clients;
	ValueMap v_commits;
	ValueMap vm;
	while (SQLR.Fetch(vm)){
		SetComputedAttributes(vm);
		String uid = vm["UID"];
		int cid = vm["CLIENT_ID"];
		rows.Add(MakeTuple(uid, cid), vm);
		clients.FindAdd(cid);
		ValueMap& commit = commits.GetAdd(uid);
		commit.Set("CMT", vm["CMT"]);
		commit.Set("BRANCH", vm["BRANCH"]);
	}
	ValueMap results;
	for(int i = 0; i<commits.GetCount() ; ++i){
		v_commits.Add(commits.GetKey(i), commits[i]);
		vm.Clear();
		for(int j = 0; j < clients.GetCount(); ++j){
			if(!IsNull(clients[j]))
				vm.Add(clients[j], rows.GetAdd(MakeTuple(commits.GetKey(i), clients[j])));
		}
		results.Add(commits.GetKey(i), vm);
	}
	for(int i = (!clients.IsEmpty() && IsNull(clients[0]))?1:0; i < clients.GetCount(); i++)
		v_clients.Add(clients[i]);
	ValueMap res;
	res.Set("RESULTS", results);
	res.Set("COMMITS", v_commits);
	res.Set("CLIENTS", v_clients);
	res.Set("ALLCLIENTS", Client::LoadAll());
	return res;
}
Ejemplo n.º 13
0
void SweepPPFiles(const Index<String>& keep)
{
	Index<int> pp_segment_id;
	int unlinked_count = 0;
	for(int i = 0; i < sPPfile.GetCount(); i++)
		if(sPPfile.IsUnlinked(i))
			unlinked_count++;
		else
			if(keep.Find(sPPfile.GetKey(i)) < 0) {
				unlinked_count++;
				sPPfile.Unlink(i);
			}
			else {
				const PPFile& p = sPPfile[i];
				for(int j = 0; j < p.item.GetCount(); j++)
					pp_segment_id.FindAdd(p.item[j].segment_id);
			}
	if(unlinked_count > sPPfile.GetCount() / 2) {
		CleanPP();
		return;
	}
	unlinked_count = 0;
	for(int i = 0; i < sAllMacros.GetCount(); i++) {
		if(sAllMacros.IsUnlinked(i))
			unlinked_count++;
		else
		if(sAllMacros[i].segment_id && pp_segment_id.Find(sAllMacros[i].segment_id) < 0) {
			sAllMacros.Unlink(i);
			unlinked_count++;
		}
		if(unlinked_count > sAllMacros.GetCount() / 2) {
			CleanPP();
			return;
		}
	}
}
Ejemplo n.º 14
0
void Pdb::AddThis(const VectorMap<String, Val>& m, adr_t address, const VectorMap<String, Value>& prev)
{
	for(int i = 0; i < m.GetCount() && self.GetCount() < 2000; i++) {
		Val mv = m[i];
		mv.address += address;
		Visual vis;
		try {
			vis = Visualise(mv);
		}
		catch(CParser::Error e) {
			vis.Cat(e, SColorDisabled);
		}
		Vis(self, m.GetKey(i), prev, vis);
	}
}
Ejemplo n.º 15
0
bool MakeBuild::Build()
{
	VectorMap<String, String> bm = GetMethodVars(method);
	if(bm.GetCount() == 0) {
		PutConsole("Invalid build method");
		ConsoleShow();
		return false;
	}
	One<Host> host = CreateHost(false);
	One<Builder> builder = CreateBuilder(~host);
	if(!builder)
		return false;
	Index<String> p = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam,
	                                *host, *builder);
	Workspace wspc;
	wspc.Scan(GetMain(), p.GetKeys());
	return Build(wspc, mainconfigparam, Null);
}
Ejemplo n.º 16
0
void LoadPPConfig()
{
	for(int i = 0; i < sAllMacros.GetCount(); i++)
		if(sAllMacros[i].segment_id == 0 && !sAllMacros.IsUnlinked(i))
			sAllMacros.Unlink(i);

	s_namespace_macro.Clear();
	s_namespace_end_macro.Clear();

	StringStream ss(sDefs);
	int linei = 0;
	while(!ss.IsEof()) {
		String l = ss.GetLine();
		try {
			CParser p(l);
			if(p.Char('#')) {
				if(p.Id("define")) {
					CppMacro def;
					String   id = def.Define(p.GetPtr());
					if(id.GetCount()) {
						PPMacro m;
						m.segment_id = 0;
						m.line = linei;
						m.macro = def;
						sAllMacros.Put(id, m);
						if(findarg(TrimBoth(def.body), "}", "};") >= 0)
							s_namespace_end_macro.Add(id);
						try {
							CParser p(def.body);
							if(p.Id("namespace") && p.IsId()) {
								String n = p.ReadId();
								if(p.Char('{') && p.IsEof())
									s_namespace_macro.Add(id, n);
							}
						}
						catch(CParser::Error) {}
					}
				}
			}
		}
		catch(CParser::Error) {}
		linei++;
	}
}
Ejemplo n.º 17
0
void MakeMap(VectorMap<String, int>& map, const XmlNode& n, const String& path, int& tag_count, int& other_count)
{
	if(map.GetCount() > 1000)
		return;
	for(int i = 0; i < n.GetCount(); i++) {
		const Tuple2<int, String> *m = FindTuple(mm, __countof(mm), n[i].GetType());
		if(m) {
			count.GetAdd(m->b, 0)++;
			count.GetAdd(String(m->b) + ".len", 0) += n[i].GetText().GetCount();
		}
		if(n[i].IsTag()) {
			String np = path + "/" + n[i].GetTag();
			map.GetAdd(np, 0)++;
			MakeMap(map, n[i], np, tag_count, other_count);
			count.GetAdd("attr", 0) += n[i].GetAttrCount();
		}
		else
			map.GetAdd(path + ':' + (m ? m->b : "?"), 0)++;
	}
}
Ejemplo n.º 18
0
void IdeIconDes::Save()
{
	if(format == 1) {
		for(int i = 0; i < GetCount(); i++) {
			Image m = GetImage(i);
			Point p = m.Get2ndSpot();
			if(m.GetKind() == IMAGE_ALPHA || p.x || p.y) {
				if(PromptYesNo("Legacy file format does not support images "
				               "with full alpha channel or 2nd hotspot - "
				               "the information would be lost.&"
				               "Do you wish to convert the file to the new format?")) {
					format = 0;
				}
				break;
			}
		}
	}
	StoreToGlobal(*this, "icondes-ctrl");
	Array<ImlImage> m;
	VectorMap<Size, Image> exp;
	String folder = GetFileFolder(filename);
	for(int i = 0; i < GetCount(); i++) {
		ImlImage& c = m.Add();
		c.name = GetName(i);
		c.image = GetImage(i);
		c.exp = GetExport(i);
		if(c.exp) {
			Size sz = c.image.GetSize();
			exp.GetAdd(sz) = c.image;
			PNGEncoder png;
			SaveChangedFile(AppendFileName(folder, String().Cat() << "icon" << sz.cx << 'x' << sz.cy << ".png"),
			                png.SaveString(c.image));
		}
	}
	String d = SaveIml(m, format);
	if(!SaveChangedFileFinish(filename, d))
		return;
	filetime = FileGetTime(filename);
	if(exp.GetCount())
		SaveChangedFile(AppendFileName(folder, "icon.ico"), WriteIcon(exp.GetValues()));
}
Ejemplo n.º 19
0
PackageInfo GetPackageInfo(const String& name)
{
    String path = PackagePath(name);
    Time tm = FileGetTime(path);
    int q = sPi.Find(name);
    if(q >= 0) {
        if(path == sPi[q].path && tm == sPi[q].stamp)
            return sPi[q];
    }
    else {
        q = sPi.GetCount();
        sPi.Add(name);
    }
    PackageInfo& pi = sPi[q];
    pi.path = path;
    pi.stamp = tm;
    Package p;
    p.Load(path);
    pi.ink = p.ink;
    pi.italic = p.italic;
    pi.bold = p.bold;
    return pi;
}
Ejemplo n.º 20
0
bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount,
	String mainparam, String outfile, Vector<String>& linkfile, String& linkopt, bool link)
{
	String package = wspc[pkindex];
	String mainpackage = wspc[0];
	const Package& pkg = wspc.package[pkindex];
	VectorMap<String, String> bm = GetMethodVars(method);
	if(bm.GetCount() == 0) {
		PutConsole("Invalid build method");
		ConsoleShow();
		return false;
	}
	One<Host> host = CreateHost(false);
	if(!IsNull(onefile)) {
		OneFileHost *h = new OneFileHost;
		h->host = host;
		h->onefile = onefile;
		host = h;
	}
	One<Builder> b = CreateBuilder(~host);
	if(!b)
		return false;
	b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b);
	const TargetMode& m = targetmode == 0 ? debug : release;
	b->version = m.version;
	b->method = method;
	b->outdir = OutDir(b->config, package, bm);
	host->RealizeDir(b->outdir);
	String mainfn = Null;
	Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, &mainfn);
	HdependClearDependencies();
	for(int i = 0; i < pkg.GetCount(); i++) {
		const Array<OptItem>& f = pkg[i].depends;
		for(int j = 0; j < f.GetCount(); j++)
			if(MatchWhen(f[j].when, mcfg.GetKeys()))
				HdependAddDependency(SourcePath(package, pkg[i]), SourcePath(package, f[j].text));
	}
	String tout = OutDir(mcfg, mainpackage, bm, use_target);
	host->RealizeDir(tout);
	if(IsNull(mainfn))
		mainfn = GetFileTitle(mainpackage) + b->GetTargetExt();
	if(!IsNull(outfile))
		target = NormalizePath(outfile, tout);
	else {
		if(m.target_override && !IsNull(m.target) && IsFolder(m.target))
			target = host->NormalizePath(AppendFileName(m.target, mainfn));
		else
		if(m.target_override && (IsFullPath(m.target) || *m.target == '/' || *m.target == '\\'))
			target = m.target;
		else
		if(m.target_override && !IsNull(m.target))
			target = host->NormalizePath(AppendFileName(tout, m.target));
		else
		if(IsFullPath(mainfn))
			target = mainfn;
		else
			target = host->NormalizePath(AppendFileName(tout, mainfn));
	}
	b->target = target;
	b->mainpackage = mainpackage;
	if(IsNull(onefile)) {
		String out;
		out << "----- " << package << " ( " << Join(b->config.GetKeys(), " ") << " )";
		if(pkcount > 1)
			out << " (" << (pknumber + 1) << " / " << pkcount << ')';
		PutConsole(out);
	}
	else
		b->config.FindAdd("NOLIB");
	bool ok = b->BuildPackage(package, linkfile, linkopt,
		                      GetAllUses(wspc, pkindex),
		                      GetAllLibraries(wspc, pkindex, bm, mainparam, *host, *b),
		                      targetmode - 1);
	Vector<String> errors = PickErrors();
	host->DeleteFile(errors);
	if(!ok || !errors.IsEmpty())
		return false;
	if(link) {
		ok = b->Link(linkfile, linkopt, GetTargetMode().createmap);
		errors = PickErrors();
		host->DeleteFile(errors);
		if(!ok || !errors.IsEmpty())
			return false;
	}
	return true;
}
Ejemplo n.º 21
0
void SaveProp(FileOut& out, VectorMap<String, String>& prop, const char *tab)
{
	for(int i = 0; i < prop.GetCount(); i++)
		out << tab << FillRight(prop.GetKey(i), 8) << " " << prop[i] << "\r\n";
	out << ";\r\n\r\n";
}