X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FKeyMap.h;h=cd28782356ac98336fb791def7b84c5d5824d789;hb=6da7ee1be170629aa6647aa8b2d6cf66ea928a9b;hp=cc7c15595915cf3ec9ea94e65125f8e4d964536c;hpb=b8cf8cbab2d5f3a2e3897a79f5103e8e46f1614b;p=lyx.git diff --git a/src/KeyMap.h b/src/KeyMap.h index cc7c155959..cd28782356 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -4,7 +4,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Jean-Marc Lasgouttes * \author John Levon * @@ -19,13 +19,17 @@ #include "support/strfwd.h" -#include +#include "support/shared_ptr.h" #include namespace lyx { +namespace support { + class FileName; +} + /// Defines key maps and actions for key sequences class KeyMap { public: @@ -37,6 +41,12 @@ public: UserExtraUnbind //< \unbind loaded from user.bind, without //< corresponding entry in system bind file. }; + enum BindReadType { + MissingOK, //< It's OK if this file is missing. + Fallback, //< If missing, fallback to default "cua". This should only + //< be used when attempting to read the user-secified bind file. + Default //< Report error and return. + }; /** * Bind/Unbind a key sequence to an action. * @return 0 on success, or position in string seq where error @@ -72,8 +82,10 @@ public: * * @param bind_file bind file * @param unbind_map pointer to a KeyMap that holds \unbind bindings + * @param rt how to respond if the file can't be found */ - bool read(std::string const & bind_file, KeyMap * unbind_map = 0); + bool read(std::string const & bind_file, KeyMap * unbind_map = 0, + BindReadType rt = Default); /** write to a bind file. * @param append append to the bind_file instead of overwrite it @@ -106,7 +118,8 @@ public: Bindings findBindings(FuncRequest const & func) const; /// Given an action, print the keybindings. - docstring printBindings(FuncRequest const & func) const; + docstring printBindings(FuncRequest const & func, + KeySequence::outputFormat format) const; struct Binding { Binding(FuncRequest const & r, KeySequence const & s, ItemType t) @@ -150,11 +163,22 @@ private: /// Modifier masks ModifierPair mod; /// Keymap for prefix keys - boost::shared_ptr table; + shared_ptr prefixes; /// Action for !prefix keys FuncRequest func; }; + enum ReturnValues { + ReadOK, + ReadError, + FileError, + FormatMismatch + }; + /// + bool read(support::FileName const & bind_file, KeyMap * unbind_map = 0); + /// + ReturnValues readWithoutConv(support::FileName const & bind_file, KeyMap * unbind_map = 0); + /** * Given an action, find all keybindings * @param func the action