本文整理汇总了C++中TextDocument::text方法的典型用法代码示例。如果您正苦于以下问题:C++ TextDocument::text方法的具体用法?C++ TextDocument::text怎么用?C++ TextDocument::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextDocument
的用法示例。
在下文中一共展示了TextDocument::text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)
*/
}