当前位置: 首页>>代码示例>>C++>>正文


C++ DocIterator::paragraph方法代码示例

本文整理汇总了C++中DocIterator::paragraph方法的典型用法代码示例。如果您正苦于以下问题:C++ DocIterator::paragraph方法的具体用法?C++ DocIterator::paragraph怎么用?C++ DocIterator::paragraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocIterator的用法示例。


在下文中一共展示了DocIterator::paragraph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paintMisspelledMark

void RowPainter::paintMisspelledMark(Row::Element const & e) const
{
	if (e.font.fontInfo().nospellcheck() == FONT_ON)
		return;
	// if changed the misspelled marker gets placed slightly lower than normal
	// to avoid drawing at the same vertical offset
	FontMetrics const & fm = theFontMetrics(e.font);
	int const thickness = max(fm.lineWidth(), 2);
	int const y = yo_ + pi_.base.solidLineOffset() + pi_.base.solidLineThickness()
		+ (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
		+ 1 + thickness / 2;

	//FIXME: this could be computed only once, it is probably not costly.
	// check for cursor position
	// don't draw misspelled marker for words at cursor position
	// we don't want to disturb the process of text editing
	DocIterator const nw = pi_.base.bv->cursor().newWord();
	pos_type cpos = -1;
	if (!nw.empty() && par_.id() == nw.paragraph().id()) {
		cpos = nw.pos();
		if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
			--cpos;
		else if (cpos > 0 && par_.isWordSeparator(cpos))
			--cpos;
	}

	pos_type pos = e.pos;
	while (pos < e.pos + pos_type(e.str.length())) {
		if (!par_.isMisspelled(pos)) {
			++pos;
			continue;
		}

		FontSpan const & range = par_.getSpellRange(pos);

		// Skip element which are being edited
		if (range.contains(cpos)) {
			// the range includes the last element
			pos = range.last + 1;
			continue;
		}

		int x1 = fm.pos2x(e.str, range.first - e.pos,
		                  e.isRTL(), e.extra);
		int x2 = fm.pos2x(e.str, min(range.last - e.pos + 1,
									 pos_type(e.str.length())),
									 e.isRTL(), e.extra);
		if (x1 > x2)
			swap(x1, x2);

		pi_.pain.line(int(x_ + x1), y, int(x_ + x2), y,
		              Color_error,
		              Painter::line_onoffdash, thickness);
		pos = range.last + 1;
	}
}
开发者ID:cburschka,项目名称:lyx,代码行数:56,代码来源:RowPainter.cpp

示例2: updateItem

bool TocBackend::updateItem(DocIterator const & dit)
{
	if (dit.paragraph().layout().toclevel == Layout::NOT_IN_TOC)
		return false;

	if (toc("tableofcontents").empty()) {
		// FIXME: should not happen, 
		// a call to TocBackend::update() is missing somewhere
		LYXERR0("TocBackend::updateItem called but the TOC is empty!");
		return false;
	}

	BufferParams const & bufparams = buffer_->params();
	const int min_toclevel = bufparams.documentClass().min_toclevel();

	TocIterator toc_item = item("tableofcontents", dit);

	docstring tocstring;

	// For each paragraph, traverse its insets and let them add
	// their toc items
	Paragraph & par = toc_item->dit_.paragraph();
	InsetList::const_iterator it = par.insetList().begin();
	InsetList::const_iterator end = par.insetList().end();
	for (; it != end; ++it) {
		Inset & inset = *it->inset;
		if (inset.lyxCode() == ARG_CODE) {
			if (!tocstring.empty())
				break;
			Paragraph const & inset_par =
				*static_cast<InsetArgument&>(inset).paragraphs().begin();
			if (!par.labelString().empty())
				tocstring = par.labelString() + ' ';
			tocstring += inset_par.asString(AS_STR_INSETS);
			break;
		}
	}

	int const toclevel = par.layout().toclevel;
	if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
		&& tocstring.empty())
			tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);

	const_cast<TocItem &>(*toc_item).str_ = tocstring;

	buffer_->updateTocItem("tableofcontents", dit);
	return true;
}
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:48,代码来源:TocBackend.cpp

示例3: goTo

bool GuiErrorList::goTo(int item)
{
    if (&buffer() != buf_) {
        if (!theBufferList().isLoaded(buf_))
            return false;
        FuncRequest fr(LFUN_BUFFER_SWITCH, buf_->absFileName());
        dispatch(fr);
    }
    ErrorItem const & err = errorList()[item];

    if (err.par_id == -1)
        return false;

    if (from_master_)
        // FIXME: implement
        return false;

    DocIterator dit = buf_->getParFromID(err.par_id);

    if (dit == doc_iterator_end(buf_)) {
        // FIXME: Happens when loading a read-only doc with
        // unknown layout. Should this be the case?
        LYXERR0("par id " << err.par_id << " not found");
        return false;
    }

    // Now make the selection.
    // if pos_end is 0, this means it is end-of-paragraph
    pos_type const s = dit.paragraph().size();
    pos_type const end = err.pos_end ? min(err.pos_end, s) : s;
    pos_type const start = min(err.pos_start, end);
    pos_type const range = end - start;
    dit.pos() = start;
    BufferView * bv = const_cast<BufferView *>(bufferview());
    // FIXME: If we used an LFUN, we would not need this line:
    bv->putSelectionAt(dit, range, false);
    bv->processUpdateFlags(Update::Force | Update::FitCursor);
    return true;
}
开发者ID:bsjung,项目名称:Lyx,代码行数:39,代码来源:GuiErrorList.cpp


注:本文中的DocIterator::paragraph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。