From 68fd2fbdfe1fe7cb7ca42e1966f5916944d4adca Mon Sep 17 00:00:00 2001 From: "smontagu%smontagu.org" Date: Tue, 7 Mar 2006 06:03:37 +0000 Subject: [PATCH] Add a user option to allow delete and backspace to delete immediately even if the character to be deleted is visually distant from the caret location. Bug 328834, r=uriber@gmail.com, sr=roc --- editor/libeditor/text/nsTextEditRules.cpp | 8 ++++++++ editor/libeditor/text/nsTextEditRules.h | 4 ++++ editor/libeditor/text/nsTextEditRulesBidi.cpp | 2 +- modules/libpref/src/init/all.js | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index cc9487401bb9..06c94d4cf792 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -165,6 +165,14 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor, PRUint32 aFlags) res = ReplaceNewlines(wholeDoc); } + PRBool deleteBidiImmediately = PR_FALSE; + nsCOMPtr prefBranch = + do_GetService(NS_PREFSERVICE_CONTRACTID, &res); + if (NS_SUCCEEDED(res)) + prefBranch->GetBoolPref("bidi.edit.delete_immediately", + &deleteBidiImmediately); + mDeleteBidiImmediately = deleteBidiImmediately; + return res; } diff --git a/editor/libeditor/text/nsTextEditRules.h b/editor/libeditor/text/nsTextEditRules.h index 9b947a313461..d50e8c3edccc 100644 --- a/editor/libeditor/text/nsTextEditRules.h +++ b/editor/libeditor/text/nsTextEditRules.h @@ -211,6 +211,10 @@ protected: PRUint32 mActionNesting; PRPackedBool mLockRulesSniffing; PRPackedBool mDidExplicitlySetInterline; + PRPackedBool mDeleteBidiImmediately; // in bidirectional text, delete + // characters not visually + // adjacent to the caret without + // moving the caret first. PRInt32 mTheAction; // the top level editor action // friends friend class nsAutoLockRulesSniffing; diff --git a/editor/libeditor/text/nsTextEditRulesBidi.cpp b/editor/libeditor/text/nsTextEditRulesBidi.cpp index 466ad11e1c17..0dd97de0a2fa 100644 --- a/editor/libeditor/text/nsTextEditRulesBidi.cpp +++ b/editor/libeditor/text/nsTextEditRulesBidi.cpp @@ -143,7 +143,7 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsIDOMNode *aSelNode, ; // perform the deletion else { - if (levelBefore == levelAfter) + if (mDeleteBidiImmediately || levelBefore == levelAfter) ; // perform the deletion else *aCancel = PR_TRUE; diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 7928471aa1e4..f1829cf18527 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -927,6 +927,10 @@ pref("bidi.support", 1); // 1 = doccharactersetBidi * // 2 = defaultcharactersetBidi pref("bidi.characterset", 1); +// Whether delete and backspace should immediately delete characters not +// visually adjacent to the caret, or adjust the visual position of the caret +// on the first keypress and delete the character on a second keypress +pref("bidi.edit.delete_immediately", false); // used for double-click word selection behavior. Win will override.