예제 #1
0
파일: Judge.cpp 프로젝트: donwoc/icancode
int Test(FILE *p,FILE *q)
{
	int status=0;
	char a;
	char b;
	for(;;)
	{
		if((feof(p))&&(feof(q)))break;
		a=fgetc(p);
		b=fgetc(q);
		if(a==b)
		{
			status = ( status== PE ) ? PE : ACCEPT;
		}
		else if(IsTable(a) || IsTable(b))
		{
			status=PE;
			while(a=fgetc(p),IsTable(a) && (a!=EOF));
			while(b=fgetc(q),IsTable(b) && (b!=EOF));
	
		}
		else
		{
			status=WA;
			break;
		}
	
	}//END FOR

	return status;

}
예제 #2
0
RichHotPos RichTxt::GetHotPos(int x, PageY y, int tolerance, RichContext rc) const
{
	int parti = 0;
	int pos = 0;
	int ti = 0;
	if(part.GetCount()) {
		PageY nnext = GetNextPageY(parti, rc);
		while(parti < part.GetCount()) {
			PageY next = nnext;
			if(parti + 1 < part.GetCount()) {
				RichContext nrc = rc;
				nrc.py = next;
				nnext = GetNextPageY(parti + 1, nrc);
			}
			if(y < next || y.page < next.page) {
				if(IsTable(parti)) {
					RichHotPos pos = GetTable(parti).GetHotPos(x, y, tolerance, rc);
					pos.table += ti + 1;
					return pos;
				}
				else
					break;
			}
			if(IsTable(parti))
				ti += 1 + GetTable(parti).GetTableCount();
			pos += GetPartLength(parti) + 1;
			parti++;
			rc.py = next;
		}
	}

	return RichHotPos();
}
예제 #3
0
void RichTxt::Normalize()
{
	RichPara pa;
	if(GetPartCount() && IsTable(0)) {
		part.Insert(0);
		Put(0, pa, RichStyle::GetDefault());
		Invalidate();
	}
	if(GetPartCount() == 0 || IsTable(GetPartCount() - 1)) {
		Put(GetPartCount(), pa, RichStyle::GetDefault());
		Invalidate();
	}
}
예제 #4
0
RichTxt& RichTxt::GetTableUpdateText(int table, const RichStyles& style, int& pi)
{
	Invalidate();
	for(int i = 0;; i++)
		if(IsTable(i)) {
			table--;
			RichTable& tab = part[i].Get<RichTable>();
			if(table <= tab.GetTableCount()) {
				SetRefresh(i);
				if(table == 0) {
					pi = i;
					return *this;
				}
				for(int i = 0; i < tab.GetRows(); i++)
					for(int j = 0; j < tab.GetColumns(); j++)
						if(tab(i, j)) {
							RichTxt& txt = tab[i][j].text;
							if(table <= txt.GetTableCount()) {
								tab.InvalidateRefresh(i, j);
								return txt.GetTableUpdateText(table, style, pi);
							}
							table -= txt.GetTableCount();
						}
				NEVER();
			}
			else
				table -= tab.GetTableCount();
		}
	NEVER();
}
예제 #5
0
RichCaret RichTxt::GetCaret(int pos, RichContext rc) const
{
	int parti = 0;
	if(pos > GetLength())
		pos = GetLength();
	while(parti < part.GetCount()) {
		int l = GetPartLength(parti) + 1;
		if(pos < l)
			if(IsTable(parti))
				return GetTable(parti).GetCaret(pos, rc);
			else {
				const Para& p = part[parti].Get<Para>();
				int nbefore = 0;
				int nline = 0;
				if(p.keepnext && parti + 1 < part.GetCount() && part[parti + 1].Is<Para>()) {
					Sync(parti + 1, rc);
					const Para& pp = part[parti + 1].Get<Para>();
					nbefore = pp.before;
					nline = pp.linecy[0];
				}
				RichCaret tp = Get(parti, rc.styles).GetCaret(pos, rc.page, rc.py, nbefore, nline);
				tp.textpage = rc.page;
				return tp;
			}
		pos -= l;
		rc.py = GetNextPageY(parti++, rc);
	}
	return RichCaret();
}
예제 #6
0
void RichTxt::SaveFormat(Formating& r, int p1, int p2, const RichStyles& style) const
{
	Array<RichObject> dummy;
	for(int i = p1; i <= p2; i++)
		if(IsTable(i)) {
			const RichTable& tab = part[i].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j)) {
						const RichTxt& txt = tab[i][j].text;
						txt.SaveFormat(r, 0, txt.GetPartCount() - 1, style);
					}
		}
		else {
			RichPara pa = Get(i, style);
			for(int i = 0; i < pa.GetCount(); i++) {
				RichPara::Part& p = pa[i];
				int q = p.GetLength();
				p.field = Id();
				p.object = RichObject();
				WString h;
				while(q) {
					int c = min(q, 50000);
					h.Cat(c + 32);
					q -= c;
				}
				p.text = h;
			}
			r.styleid.Add(pa.format.styleid);
			r.format.Add(pa.Pack(GetStyle(style, pa.format.styleid).format, dummy));
		}
}
예제 #7
0
void RichTxt::ApplyFormat(const FormatInfo& fi, int pi, int pi2, const RichStyles& style)
{
	while(pi < pi2) {
		if(IsTable(pi)) {
			RichTable& tab = part[pi].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j)) {
						RichTxt& txt = tab[i][j].text;
						tab.InvalidateRefresh(i, j);
						txt.ApplyFormat(fi, 0, txt.GetPartCount(), style);
					}
		}
		else {
			RichPara pa;
			if(fi.paravalid & RichText::STYLE)
				pa = RichTxt::Get(pi, fi.styleid, style);
			else
				pa = Get(pi, style);
			Apply(fi, pa, style);
			Put(pi, pa, style);
		}
		pi++;
	}
}
예제 #8
0
void RichTxt::CombineFormat(FormatInfo& fi, int pi, int pi2, bool& first, const RichStyles& style) const
{
	while(pi < pi2) {
		if(IsTable(pi)) {
			const RichTable& tab = part[pi].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j)) {
						const RichTxt& txt = tab[i][j].text;
						txt.CombineFormat(fi, 0, txt.GetPartCount(), first, style);
					}
		}
		else {
			RichPara pa = Get(pi, style);
			if(first) {
				fi.Set(pa.format);
				if(pa.GetCount())
					fi.Set(pa[0].format);
				first = false;
			}
			else
				fi.Combine(pa.format);
			for(int i = first; i < pa.GetCount(); i++)
				fi.Combine(pa[i].format);
		}
		pi++;
	}
}
예제 #9
0
int RichTxt::GetVertMove(int pos, int gx, RichContext rc, int dir) const
{
	ASSERT(dir == -1 || dir == 1);
	if(GetPartCount() == 0)
		return -1;
	int pi;
	int p = pos;
	if(pos >= 0) {
		pi = FindPart(p);
		pos -= p;
	}
	else {
		pi = dir > 0 ? 0 : GetPartCount() - 1;
		p = -1;
		pos = 0;
	}
	while(pi < GetPartCount()) {
		int q = IsTable(pi) ? GetTable(pi).GetVertMove(p, gx, rc, dir)
		                    : Get(pi, rc.styles).GetVertMove(p, gx, rc.page, dir);
		if(q >= 0)
			return q + pos;
		if(dir > 0)
			pos += GetPartLength(pi) + 1;
		p = -1;
		pi += dir;
		if(pi < 0)
			break;
		if(dir < 0)
			pos -= GetPartLength(pi) + 1;
	}
	return -1;
}
예제 #10
0
파일: TextPaint.cpp 프로젝트: koz4k/soccer
void RichText::Validate()
{
	r_type = NONE;
	for(int i = 0; i < part.GetCount(); i++)
		if(IsTable(i))
			part[i].Get<RichTable>().Validate();
}
예제 #11
0
RichTable& RichTxt::GetTable0(int table, bool update)
{
	if(update)
		Invalidate();
	for(int i = 0;; i++)
		if(IsTable(i)) {
			table--;
			RichTable& tab = part[i].Get<RichTable>();
			if(table <= tab.GetTableCount()) {
				if(update)
					SetRefresh(i);
				if(table == 0)
					return tab;
				for(int i = 0; i < tab.GetRows(); i++)
					for(int j = 0; j < tab.GetColumns(); j++)
						if(tab(i, j)) {
							RichTxt& txt = tab[i][j].text;
							if(table <= txt.GetTableCount()) {
								if(update)
									tab.InvalidateRefresh(i, j);
								return txt.GetTable0(table, update);
							}
							table -= txt.GetTableCount();
						}
				NEVER();
			}
			else
				table -= tab.GetTableCount();
		}
}
예제 #12
0
void RichTxt::RestoreFormat(int pi, const Formating& info, int& ii, const RichStyles& style)
{
	Array<RichObject> dummy;
	while(ii < info.format.GetCount() && pi < GetPartCount()) {
		if(IsTable(pi)) {
			RichTable& tab = part[pi].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++) {
					if(tab(i, j)) {
						if(ii >= info.format.GetCount())
							return;
						tab.InvalidateRefresh(i, j);
						tab[i][j].text.RestoreFormat(0, info, ii, style);
					}
				}
			pi++;
		}
		else {
			RichPara pa = Get(pi, style);
			RichPara pf;
			pf.Unpack(info.format[ii], dummy, GetStyle(style, info.styleid[ii]).format);
			RichPara t;
			t.format = pf.format;
			int si = 0;
			int sp = 0;
			for(int j = 0; j < pf.GetCount(); j++) {
				const RichPara::Part& q = pf[j];
				for(int k = 0; k < q.text.GetLength(); k++) {
					int len = q.text[k] - 32;
					t.part.Add().format = q.format;
					while(len) {
						const RichPara::Part& p = pa[si];
						if(p.IsText()) {
							int l = min(len, p.GetLength() - sp);
							t.part.Top().text.Cat(p.text.Mid(sp, l));
							sp += l;
							len -= l;
							ASSERT(sp <= p.GetLength());
							if(sp >= p.GetLength()) {
								sp = 0;
								si++;
							}
						}
						else {
							ASSERT(sp == 0);
							(t.part.Add() = pa[si++]).format = q.format;
							len--;
							sp = 0;
						}
					}
				}
			}
			ASSERT(si == pa.GetCount() && sp == 0);
			Put(pi, t, style);
			ii++;
			pi++;
		}
	}
}
예제 #13
0
	bool LuaStack::SwapTableKey(int i_table_index)
	{
		if (IsTable(i_table_index))
		{
			lua_gettable(state, i_table_index);
			return true;
		}
		return false;
	}
예제 #14
0
ProcessParameter::parameter_list ProcessParameter::TableColumns() const
{
   parameter_list parameters;
   if ( IsTable() )
      if ( (*API->Process->EnumerateTableColumns)( m_data->handle,
                                    InternalParameterEnumerator::ParameterCallback, &parameters ) == api_false )
         throw APIFunctionError( "EnumerateTableColumns" );
   return parameters;
}
예제 #15
0
파일: Ref.cpp 프로젝트: Pocsel/luasel
 Ref Ref::GetTable(std::string const& name) const
 {
     auto table = this->operator[](name);
     if (!table.Exists())
         table = this->Set(name, this->_state.MakeTable());
     if (!table.IsTable())
         throw std::runtime_error("Luasel::Ref: Indexing a value that is not a table");
     return table;
 }
예제 #16
0
void RichTxt::ApplyZoom(Zoom z, const RichStyles& ostyle, const RichStyles& zstyle)
{
	for(int i = 0; i < GetPartCount(); i++)
		if(IsTable(i))
			part[i].Get<RichTable>().ApplyZoom(z, ostyle, zstyle);
		else {
			RichPara p = Get(i, ostyle);
			p.ApplyZoom(z);
			Set(i, p, zstyle);
		}
}
예제 #17
0
AnnotationTablePtr AnnotationValue::GetValueAsTable() const
{
	if (!IsTable())
	{
		std::stringstream ss;
		ss << "Attempted to access " << GetTypeString() 
			<< " annotation as a table.";
		throw AnnotationValueTypeException(ss.str());
	}
	AnnotationTableInternalPtr table = boost::get<AnnotationTableInternalPtr>(value);
	return AnnotationTablePtr(table.get());
}
예제 #18
0
RichTxt& RichTxt::GetText0(int& pos, bool update)
{
	if(update)
		Invalidate();
	int p = pos;
	int pi = FindPart(p);
	if(IsTable(pi)) {
		RichTable& tab = part[pi].Get<RichTable>();
		Point cl = tab.FindCell(p);
		if(update) {
			tab.InvalidateRefresh(cl);
			SetRefresh(pi);
		}
		pos = p;
		return tab[cl].text.GetText0(pos, update);
	}
	return *this;
}
예제 #19
0
bool RichTxt::Update(ParaOp& op)
{
	bool val = false;
	for(int i = 0; i < part.GetCount(); i++)
		if(IsTable(i)) {
			RichTable& tab = part[i].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j))
						if(tab[i][j].text.Update(op)) {
							tab.InvalidateRefresh(i, j);
							val = true;
						}
		}
		else
		if(op(part[i].Get<Para>()))
			val = true;
	RefreshAll();
	return val;
}
예제 #20
0
NAMESPACE_UPP

void RichTxt::GetAllLanguages(Index<int>& all) const
{
	for(int i = 0; i < part.GetCount(); i++) {
		if(IsTable(i)) {
			const RichTable& tab = part[i].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j))
						tab[i][j].text.GetAllLanguages(all);
		}
		else {
			RichPara p = Get(i, RichStyle::GetDefault());
			all.FindAdd(p.format.language);
			for(int i = 0; i < p.GetCount(); i++)
				all.FindAdd(p[i].format.language);
		}
	}
}
예제 #21
0
int   RichTxt::GetPos(int x, PageY y, RichContext rc) const
{
	int parti = 0;
	int pos = 0;

	if(part.GetCount()) {
		PageY nnext = GetNextPageY(parti, rc);
		while(parti < part.GetCount()) {
			PageY next = nnext;
			if(parti + 1 < part.GetCount()) {
				RichContext nrc = rc;
				nrc.py = next;
				nnext = GetNextPageY(parti + 1, nrc);
			}
			if(y < next || y.page < next.page) {
				if(IsTable(parti))
					return GetTable(parti).GetPos(x, y, rc) + pos;
				else {
					int nbefore = 0;
					int nline = 0;
					if(part[parti].Get<Para>().keepnext && parti + 1 < part.GetCount() && IsPara(parti + 1)) {
						Sync(parti + 1, rc);
						const Para& pp = part[parti + 1].Get<Para>();
						nbefore = pp.before;
						nline = pp.linecy[0];
					}
					return Get(parti, rc.styles).GetPos(x, y, rc.page, rc.py, nbefore, nline) + pos;
				}
			}
			pos += GetPartLength(parti) + 1;
			parti++;
			rc.py = next;
		}
	}

	return pos - 1;
}
예제 #22
0
WString RichTxt::GetPlainText() const {
	WString clip;
	for(int pi = 0; pi < GetPartCount(); pi++) {
		if(pi) {
			clip.Cat('\r');
			clip.Cat('\n');
		}
		if(IsTable(pi)) {
			const RichTable& tab = part[pi].Get<RichTable>();
			for(int i = 0; i < tab.GetRows(); i++)
				for(int j = 0; j < tab.GetColumns(); j++)
					if(tab(i, j)) {
						if(i || j) {
							clip.Cat('\r');
							clip.Cat('\n');
						}
						clip << tab[i][j].text.GetPlainText();
					}
		}
		else
			clip.Cat(Get(pi, RichStyle::GetDefault()).GetText());
	}
	return clip;
}
예제 #23
0
파일: TextPaint.cpp 프로젝트: koz4k/soccer
bool RichText::GetInvalid(PageY& top, PageY& bottom, const Rect& page,
                          int sell, int selh, int osell, int oselh) const
{
	Mutex::Lock __(mutex);
	int spi = 0;
	int rtype = r_type;
	if(sell != selh || osell != oselh) {
		if(sell != osell) {
			if(rtype == NONE) {
				spi = FindPart(sell);
				rtype = spi == FindPart(osell) ? SPARA : ALL;
			}
			else
				rtype = ALL;
		}
		if(selh != oselh) {
			if(rtype == NONE) {
				spi = FindPart(selh);
				rtype = spi == FindPart(oselh) ? SPARA : ALL;
			}
			else
				rtype = ALL;
		}
	}
	bottom = top = PageY(0, page.top);
	if(rtype == NONE) {
		bottom = top;
		return false;
	}
	if(rtype == ALL) {
		bottom = GetHeight(page);
		return true;
	}
#if 0
	RichContext rc = Context(page, PageY(0, 0));
	if(rtype == SPARA) {
		rc.py = top = GetPartPageY(spi, rc);
		bottom = GetNextPageY(spi, rc);
		return true;
	}
#endif
	RichContext begin;
	if(rtype == SPARA) { // selection changed within single paragraph
		RichContext rc = GetPartContext(spi, Context(page));
		top = rc.py;
		bottom = GetAdvanced(spi, rc, begin).py;
		return true;
	}
	RichContext rc = GetPartContext(r_parti, Context(page));
	top = rc.py;
	if(rtype == PARA) {
		if(IsTable(r_parti))
			switch(GetTable(r_parti).GetInvalid(top, bottom, rc)) {
			case -1: return false;
			case 0: return true;
			default:
				bottom = GetHeight(page);
				return true;
			}
		else {
			Sync(r_parti, rc);
			const Para& pp = part[r_parti].Get<Para>();
			if(r_paraocx == pp.ccx &&
			   r_paraocy == Sum(pp.linecy, 0) + pp.ruler + pp.before + pp.after &&
			   r_keep == pp.keep &&
			   r_keepnext == pp.keepnext &&
			   r_newpage == pp.newpage) {
				bottom = GetAdvanced(r_parti, rc, begin).py;
				return true;
			}
		}
	}
	bottom = GetHeight(page);
	return true;
}