本文整理汇总了C++中selectionEnd函数的典型用法代码示例。如果您正苦于以下问题:C++ selectionEnd函数的具体用法?C++ selectionEnd怎么用?C++ selectionEnd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了selectionEnd函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: owner
bool TextCursor::isSame(Cursor* c)
{
auto tc = dynamic_cast<TextCursor*>(c);
if (tc)
return tc->owner() == owner()
&& tc->selectionBegin() == selectionBegin()
&& tc->selectionEnd() == selectionEnd();
return false;
}
示例2: data
QString ChatItem::selection() const
{
if (selectionMode() == FullSelection)
return data(MessageModel::DisplayRole).toString();
if (selectionMode() == PartialSelection) {
int start = qMin(selectionStart(), selectionEnd());
int end = start + qAbs(selectionStart() - selectionEnd());
QTextCursor cSelect(document());
cSelect.setPosition(start);
cSelect.setPosition(end, QTextCursor::KeepAnchor);
return cSelect.selectedText();
}
return QString();
}
示例3: document
QAbstractTextDocumentLayout::Selection ChatItem::selectionLayout() const
{
QAbstractTextDocumentLayout::Selection selection;
if (!hasSelection())
return selection;
int start;
int end;
if (selectionMode() == FullSelection) {
start = 0;
end = document()->characterCount()-1;
}
else {
start = selectionStart();
end = selectionEnd();
}
QTextCursor c(document());
c.setPosition(start);
c.setPosition(end, QTextCursor::KeepAnchor);
selection.cursor = c;
return selection;
}
示例4: buildCompletionList
void TabCompleter::complete()
{
if (!enabled) {
buildCompletionList();
enabled = true;
}
if (nextCompletion != completionMap.end()) {
// clear previous completion
auto cur = msgEdit->textCursor();
cur.setPosition(cur.selectionEnd());
msgEdit->setTextCursor(cur);
for (int i = 0; i < lastCompletionLength; ++i)
msgEdit->textCursor().deletePreviousChar();
// insert completion
msgEdit->insertPlainText(*nextCompletion);
// remember charcount to delete next time and advance to next completion
lastCompletionLength = nextCompletion->length();
++nextCompletion;
// we're completing the first word of the line
if (msgEdit->textCursor().position() == lastCompletionLength) {
msgEdit->insertPlainText(nickSuffix);
lastCompletionLength += nickSuffix.length();
}
} else { // we're at the end of the list -> start over again
if (!completionMap.isEmpty()) {
nextCompletion = completionMap.begin();
complete();
}
}
}
示例5: value
void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionState& exceptionState)
{
if (start > end) {
exceptionState.throwDOMException(IndexSizeError, "The provided start value (" + String::number(start) + ") is larger than the provided end value (" + String::number(end) + ").");
return;
}
if (hasAuthorShadowRoot())
return;
String text = innerTextValue();
unsigned textLength = text.length();
unsigned replacementLength = replacement.length();
unsigned newSelectionStart = selectionStart();
unsigned newSelectionEnd = selectionEnd();
start = std::min(start, textLength);
end = std::min(end, textLength);
if (start < end)
text.replace(start, end - start, replacement);
else
text.insert(replacement, start);
setInnerTextValue(text);
// FIXME: What should happen to the value (as in value()) if there's no renderer?
if (!renderer())
return;
subtreeHasChanged();
if (equalIgnoringCase(selectionMode, "select")) {
newSelectionStart = start;
newSelectionEnd = start + replacementLength;
} else if (equalIgnoringCase(selectionMode, "start"))
newSelectionStart = newSelectionEnd = start;
else if (equalIgnoringCase(selectionMode, "end"))
newSelectionStart = newSelectionEnd = start + replacementLength;
else {
// Default is "preserve".
long delta = replacementLength - (end - start);
if (newSelectionStart > end)
newSelectionStart += delta;
else if (newSelectionStart > start)
newSelectionStart = start;
if (newSelectionEnd > end)
newSelectionEnd += delta;
else if (newSelectionEnd > start)
newSelectionEnd = start + replacementLength;
}
setSelectionRange(newSelectionStart, newSelectionEnd, SelectionHasNoDirection);
}
示例6: innerTextValue
void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionCode& ec)
{
if (start > end) {
ec = INDEX_SIZE_ERR;
return;
}
String text = innerTextValue();
unsigned textLength = text.length();
unsigned replacementLength = replacement.length();
unsigned newSelectionStart = selectionStart();
unsigned newSelectionEnd = selectionEnd();
start = std::min(start, textLength);
end = std::min(end, textLength);
if (start < end)
text.replace(start, end - start, replacement);
else
text.insert(replacement, start);
setInnerTextValue(text);
// FIXME: What should happen to the value (as in value()) if there's no renderer?
if (!renderer())
return;
subtreeHasChanged();
if (equalIgnoringCase(selectionMode, "select")) {
newSelectionStart = start;
newSelectionEnd = start + replacementLength;
} else if (equalIgnoringCase(selectionMode, "start"))
newSelectionStart = newSelectionEnd = start;
else if (equalIgnoringCase(selectionMode, "end"))
newSelectionStart = newSelectionEnd = start + replacementLength;
else {
// Default is "preserve".
long delta = replacementLength - (end - start);
if (newSelectionStart > end)
newSelectionStart += delta;
else if (newSelectionStart > start)
newSelectionStart = start;
if (newSelectionEnd > end)
newSelectionEnd += delta;
else if (newSelectionEnd > start)
newSelectionEnd = start + replacementLength;
}
setSelectionRange(newSelectionStart, newSelectionEnd, SelectionHasNoDirection);
}
示例7: fileToDocPos
QTextCursor YFileCursor::qTextCursor(const YTextDocument * document) const
{
if(isNull()) { return QTextCursor(); }
int anchor = fileToDocPos(charAddress(), document);
int position = fileToDocPos(selectionEnd(), document);
if(position < anchor) { std::swap(position, anchor); }
QTextCursor cursor(document->begin());
cursor.setPosition(anchor);
cursor.setPosition(position, QTextCursor::KeepAnchor);
return cursor;
}
示例8: setRangeText
void HTMLTextFormControlElement::setRangeText(const String& replacement, ExceptionCode& ec)
{
setRangeText(replacement, selectionStart(), selectionEnd(), String(), ec);
}
示例9: String
String HTMLTextFormControlElement::selectedText() const
{
if (!isTextFormControl())
return String();
return value().substring(selectionStart(), selectionEnd() - selectionStart());
}
示例10: setSelectionRange
void HTMLTextFormControlElement::setSelectionDirection(const String& direction)
{
setSelectionRange(selectionStart(), selectionEnd(), direction);
}