本文整理汇总了C++中ktexteditor::Cursor::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Cursor::setPosition方法的具体用法?C++ Cursor::setPosition怎么用?C++ Cursor::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::Cursor
的用法示例。
在下文中一共展示了Cursor::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCursorStringConversion
void RangeTest::testCursorStringConversion()
{
using KTextEditor::Cursor;
KTextEditor::Cursor c;
QCOMPARE(c.line(), 0);
QCOMPARE(c.column(), 0);
QCOMPARE(c.toString(), QStringLiteral("(0, 0)"));
c = Cursor::fromString(QStringLiteral("(0, 0)"));
QCOMPARE(c.toString(), QStringLiteral("(0, 0)"));
c = Cursor::fromString(QStringLiteral("(0,0)"));
QCOMPARE(c.toString(), QStringLiteral("(0, 0)"));
c.setPosition(-1, -1);
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-1, -1)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-1,-1)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c.setPosition(12, 42);
QCOMPARE(c.toString(), QStringLiteral("(12, 42)"));
c = Cursor::fromString(QStringLiteral("(12, 42)"));
QCOMPARE(c.toString(), QStringLiteral("(12, 42)"));
c = Cursor::fromString(QStringLiteral("( 12,42)"));
QCOMPARE(c.toString(), QStringLiteral("(12, 42)"));
c.setPosition(12, 42);
QCOMPARE(c.toString(), QStringLiteral("(12, 42)"));
c = Cursor::fromString(QStringLiteral("(12, 42)"));
QCOMPARE(c.toString(), QStringLiteral("(12, 42)"));
c.setPosition(-12, 42);
QCOMPARE(c.toString(), QStringLiteral("(-12, 42)"));
c = Cursor::fromString(QStringLiteral("(-12, 42)"));
QCOMPARE(c.toString(), QStringLiteral("(-12, 42)"));
c = Cursor::fromString(QStringLiteral("(-12, +42)"));
QCOMPARE(c.toString(), QStringLiteral("(-12, 42)"));
c = Cursor::fromString(QStringLiteral("( -12 , +42)"));
QCOMPARE(c.toString(), QStringLiteral("(-12, 42)"));
c = Cursor::fromString(QStringLiteral("(-12 , 42 )"));
QCOMPARE(c.toString(), QStringLiteral("(-12, 42)"));
// test invalid input
c = Cursor::fromString(QStringLiteral("( - 12 , + 42)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(, 42)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-, -)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-, -)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-x,y)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
c = Cursor::fromString(QStringLiteral("(-3,-2y)"));
QCOMPARE(c.toString(), QStringLiteral("(-1, -1)"));
}
示例2: cursorFromScriptValue
/** Conversion function from QtScript cursor to KTextEditor::Cursor */
static void cursorFromScriptValue(const QScriptValue &obj, KTextEditor::Cursor &cursor)
{
cursor.setPosition(obj.property("line").toInt32(),
obj.property("column").toInt32());
}