本文整理汇总了C++中TextEditor::GetSelectionController方法的典型用法代码示例。如果您正苦于以下问题:C++ TextEditor::GetSelectionController方法的具体用法?C++ TextEditor::GetSelectionController怎么用?C++ TextEditor::GetSelectionController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor::GetSelectionController方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
NS_IMETHODIMP
SelectionMoveCommands::DoCommand(const char* aCommandName,
nsISupports* aCommandRefCon) {
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
TextEditor* textEditor = editor->AsTextEditor();
MOZ_ASSERT(textEditor);
RefPtr<Document> doc = textEditor->GetDocument();
if (doc) {
// Most of the commands below (possibly all of them) need layout to
// be up to date.
doc->FlushPendingNotifications(FlushType::Layout);
}
nsCOMPtr<nsISelectionController> selectionController =
textEditor->GetSelectionController();
if (NS_WARN_IF(!selectionController)) {
return NS_ERROR_FAILURE;
}
// scroll commands
for (size_t i = 0; i < mozilla::ArrayLength(scrollCommands); i++) {
const ScrollCommand& cmd = scrollCommands[i];
if (!nsCRT::strcmp(aCommandName, cmd.reverseScroll)) {
return (selectionController->*(cmd.scroll))(false);
} else if (!nsCRT::strcmp(aCommandName, cmd.forwardScroll)) {
return (selectionController->*(cmd.scroll))(true);
}
}
// caret movement/selection commands
for (size_t i = 0; i < mozilla::ArrayLength(moveCommands); i++) {
const MoveCommand& cmd = moveCommands[i];
if (!nsCRT::strcmp(aCommandName, cmd.reverseMove)) {
return (selectionController->*(cmd.move))(false, false);
} else if (!nsCRT::strcmp(aCommandName, cmd.forwardMove)) {
return (selectionController->*(cmd.move))(true, false);
} else if (!nsCRT::strcmp(aCommandName, cmd.reverseSelect)) {
return (selectionController->*(cmd.move))(false, true);
} else if (!nsCRT::strcmp(aCommandName, cmd.forwardSelect)) {
return (selectionController->*(cmd.move))(true, true);
}
}
// physical-direction movement/selection
for (size_t i = 0; i < mozilla::ArrayLength(physicalCommands); i++) {
const PhysicalCommand& cmd = physicalCommands[i];
if (!nsCRT::strcmp(aCommandName, cmd.move)) {
return selectionController->PhysicalMove(cmd.direction, cmd.amount,
false);
} else if (!nsCRT::strcmp(aCommandName, cmd.select)) {
return selectionController->PhysicalMove(cmd.direction, cmd.amount, true);
}
}
return NS_ERROR_FAILURE;
}