Fixup 71623b88: change semantics of "delete" LFUNs again

Instead of specifying "force" to disable the deletion protection
mechanism, invert the default so that "confirm" is needed to activate
it. The idea is to keep the lfun reasonable for scripting and add a
special argument for interactive use.

Document in release notes.

Update LFUN.lyx documentation

Update bind files.

Add conversion step to prefs2prefs_lfun.py.
This commit is contained in:
Jean-Marc Lasgouttes 2022-02-21 14:00:14 +01:00
parent 7b5a5e524b
commit ff1ddf6251
12 changed files with 540 additions and 912 deletions

View File

@ -178,6 +178,16 @@
* branch-sync-all: Open/close all insets of selected branch (depending on its activation status). * branch-sync-all: Open/close all insets of selected branch (depending on its activation status).
* word-delete-forward, word-delete-backward, char-delete-forward,
char-delete-backward
The 2.4 behavior of these functions is almost equivalent to the
pre-2.3 behavior: without argument, it just deletes the
next/previous element; with the "confirm" argument however, big
insets are selected on the first call and deleted only on the
second. This new behavior allow scripts to work intuitively and
require the argument only for interactive use.
!!!The following LyX functions have been removed in 2.4: !!!The following LyX functions have been removed in 2.4:

View File

@ -226,8 +226,8 @@ Format 5
# Edit group # Edit group
# #
\bind "C-Delete" "word-delete-forward" \bind "C-Delete" "word-delete-forward confirm"
\bind "C-BackSpace" "word-delete-backward" \bind "C-BackSpace" "word-delete-backward confirm"
\bind "M-Return" "paragraph-break inverse" \bind "M-Return" "paragraph-break inverse"
\bind "C-Return" "newline-insert newline" \bind "C-Return" "newline-insert newline"
\bind "C-S-Return" "newline-insert linebreak" \bind "C-S-Return" "newline-insert linebreak"

View File

@ -31,7 +31,7 @@ Format 5
\bind "C-a" "line-begin" \bind "C-a" "line-begin"
\bind "C-b" "char-backward" \bind "C-b" "char-backward"
#bind "C-c" "------" // used as users prefix #bind "C-c" "------" // used as users prefix
\bind "C-d" "char-delete-forward" \bind "C-d" "char-delete-forward confirm"
\bind "C-e" "line-end" \bind "C-e" "line-end"
\bind "C-f" "char-forward" \bind "C-f" "char-forward"
\bind "C-g" "cancel" \bind "C-g" "cancel"
@ -225,9 +225,9 @@ Format 5
# Edit group # Edit group
# #
\bind "C-Delete" "word-delete-forward" \bind "C-Delete" "word-delete-forward confirm"
\bind "M-d" "word-delete-forward" \bind "M-d" "word-delete-forward confirm"
\bind "C-BackSpace" "word-delete-backward" \bind "C-BackSpace" "word-delete-backward confirm"
\bind "M-Return" "paragraph-break inverse" \bind "M-Return" "paragraph-break inverse"
\bind "C-Return" "newline-insert newline" \bind "C-Return" "newline-insert newline"
\bind "C-S-Return" "newline-insert linebreak" \bind "C-S-Return" "newline-insert linebreak"

View File

@ -53,13 +53,13 @@ Format 5
# +: "Control-B" # Move one character backward # +: "Control-B" # Move one character backward
\bind "M-b" "char-backward" \bind "M-b" "char-backward"
# +: "Control-D" # Delete the character in front of the cursor # +: "Control-D" # Delete the character in front of the cursor
\bind "M-d" "char-delete-forward" \bind "M-d" "char-delete-forward confirm"
# +: "Control-E" # Move to end of line/paragraph # +: "Control-E" # Move to end of line/paragraph
\bind "M-e" "line-end" \bind "M-e" "line-end"
# +: "Control-F" # Move one character forward # +: "Control-F" # Move one character forward
\bind "M-f" "char-forward" \bind "M-f" "char-forward"
# +: "Control-H" # Delete the character behind the cursor # +: "Control-H" # Delete the character behind the cursor
\bind "M-h" "char-delete-backward" \bind "M-h" "char-delete-backward confirm"
# -: "Control-K" # Delete from the character in front of the cursor to the end of the line/paragraph # -: "Control-K" # Delete from the character in front of the cursor to the end of the line/paragraph
# used by menu.bind - keymap # used by menu.bind - keymap
# +: "Control-L" # Center the cursor/selection in the visible area # +: "Control-L" # Center the cursor/selection in the visible area
@ -83,7 +83,7 @@ Format 5
\bind "M-S-BackTab" "buffer-previous" \bind "M-S-BackTab" "buffer-previous"
\bind "A-S-BackTab" "buffer-previous" \bind "A-S-BackTab" "buffer-previous"
# +: "fn-Delete" # Forward Delete (on portable Macs' built-in keyboard) # +: "fn-Delete" # Forward Delete (on portable Macs' built-in keyboard)
\bind "Delete" "char-delete-forward" \bind "Delete" "char-delete-forward confirm"
# ?: "Control-F1" # Toggle full keyboard access on or off # ?: "Control-F1" # Toggle full keyboard access on or off
# +: "Control-F2" # Move focus to the menu bar # +: "Control-F2" # Move focus to the menu bar
# +: "Control-F3" # Move focus to the Dock # +: "Control-F3" # Move focus to the Dock
@ -348,8 +348,8 @@ Format 5
# Additional Edit group # Additional Edit group
# #
\bind "A-Delete" "word-delete-forward" \bind "A-Delete" "word-delete-forward confirm"
\bind "A-BackSpace" "word-delete-backward" \bind "A-BackSpace" "word-delete-backward confirm"
\bind "M-Return" "paragraph-break inverse" \bind "M-Return" "paragraph-break inverse"
\bind "C-Return" "newline-insert newline" \bind "C-Return" "newline-insert newline"
\bind "C-S-Return" "newline-insert linebreak" \bind "C-S-Return" "newline-insert linebreak"

View File

@ -38,8 +38,8 @@ Format 5
\bind "Prior" "screen-up" \bind "Prior" "screen-up"
\bind "Next" "screen-down" \bind "Next" "screen-down"
\bind "Return" "paragraph-break" \bind "Return" "paragraph-break"
\bind "Delete" "char-delete-forward" \bind "Delete" "char-delete-forward confirm"
\bind "BackSpace" "char-delete-backward" \bind "BackSpace" "char-delete-backward confirm"
\bind "KP_Enter" "paragraph-break" \bind "KP_Enter" "paragraph-break"
\bind "KP_Right" "char-right" \bind "KP_Right" "char-right"

View File

@ -152,4 +152,4 @@ Format 5
# #
\unbind "M-u" "word-upcase partial" \unbind "M-u" "word-upcase partial"
\unbind "M-d" "word-delete-forward" \unbind "M-d" "word-delete-forward confirm"

View File

@ -33,7 +33,7 @@ Format 5
\bind "C-a" "line-begin" \bind "C-a" "line-begin"
\bind "C-b" "char-backward" \bind "C-b" "char-backward"
#bind "C-c" "------" # see end of file #bind "C-c" "------" # see end of file
\bind "C-d" "char-delete-forward" \bind "C-d" "char-delete-forward confirm"
\bind "C-e" "line-end" \bind "C-e" "line-end"
\bind "C-f" "char-forward" \bind "C-f" "char-forward"
\bind "C-g" "cancel" \bind "C-g" "cancel"
@ -220,10 +220,10 @@ Format 5
# Edit group # Edit group
# #
\bind "M-Delete" "word-delete-backward" \bind "M-Delete" "word-delete-backward confirm"
\bind "C-Delete" "word-delete-forward" \bind "C-Delete" "word-delete-forward confirm"
\bind "M-d" "word-delete-forward" \bind "M-d" "word-delete-forward confirm"
\bind "C-BackSpace" "word-delete-backward" \bind "C-BackSpace" "word-delete-backward confirm"
\bind "M-Return" "paragraph-break inverse" \bind "M-Return" "paragraph-break inverse"
\bind "C-Return" "newline-insert newline" \bind "C-Return" "newline-insert newline"
\bind "C-S-Return" "newline-insert linebreak" \bind "C-S-Return" "newline-insert linebreak"

File diff suppressed because it is too large Load Diff

View File

@ -221,6 +221,27 @@ def remove_date_insert(line):
return simple_remove(line, "date-insert") return simple_remove(line, "date-insert")
re_delete_force = re.compile(r"((char|word)-delete-(for|back)ward)(\s+force)?")
def delete_force(line):
# we change as follows:
# char-delete-forward -> char-delete-forward confirm
# but:
# char-delete-forward force -> char-delete-forward
#
def change(match):
if match.group(4):
return match.group(1)
else:
return match.group(1) + " confirm"
result = re_delete_force.subn(change, line)
if result[1]:
return (True, result[0])
else:
return no_match
# #
########################################################### ###########################################################
@ -258,6 +279,7 @@ conversions = [
info_rename_vcstime, info_rename_vcstime,
info_rename_vcsrevision, info_rename_vcsrevision,
info_rename_vcstreerevision, info_rename_vcstreerevision,
remove_date_insert remove_date_insert,
delete_force
]] ]]
] ]

View File

@ -1150,8 +1150,8 @@ void LyXAction::init()
/*! /*!
* \var lyx::FuncCode lyx::LFUN_CHAR_DELETE_BACKWARD * \var lyx::FuncCode lyx::LFUN_CHAR_DELETE_BACKWARD
* \li Action: Deletes one character in the backward direction (usually the "BackSpace" key). * \li Action: Deletes one character in the backward direction (usually the "BackSpace" key).
* \li Syntax: char-delete-backward [force] * \li Syntax: char-delete-backward [confirm]
* \li Params: force: Delete big insets, do not only select them. * \li Params: confirm: Select big insets, do not directly delete them.
* \endvar * \endvar
*/ */
{ LFUN_CHAR_DELETE_BACKWARD, "char-delete-backward", SingleParUpdate, Edit }, { LFUN_CHAR_DELETE_BACKWARD, "char-delete-backward", SingleParUpdate, Edit },
@ -1159,8 +1159,8 @@ void LyXAction::init()
/*! /*!
* \var lyx::FuncCode lyx::LFUN_CHAR_DELETE_FORWARD * \var lyx::FuncCode lyx::LFUN_CHAR_DELETE_FORWARD
* \li Action: Deletes one character in the backward direction (usually the "Delete" key). * \li Action: Deletes one character in the backward direction (usually the "Delete" key).
* \li Syntax: char-delete-forward [force] * \li Syntax: char-delete-forward [confirm]
* \li Params: force: Delete big insets, do not only select them. * \li Params: confirm: Select big insets, do not directly delete them.
* \endvar * \endvar
*/ */
{ LFUN_CHAR_DELETE_FORWARD, "char-delete-forward", SingleParUpdate, Edit }, { LFUN_CHAR_DELETE_FORWARD, "char-delete-forward", SingleParUpdate, Edit },
@ -2190,7 +2190,7 @@ void LyXAction::init()
matches all note insets, while "Note:Note" only matches LyX matches all note insets, while "Note:Note" only matches LyX
yellow note insets. yellow note insets.
* \li Sample: Remove all index insets: \n * \li Sample: Remove all index insets: \n
inset-forall Index char-delete-forward force \n inset-forall Index char-delete-forward \n
Close all Notes: \n Close all Notes: \n
inset-forall Note inset-toggle close \n inset-forall Note inset-toggle close \n
Open all branch insets of branch "myBranch": \n Open all branch insets of branch "myBranch": \n
@ -4417,8 +4417,8 @@ void LyXAction::init()
/*! /*!
* \var lyx::FuncCode lyx::LFUN_WORD_DELETE_BACKWARD * \var lyx::FuncCode lyx::LFUN_WORD_DELETE_BACKWARD
* \li Action: Deletes characters to the beginning of the word (usually the "C+BackSpace" key). * \li Action: Deletes characters to the beginning of the word (usually the "C+BackSpace" key).
* \li Syntax: word-delete-backward [force] * \li Syntax: word-delete-backward [confirm]
* \li Params: force: Delete big insets, do not only select them. * \li Params: confirm: Select big insets, do not directly delete them.
* \endvar * \endvar
*/ */
{ LFUN_WORD_DELETE_BACKWARD, "word-delete-backward", Noop, Edit }, { LFUN_WORD_DELETE_BACKWARD, "word-delete-backward", Noop, Edit },
@ -4426,8 +4426,8 @@ void LyXAction::init()
/*! /*!
* \var lyx::FuncCode lyx::LFUN_WORD_DELETE_FORWARD * \var lyx::FuncCode lyx::LFUN_WORD_DELETE_FORWARD
* \li Action: Deletes characters to the end of the word (usually the "C+Delete" key). * \li Action: Deletes characters to the end of the word (usually the "C+Delete" key).
* \li Syntax: word-delete-forward [force] * \li Syntax: word-delete-forward [confirm]
* \li Params: force: Delete big insets, do not only select them. * \li Params: confirm: Select big insets, do not directly delete them.
* \endvar * \endvar
*/ */
{ LFUN_WORD_DELETE_FORWARD, "word-delete-forward", Noop, Edit }, { LFUN_WORD_DELETE_FORWARD, "word-delete-forward", Noop, Edit },

View File

@ -750,7 +750,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.selection()) if (cur.selection())
cutSelection(cur, false); cutSelection(cur, false);
else else
deleteWordForward(cur, cmd.getArg(0) == "force"); deleteWordForward(cur, cmd.getArg(0) != "confirm");
finishChange(cur, false); finishChange(cur, false);
break; break;
@ -758,7 +758,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.selection()) if (cur.selection())
cutSelection(cur, false); cutSelection(cur, false);
else else
deleteWordBackward(cur, cmd.getArg(0) == "force"); deleteWordBackward(cur, cmd.getArg(0) != "confirm");
finishChange(cur, false); finishChange(cur, false);
break; break;
@ -1225,7 +1225,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.pos() == cur.paragraph().size()) if (cur.pos() == cur.paragraph().size())
// Par boundary, force full-screen update // Par boundary, force full-screen update
singleParUpdate = false; singleParUpdate = false;
else if (cmd.getArg(0) != "force" && cur.confirmDeletion()) { else if (cmd.getArg(0) == "confirm" && cur.confirmDeletion()) {
cur.resetAnchor(); cur.resetAnchor();
cur.selection(true); cur.selection(true);
cur.posForward(); cur.posForward();
@ -1250,7 +1250,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Par boundary, full-screen update // Par boundary, full-screen update
if (par_boundary) if (par_boundary)
singleParUpdate = false; singleParUpdate = false;
else if (cmd.getArg(0) != "force" && cur.confirmDeletion(true)) { else if (cmd.getArg(0) == "confirm" && cur.confirmDeletion(true)) {
cur.resetAnchor(); cur.resetAnchor();
cur.selection(true); cur.selection(true);
cur.posBackward(); cur.posBackward();

View File

@ -827,8 +827,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
else if (!cur.inMacroMode()) else if (!cur.inMacroMode())
cur.recordUndoSelection(); cur.recordUndoSelection();
// if the inset can not be removed from within, delete it // if the inset can not be removed from within, delete it
if (!cur.backspace(cmd.getArg(0) == "force")) { if (!cur.backspace(cmd.getArg(0) != "confirm")) {
FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force"); FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
cur.innerText()->dispatch(cur, newcmd); cur.innerText()->dispatch(cur, newcmd);
} }
break; break;
@ -841,8 +841,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
else else
cur.recordUndoSelection(); cur.recordUndoSelection();
// if the inset can not be removed from within, delete it // if the inset can not be removed from within, delete it
if (!cur.erase(cmd.getArg(0) == "force")) { if (!cur.erase(cmd.getArg(0) != "confirm")) {
FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force"); FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
cur.innerText()->dispatch(cur, newcmd); cur.innerText()->dispatch(cur, newcmd);
} }
break; break;