Helper patch for bug 15364. Expose an API to allow scripts to show the caret even in selections (a la Emacs). Users can also set the pref ui.caretVisibleWithSelection to 1, which gives a nice combination with caret browsing (hit F7). r=sfraser, sr=bzbarsky

git-svn-id: svn://10.0.0.236/trunk@144128 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rbs%maths.uq.edu.au
2003-06-25 01:14:25 +00:00
parent b37e2004d2
commit a6c97c6fb0
6 changed files with 69 additions and 0 deletions

View File

@@ -428,6 +428,7 @@ public:
NS_IMETHOD SetCaretWidth(PRInt16 twips);
NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly);
NS_IMETHOD GetCaretEnabled(PRBool *_retval);
NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility);
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend);
NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend);
NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend);
@@ -676,6 +677,27 @@ nsTextInputSelectionImpl::GetCaretEnabled(PRBool *_retval)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(PRBool aVisibility)
{
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsresult result;
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
if (shell)
{
nsCOMPtr<nsICaret> caret;
if (NS_SUCCEEDED(result = shell->GetCaret(getter_AddRefs(caret))))
{
nsCOMPtr<nsISelection> domSel;
if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))))
{
return caret->SetVisibilityDuringSelection(aVisibility);
}
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsTextInputSelectionImpl::CharacterMove(PRBool aForward, PRBool aExtend)