Kill macro mode when using LFUN_ESCAPE

Add a `cancel' boolean to macroModeClose() that just removes all trace
of what has been entered instead of finalizing it.

When entering a macro in mathed, let LFUN_ESCAPE invoke
macroModeClose(true). The new semantics of LFUN_ESCAPE in mathed is
thus to abort the input of a macro name.

Fixes bug #9251.

(cherry picked from commit 9296344b9a)
This commit is contained in:
Jean-Marc Lasgouttes 2018-02-20 12:09:10 +01:00
parent 77d10ca20a
commit 66fd21adcb
4 changed files with 14 additions and 7 deletions

View File

@ -1528,7 +1528,7 @@ bool Cursor::down()
} }
bool Cursor::macroModeClose() bool Cursor::macroModeClose(bool cancel)
{ {
if (!inMacroMode()) if (!inMacroMode())
return false; return false;
@ -1541,7 +1541,7 @@ bool Cursor::macroModeClose()
cell().erase(pos()); cell().erase(pos());
// do nothing if the macro name is empty // do nothing if the macro name is empty
if (s == "\\") if (s == "\\" || cancel)
return false; return false;
// trigger updates of macros, at least, if no full // trigger updates of macros, at least, if no full

View File

@ -488,9 +488,9 @@ public:
void setScreenPos(int x, int y); void setScreenPos(int x, int y);
/// current offset in the top cell /// current offset in the top cell
/// interpret name a name of a macro. Returns true if /// interpret name of a macro or ditch it if \c cancel is true.
/// something got inserted. /// Returns true if something got inserted.
bool macroModeClose(); bool macroModeClose(bool cancel = false);
/// are we currently typing the name of a macro? /// are we currently typing the name of a macro?
bool inMacroMode() const; bool inMacroMode() const;
/// get access to the macro we are currently typing /// get access to the macro we are currently typing

View File

@ -869,10 +869,14 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_ESCAPE: case LFUN_ESCAPE:
if (cur.selection()) if (cur.selection())
cur.clearSelection(); cur.clearSelection();
else {
if (cur.inMacroMode())
cur.macroModeClose(true);
else { else {
cmd = FuncRequest(LFUN_FINISHED_FORWARD); cmd = FuncRequest(LFUN_FINISHED_FORWARD);
cur.undispatched(); cur.undispatched();
} }
}
break; break;
// 'Locks' the math inset. A 'locked' math inset behaves as a unit // 'Locks' the math inset. A 'locked' math inset behaves as a unit

View File

@ -152,6 +152,9 @@ What's new
- Fix untranslated GUI strings on View/Update toolbar button menu (bug 11040). - Fix untranslated GUI strings on View/Update toolbar button menu (bug 11040).
- When entering a math macro name, Escape properly cancels the
operation (bug 9251).
* INTERNALS * INTERNALS