Пример #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());
	}
Пример #2
0
String GetSegmentFile(int segment_id)
{
	for(int i = 0; i < sPPfile.GetCount(); i++) {
		const Array<PPItem>& m = sPPfile[i].item;
		for(int j = 0; j < m.GetCount(); j++)
			if(m[j].type == PP_DEFINES && m[j].segment_id == segment_id)
				return sPPfile.GetKey(i);
	}
	return "<not found>";
}
Пример #3
0
void sPut(String& qtf, ArrayMap<String, FileStat>& pfs, ArrayMap<String, FileStat>& all) {
	FileStat pall;
	for(int i = 0; i < pfs.GetCount(); i++) {
		FileStat& fs = pfs[i];
		sPut(pfs.GetKey(i), qtf, fs);
		pall.Add(fs);
		all.GetAdd(pfs.GetKey(i)).Add(fs);
	}
	sPut("All files", qtf, pall);
	qtf << "}}&&";
}
Пример #4
0
Speller *sGetSpeller(int lang)
{
	static ArrayMap<int, Speller> speller;
	int q = speller.Find(lang);
	if(q < 0) {
		String pp = spell_path;
		DoSpellerPath(pp, GetExeDirFile("scd"));		
		DoSpellerPath(pp, ConfigFile("scd"));
		pp << spell_path << ';' << getenv("LIB") << ';' << getenv("PATH") << ';';
		String path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".udc", pp);
		if(IsNull(path))
			path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".scd", pp);
		if(IsNull(path))
			return NULL;
		FileIn in(path);
		if(!in)
			return NULL;
		q = speller.GetCount();
		Speller& f = speller.Add(lang);
		FileIn user(sUserFile(lang));
		while(!user.IsEof()) {
			String s = user.GetLine();
			if(!s.IsEmpty())
				f.user.Add(FromUtf8(s));
		}
		if(in.Get() != 255)
			f.SetOld(LoadFile(path));
		else {
			f.path = path;
			int n = in.GetL();
			LLOG("Found scd file " << path << " blocks " << n);
			if(n > 0 && n < 100000) {
				for(int i = 0; i < n; i++) {
					SpellBlock& b = f.block.Add();
					b.first = in.Get(in.Get());
					b.ctrl_len = in.GetL();
					b.text_len = in.GetL();
				}
				if(in.IsEof())
					f.block.Clear();
				else {
					int off = (int)in.GetPos();
					for(int i = 0; i < n; i++) {
						SpellBlock& b = f.block[i];
						b.offset = off;
						off += b.ctrl_len + b.text_len;
					}
				}
			}
		}
	}
	return &speller[q];
}
Пример #5
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;
		}
	}
}
Пример #6
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);
}
Пример #7
0
void DockWindow::SerializeLayout(Stream &s, bool withsavedlayouts)
{
	StopHighlight(false);
	int cnt = 0;

	s.Magic();

	// Groups
	ArrayMap<String, Vector<int> > groups;
	if (s.IsStoring())
		for (int i = 0; i < dockers.GetCount(); i++) {
			String g = dockers[i]->GetGroup();
			if (!g.IsEmpty()) {
				int ix = groups.Find(g);
				if (ix < 0) {
					groups.Add(dockers[i]->GetGroup(), Vector<int>());
					ix = groups.GetCount() - 1;
				}
				groups[ix].Add(i);
			}
		}
	s % groups;
	if (s.IsLoading()) {
		ClearLayout();

		for (int i = 0; i < dockers.GetCount(); i++)
			dockers[i]->SetGroup(Null);
		for (int i = 0; i < groups.GetCount(); i++) {
			Vector<int> &v = groups[i];
			const String &g = groups.GetKey(i);
			for (int j = 0; j < v.GetCount(); j++) {
				int ix = v[j];
				if (ix >= 0 && ix < dockers.GetCount())
					dockers[ix]->SetGroup(g);
			}
		}
	}

	if (s.IsStoring()) {
		// Write docked
		for (int i = 0; i < 4; i++) {
			DockPane &pane = dockpane[i];
			int fsz = dockframe[i].IsShown() ? dockframe[i].GetSize() : 0;

			s / fsz % pane;
			DockCont *dc = dynamic_cast<DockCont *>(pane.GetFirstChild());
			for (int j = 0; dc && j < pane.GetCount(); j++) {
				s % *dc;
				dc = dynamic_cast<DockCont *>(dc->GetNext());
			}
		}
		cnt = 0;
		// Count Floating
		for (int i = 0; i < conts.GetCount(); i++)
			if (conts[i].IsFloating()) cnt++;
		// Write Floating
		s / cnt;
		for (int i = 0; i < conts.GetCount(); i++) {
			if (conts[i].IsFloating()) {
				conts[i].Serialize(s);
				conts[i].SerializePlacement(s, false);
			}
		}
		// Write Autohidden
		for (int i = 0; i < 4; i++) {
			cnt = hideframe[i].GetCount();
			s / cnt;
			for (int j = 0; j < hideframe[i].GetCount(); j++) {
				int ix = FindDocker(&hideframe[i].GetCtrl(j)->Get(0));
				if (ix >= 0)
					s / ix;
			}
		}
	}
	else {
		// Read docked
		for (int i = 0; i < 4; i++) {
			DockPane &pane = dockpane[i];
			dockframe[i].Hide();
			int fsz;
			s / fsz % pane;

			for (int j = 0; j < pane.GetCount(); j++) {
				DockCont *dc = CreateContainer();
				s % *dc;
				dc->StateDocked(*this);
				pane << *dc;
			}
			if (fsz && pane.GetCount()) {
				dockframe[i].SetSize(fsz);
				dockframe[i].Show();
			}
			else
				dockframe[i].SetSize(0);
		}
		// Read floating
		s / cnt;
		for (int i = 0; i < cnt; i++) {
			DockCont *dc = CreateContainer();
			dc->Serialize(s);
			FloatContainer(*dc);
			dc->SerializePlacement(s, false);
		}
		// Read Autohidden
		for (int i = 0; i < 4; i++) {
			s / cnt;
			for (int j = 0; j < cnt; j++) {
				int ix;
				s / ix;
				if (ix >= 0 && ix < dockers.GetCount())
					AutoHide(i, *dockers[ix]);
			}
		}
		// Clear empty containers
		for (int i = conts.GetCount()-1; i >= 0; i--) {
			if (!conts.GetCount()) CloseContainer(conts[i]);
		}
		RefreshLayout();
	}
	bool haslay = withsavedlayouts;
	s % haslay;
	if (withsavedlayouts && (s.IsStoring() || haslay))
		s % layouts;

	s.Magic();
}