• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TextDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TextDocument的典型用法代码示例。如果您正苦于以下问题:C++ TextDocument类的具体用法?C++ TextDocument怎么用?C++ TextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: foreach

QMap<QString, QString> TextDocument::openedTextDocumentContents()
{
    QMap<QString, QString> workingCopy;
    foreach (IDocument *document, DocumentModel::openedDocuments()) {
        TextDocument *textEditorDocument = qobject_cast<TextDocument *>(document);
        if (!textEditorDocument)
            continue;
        QString fileName = textEditorDocument->filePath().toString();
        workingCopy[fileName] = textEditorDocument->plainText();
    }
开发者ID:,项目名称:,代码行数:10,代码来源:


示例2: openURL

void DocManager::gotoTextLine( const KURL &url, int line )
{
	TextDocument * doc = dynamic_cast<TextDocument*>( openURL(url) );
	TextView * tv = doc ? doc->textView() : 0;
	
	if ( !tv ) return;
	
	tv->gotoLine(line);
	tv->setFocus();
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:10,代码来源:docmanager.cpp


示例3: TEST

TEST (test_case, your_test)
{
	TextDocument *text = new TextDocument();
	ASSERT_TRUE(text->GetGraphic() == NULL);
	text->Insert(new ImageProxy("virtual_proxy_pattern.cpp"));

	Graphic *graph = text->GetGraphic();//image object is not yet instantiated
	ASSERT_TRUE(graph != NULL);
	ASSERT_TRUE(graph->GetExtent() == Point(0, 0));
	Point pt(10, 5);
	graph->Draw(pt);
	Point pt2 = graph->GetExtent();
	ASSERT_TRUE(pt2 == pt);

	delete text;
}
开发者ID:cristeab,项目名称:PersonalProject,代码行数:16,代码来源:virtual_proxy_pattern.cpp


示例4: TextEditorWidget

/// This method test the undo functionality of the text
void ReplaceSelectionCommandTest::testUndo()
{
    TextEditorWidget* widget = new TextEditorWidget();
    TextEditorController* ctrl = widget->controller();
    TextDocument *doc = widget->textDocument();
    TextBuffer* buf = doc->buffer();

    // check if we can set the txt  
    ctrl->replaceSelection("test");
    testEqual( buf->text(), "test" );

    // test basic, undo/redo
        ctrl->undo();
        testEqual( buf->text(), "" );

        // test coalesce
        ctrl->replaceSelection("emma");
        ctrl->replaceSelection(" sarah",true);
        ctrl->replaceSelection(" david",true);
        testEqual( buf->text(), "emma sarah david" );
        ctrl->undo();
        testEqual( buf->text(), "emma" );

        ctrl->redo();
        testEqual( buf->text(), "emma sarah david");

    // test ranged replacement
        doc->textUndoStack()->clear();
        buf->setText("Blommers");

        testEqual( buf->text(), "Blommers" );

        // now replace 'mm' by nothing
        TextRangeSet sel( doc );
        sel.addRange(3,5);
        ctrl->replaceRangeSet( sel, "" );
        testEqual( buf->text(), "Bloers" );

        ctrl->undo();
        testEqual( buf->text(), "Blommers" );
        ctrl->redo();
        testEqual( buf->text(), "Bloers" );



        delete widget;
}
开发者ID:letmefly,项目名称:edbee-lib,代码行数:48,代码来源:replaceselectioncommandtest.cpp


示例5: fileOpened

TextDocument *DocManager::openTextFile( const KURL &url, ViewArea *viewArea )
{
	TextDocument *document = TextDocument::constructTextDocument( url.fileName().remove(url.directory()) );
	
	if (!document)
		return 0;
	
	if ( !document->openURL(url) )
	{
		KMessageBox::sorry( 0, i18n("Could not open text file \"%1\"").arg(url.prettyURL()) );
		document->deleteLater();
		return 0;
	}
	
	handleNewDocument( document, viewArea );
	emit fileOpened(url);
	return document;
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:18,代码来源:docmanager.cpp


示例6: flush

TextDocument* TextDocument::clone()
{
    if (d.dirty > 0)
        flush();

    TextDocument* doc = new TextDocument(d.buffer);
    doc->setDefaultStyleSheet(defaultStyleSheet());
    QTextCursor(doc).insertFragment(QTextDocumentFragment(this));
    doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat());

    // TODO:
    doc->d.uc = d.uc;
    doc->d.css = d.css;
    doc->d.lowlight = d.lowlight;
    doc->d.buffer = d.buffer;
    doc->d.highlights = d.highlights;
    doc->d.timeStampFormat = d.timeStampFormat;
    doc->d.clone = true;

    return doc;
}
开发者ID:rburchell,项目名称:communi-desktop,代码行数:21,代码来源:textdocument.cpp


示例7: foreach

void TextMarkRegistry::documentRenamed(IDocument *document, const
                                           QString &oldName, const QString &newName)
{
    TextDocument *baseTextDocument = qobject_cast<TextDocument *>(document);
    if (!document)
        return;
    FileName oldFileName = FileName::fromString(oldName);
    FileName newFileName = FileName::fromString(newName);
    if (!m_marks.contains(oldFileName))
        return;

    QSet<TextMark *> toBeMoved;
    foreach (TextMark *mark, baseTextDocument->marks())
        toBeMoved.insert(mark);

    m_marks[oldFileName].subtract(toBeMoved);
    m_marks[newFileName].unite(toBeMoved);

    foreach (TextMark *mark, toBeMoved)
        mark->updateFileName(newName);
}
开发者ID:MarianMMX,项目名称:qt-creator,代码行数:21,代码来源:textmark.cpp


示例8: CreateMainFile

BOOL CFileBasedProjectTemplateItem::CreateMainFile(LPCTSTR lpszTargetPath, LPCTSTR lpszCrLf)
{
	CStringW text;
	TextDocument doc;

	bool result = doc.Read(m_strPath,text);

	if (result)
	{
		const CStringW lineendings(L"\r\n");
		int index = text.FindOneOf(lineendings);

		if (index != -1)
		{
			CStringW line = text.Left(index);
			const CStringW strKey(L"%DESCRIPTION: ");
			CStringW strStartOfLine = line.Left(strKey.GetLength());

			strStartOfLine.MakeUpper();

			if (strKey == strStartOfLine) 
			{
				text.Delete(0,index);
				text.TrimLeft(lineendings + L' ');
			}
		}

		LPCWSTR le = GetLineEnding(static_cast<LPCWSTR>(text),text.GetLength());

		USES_CONVERSION;

		if (std::wcscmp(le,T2CW(lpszCrLf)) != 0) // Line endings not equal
			text.Replace(le,lpszCrLf);

		result = doc.Write(lpszTargetPath,text);
	}

	return result;
}
开发者ID:bzindovic,项目名称:texniccenter-code,代码行数:39,代码来源:projectnewdialog.cpp


示例9: del

void TextUndoStackTest::testMultiCaretUndoIssue196()
{
    TextEditorWidget widget;
    TextDocument* doc = widget.textDocument();
    TextEditorController* controller = widget.controller();
//    TextUndoStack* undoStack = doc->textUndoStack();

    controller->replace(0,0,"1a2b3c4d",0);                  // 1a|2b|3c4d
    controller->moveCaretToOffset(2,false);
    controller->addCaretAtOffset(4);

    testEqual( doc->text(), "1a2b3c4d" );
    testEqual( controller->textSelection()->rangesAsString(), "2>2,4>4");

    RemoveCommand del( RemoveCommand::RemoveChar, RemoveCommand::Right );

    del.execute(controller);
    testEqual( doc->text(), "1abc4d" );                          // 1a|b|c4d
    testEqual( controller->textSelection()->rangesAsString(), "2>2,3>3");

    del.execute(controller);
    testEqual( controller->textSelection()->rangesAsString(), "2>2");
    testEqual( doc->text(), "1a4d" );                       // 1a||4d



    del.execute(controller);
    testEqual( doc->text(), "1ad" );
    testEqual( controller->textSelection()->rangesAsString(), "2>2");

    del.execute(controller);
    testEqual( doc->text(), "1a" );
    testEqual( controller->textSelection()->rangesAsString(), "2>2");

    del.execute(controller);
    testEqual( doc->text(), "1a" );
    testEqual( controller->textSelection()->rangesAsString(), "2>2");

//qlog_info() << "STACK: ---------------------------------------";
//qlog_info() << doc->textUndoStack()->dumpStack();
//qlog_info() << "----------------------------------------------";

    controller->undo();

    testEqual( doc->text(), "1a2b3c4d" );
    testEqual( controller->textSelection()->rangesAsString(), "2>2,4>4");


/*


==== after 1 delete ===

  1a|2b|3c4d =>  1a|b|c4d


 UndoStack
 =====================
 "-|Complex::TextChangeGroup(3/3)
 - 0: SelectionTextChange
 - 1: SingleTextChange:2:0:2
 - 2: SingleTextChange:3:0:3

==== after 2 deletes ===

  1a|b|c4d =>  1a|4d


UndoStack
=====================
"-|Complex::TextChangeGroup(3/3)
 - 0: SelectionTextChange
 - 1: SingleTextChange:2:0:2b         (2b en 3c is verwijderd... Dit is nog goed!)
 - 2: SingleTextChange:2:0:3c

 ==== after 3 deletes ===

  1a|4d =>  1a|d

  // NEW STACK ITEM REQUIRED!!!!

 UndoStack
 =====================
 "-|Complex::TextChangeGroup(3/3)
 - 0: SelectionTextChange
 - 1: SingleTextChange:2:0:2b4
 - 2: SingleTextChange:1:0:3c          <= hier zou de 4 achter moeten staan!!! (Dit is nooit te bepalen, omdat je niet weet welke carets verdwenen zijn)

*/


}
开发者ID:letmefly,项目名称:edbee-lib,代码行数:92,代码来源:textundostacktest.cpp


示例10: execute

/// execute the given selection command
/// @param controller the controller to execute the selection for
void SelectionCommand::execute( TextEditorController* controller )
{
    // save the selection state
    TextDocument* document = controller->textDocument();
    TextRangeSet* currentSelection = dynamic_cast<TextRangeSet*>( controller->textSelection() );
    TextRangeSet* sel = new TextRangeSet(*currentSelection);  // start with the current selection

    bool resetAnchors = !keepSelection_;

    // handle the select operation
    switch( unit_ ) {
        // character movement
        case MoveCaretByCharacter:
            sel->moveCarets(amount_);
            break;

        // This results in clearing the selection if a selection is present or it results in a movement of the caret.
        // When clearing a selection the caret is placed next to the selection (which side depends on the direction)
        case MoveCaretsOrDeselect:
            if( keepSelection_ ) {
                sel->moveCarets(amount_);
            } else {
                sel->moveCaretsOrDeselect(amount_);
            }
            break;

        case MoveCaretByWord:
            sel->moveCaretsByCharGroup(amount_, document->config()->whitespaceWithoutNewline(), document->config()->charGroups() );
            break;

        case MoveCaretByLine:
            TextSelection::moveCaretsByLine( controller, sel, amount_ );
            break;

        case MoveCaretToLineBoundary:
            sel->moveCaretsToLineBoundary( amount_, document->config()->whitespaceWithoutNewline() );
            break;

        case MoveCaretToDocumentBegin:
            sel->toSingleRange();
            sel->range(0).setCaret(0);
            break;

        case MoveCaretToDocumentEnd:
            sel->toSingleRange();
            sel->range(0).setCaret( controller->textDocument()->length() );
            break;

        case MoveCaretByPage:
        {
            // make sure the first line of the window is scrolled
            TextRenderer* renderer   = controller->textRenderer();
            TextEditorWidget* widget = controller->widget();
            int firstVisibleLine = renderer->firstVisibleLine();
            int linesPerPage     = renderer->viewHeightInLines();

            sel->beginChanges();
            TextSelection::moveCaretsByPage( controller, sel, amount_ );
            if( !keepSelection_ ) {
                sel->resetAnchors();    // we must reset anchors here because de process-changes will merge carets
            }
            sel->endChanges();

            firstVisibleLine += linesPerPage * amount_;
            widget->scrollTopToLine( firstVisibleLine );

            break;
        }
        case MoveCaretToExactOffset:
            sel->toSingleRange();
            sel->range(0).setCaret(amount_);
            break;

        case SelectAll:
            sel->toSingleRange();
            sel->setRange(0, document->buffer()->length() );
            resetAnchors = false;   // do not reset the anchors
            break;

        case SelectWord:
            sel->expandToWords(document->config()->whitespaces(), document->config()->charGroups());
            resetAnchors = false;   // do not reset the anchors
            break;

        case SelectWordAt:
            sel->selectWordAt( amount_, document->config()->whitespaces(), document->config()->charGroups() );
            resetAnchors = false;
            break;

        case ToggleWordSelectionAt:
            sel->toggleWordSelectionAt( amount_, document->config()->whitespaces(), document->config()->charGroups() );
            resetAnchors = false;
            break;

        case SelectFullLine:
            sel->expandToFullLines( amount_);
            resetAnchors = false;
            break;
//.........这里部分代码省略.........
开发者ID:letmefly,项目名称:edbee-lib,代码行数:101,代码来源:selectioncommand.cpp


示例11: KUrl

void ProcessChain::slotFinishedCompile(Language *language)
{
	ProcessOptions options = language->processOptions();
	
	if ( options.b_addToProject && ProjectManager::self()->currentProject() )
		ProjectManager::self()->currentProject()->addFile( KUrl(options.targetFile()) );
	
	ProcessOptions::ProcessPath::MediaType typeTo = ProcessOptions::ProcessPath::to( m_processOptions.processPath() );
	
	TextDocument * editor = 0l;
	if ( KTLConfig::reuseSameViewForOutput() )
	{
		editor = options.textOutputTarget();
		if ( editor && (!editor->url().isEmpty() || editor->isModified()) )
			editor = 0l;
	}
	
	switch (typeTo)
	{
		case ProcessOptions::ProcessPath::AssemblyAbsolute:
		case ProcessOptions::ProcessPath::AssemblyRelocatable:
		case ProcessOptions::ProcessPath::C:
		case ProcessOptions::ProcessPath::Disassembly:
		case ProcessOptions::ProcessPath::Library:
		case ProcessOptions::ProcessPath::Microbe:
		case ProcessOptions::ProcessPath::Object:
		case ProcessOptions::ProcessPath::Program:
		{
			switch ( options.method() )
			{
				case ProcessOptions::Method::LoadAsNew:
				{
					if ( !editor )
						editor = DocManager::self()->createTextDocument();
					
					if ( !editor )
						break;
				
					QString text;
					QFile f( options.targetFile() );
					if ( !f.open( QIODevice::ReadOnly ) )
					{
						editor->deleteLater();
						editor = 0l;
						break;
					}
				
					QTextStream stream(&f);
				
					while ( !stream.atEnd() )
						text += stream.readLine()+'\n';
				
					f.close();
	
					editor->setText( text, true );
					break;
				}
			
				case ProcessOptions::Method::Load:
				{
					editor = dynamic_cast<TextDocument*>( DocManager::self()->openURL(options.targetFile()) );
					break;
				}
			
				case ProcessOptions::Method::Forget:
					break;
			}
		}
			
		case ProcessOptions::ProcessPath::FlowCode:
		case ProcessOptions::ProcessPath::Pic:
		case ProcessOptions::ProcessPath::Unknown:
			break;
	}
	
	
	if (editor)
	{
		switch (typeTo)
		{
			case ProcessOptions::ProcessPath::AssemblyAbsolute:
			case ProcessOptions::ProcessPath::AssemblyRelocatable:
			{
				if ( KTLConfig::autoFormatMBOutput() )
					editor->formatAssembly();
				editor->slotInitLanguage( TextDocument::ct_asm );
				break;
			}
		
			case ProcessOptions::ProcessPath::C:
				editor->slotInitLanguage( TextDocument::ct_c );
				break;
			
			case ProcessOptions::ProcessPath::Disassembly:
				break;
			
			case ProcessOptions::ProcessPath::Library:
			case ProcessOptions::ProcessPath::Object:
			case ProcessOptions::ProcessPath::Program:
				editor->slotInitLanguage( TextDocument::ct_hex );
//.........这里部分代码省略.........
开发者ID:ktechlab,项目名称:ktechlab,代码行数:101,代码来源:processchain.cpp


示例12: Document

TextDocument::TextDocument(const TextDocument& orig) : Document(orig) {
    text = auto_ptr< string > (new string(*orig.getText()));
}
开发者ID:w-martin,项目名称:tact,代码行数:3,代码来源:TextDocument.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TextEdit类代码示例发布时间:2022-05-31
下一篇:
C++ TextDiagnosticPrinter类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap