Пример #1
0
void ManGenerator::startCodeFragment() 
{ 
  newParagraph();
  t << ".nf" << endl; 
  firstCol=TRUE;
  paragraph=FALSE;
}
Пример #2
0
void PmlReader::processAlignment(ZLTextAlignmentType alignment) {
	if (myState.Alignment != alignment) {
		myState.Alignment = alignment;
	} else {
		myState.Alignment = ALIGN_UNDEFINED;
	}
	newParagraph();
}
Пример #3
0
void PmlReader::processIndent(const std::string& parameter) {
	int indentPercentSize = 5;
	if (!parameter.empty()) {
		const int index = parameter.find('%');
        if (index != -1) {
        	const std::string indentValueStr = parameter.substr(0, index);
			indentPercentSize = atoi(indentValueStr.data());
		} else {
			indentPercentSize = 5;
		}
	}
	if(!myState.IndentBlockOn) {
		myState.Indent = indentPercentSize;
	} else {
		myState.Indent = 0;
	}
	myState.IndentBlockOn = !myState.IndentBlockOn;
	newParagraph();
}
Пример #4
0
status_t
TextDocument::Remove(int32 textOffset, int32 length)
{
	if (length == 0)
		return B_OK;

	int32 paragraphOffset;
	int32 index = ParagraphIndexFor(textOffset, paragraphOffset);
	if (index < 0)
		return B_BAD_VALUE;

	textOffset -= paragraphOffset;

	// The paragraph at the text offset remains, even if the offset is at
	// the beginning of that paragraph. The idea is that the selection start
	// stays visually in the same place. Therefore, the paragraph at that
	// offset has to keep the paragraph style from that paragraph.

	Paragraph resultParagraph(ParagraphAt(index));
	int32 paragraphLength = resultParagraph.Length();
	if (textOffset == 0 && length > paragraphLength) {
		length -= paragraphLength;
		paragraphLength = 0;
		resultParagraph.Clear();
	} else {
		int32 removeLength = std::min(length, paragraphLength - textOffset);
		resultParagraph.Remove(textOffset, removeLength);
		paragraphLength -= removeLength;
		length -= removeLength;
	}

	if (textOffset == paragraphLength && length == 0
		&& index + 1 < fParagraphs.CountItems()) {
		// Line break between paragraphs got removed. Shift the next
		// paragraph's text spans into the resulting one.

		const TextSpanList&	textSpans = ParagraphAt(index + 1).TextSpans();
		int32 spanCount = textSpans.CountItems();
		for (int32 i = 0; i < spanCount; i++) {
			const TextSpan& span = textSpans.ItemAtFast(i);
			resultParagraph.Append(span);
		}
		fParagraphs.Remove(index + 1);
	}

	textOffset = 0;

	while (length > 0 && index + 1 < fParagraphs.CountItems()) {
		const Paragraph& paragraph = ParagraphAt(index + 1);
		paragraphLength = paragraph.Length();
		// Remove paragraph in any case. If some of it remains, the last
		// paragraph to remove is reached, and the remaining spans are
		// transfered to the result parahraph.
		if (length >= paragraphLength) {
			length -= paragraphLength;
			fParagraphs.Remove(index);
		} else {
			// Last paragraph reached
			int32 removedLength = std::min(length, paragraphLength);
			Paragraph newParagraph(paragraph);
			fParagraphs.Remove(index + 1);

			if (!newParagraph.Remove(0, removedLength))
				return B_NO_MEMORY;

			// Transfer remaining spans to resultParagraph
			const TextSpanList&	textSpans = newParagraph.TextSpans();
			int32 spanCount = textSpans.CountItems();
			for (int32 i = 0; i < spanCount; i++) {
				const TextSpan& span = textSpans.ItemAtFast(i);
				resultParagraph.Append(span);
			}

			break;
		}
	}

	fParagraphs.Replace(index, resultParagraph);

	return B_OK;
}