[LyX/master] Add != operator to FuncRequest and special value FuncRequest::prefix
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Sat Dec 10 18:35:03 UTC 2022
commit 46992201b71c3b20e9cdf640ce1b8d36ecaf48ac
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Fri Dec 9 14:43:19 2022 +0100
Add != operator to FuncRequest and special value FuncRequest::prefix
Use this value (and `unknown' where relevant)
---
src/FuncRequest.cpp | 8 ++++++++
src/FuncRequest.h | 5 +++++
src/KeyMap.cpp | 3 +--
src/frontends/qt/GuiPrefs.cpp | 3 ++-
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/FuncRequest.cpp b/src/FuncRequest.cpp
index 25ea41a..1597027 100644
--- a/src/FuncRequest.cpp
+++ b/src/FuncRequest.cpp
@@ -28,6 +28,7 @@ namespace lyx {
FuncRequest const FuncRequest::unknown(LFUN_UNKNOWN_ACTION);
FuncRequest const FuncRequest::noaction(LFUN_NOACTION);
+FuncRequest const FuncRequest::prefix(LFUN_COMMAND_PREFIX);
FuncRequest::FuncRequest(Origin o)
: origin_(o)
@@ -114,12 +115,19 @@ string FuncRequest::getLongArg(unsigned int i) const
return i < args.size() ? args[i] : string();
}
+
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
{
return lhs.action() == rhs.action() && lhs.argument() == rhs.argument();
}
+bool operator!=(FuncRequest const & lhs, FuncRequest const & rhs)
+{
+ return !(lhs == rhs);
+}
+
+
ostream & operator<<(ostream & os, FuncRequest const & cmd)
{
return os
diff --git a/src/FuncRequest.h b/src/FuncRequest.h
index 52fb143..efbe425 100644
--- a/src/FuncRequest.h
+++ b/src/FuncRequest.h
@@ -99,6 +99,9 @@ public:
///
static FuncRequest const noaction;
///
+ static FuncRequest const prefix;
+
+ ///
bool allowAsync() const { return allow_async_; }
///
void allowAsync(bool allow_async) { allow_async_ = allow_async; }
@@ -129,6 +132,8 @@ private:
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
+bool operator!=(FuncRequest const & lhs, FuncRequest const & rhs);
+
std::ostream & operator<<(std::ostream &, FuncRequest const &);
LyXErr & operator<<(LyXErr &, FuncRequest const &);
diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp
index 1fb82c2..c530f5f 100644
--- a/src/KeyMap.cpp
+++ b/src/KeyMap.cpp
@@ -457,8 +457,7 @@ FuncRequest const & KeyMap::lookup(KeySymbol const &key,
if (cit->prefixes) {
// this is a prefix key - set new map
seq->curmap = cit->prefixes.get();
- static const FuncRequest prefix(LFUN_COMMAND_PREFIX);
- return prefix;
+ return FuncRequest::prefix;
} else {
// final key - reset map
seq->reset();
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index c72baee..46baffd 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -3359,9 +3359,10 @@ docstring makeCmdString(FuncRequest const & f)
FuncRequest PrefShortcuts::currentBinding(KeySequence const & k)
{
FuncRequest res = user_bind_.getBinding(k);
- if (res.action() != LFUN_UNKNOWN_ACTION)
+ if (res != FuncRequest::unknown)
return res;
res = system_bind_.getBinding(k);
+
// Check if it is unbound. Note: user_unbind_ can only unbind one
// FuncRequest per key sequence.
if (user_unbind_.getBinding(k) == res)
More information about the lyx-cvs
mailing list