mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
CmdDef:
- deboostification - correct comments git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21931 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0743f576cb
commit
4cd6123095
@ -13,7 +13,6 @@
|
||||
# DO NOT CHANGE THIS DEFAULT COMMAND DEFINITION FILE! It will be replaced
|
||||
# with every new install of LyX and your changes will be lost.
|
||||
# Instead, customize a copy of this file placed in
|
||||
# ~/.lyx/commands/default.bind
|
||||
# ~/.lyx/commands/default.def
|
||||
#
|
||||
# Happy tuning!
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
@ -62,8 +63,6 @@ bool CmdDef::read(string const & def_file)
|
||||
return false;
|
||||
}
|
||||
|
||||
//LYXERR(Debug::KBMAP, "Reading def file:" << tmp);
|
||||
|
||||
bool error = false;
|
||||
while (lexrc.isOK()) {
|
||||
switch (lexrc.lex()) {
|
||||
@ -133,47 +132,36 @@ bool CmdDef::read(string const & def_file)
|
||||
|
||||
bool CmdDef::lock(string const & name, FuncRequest & func)
|
||||
{
|
||||
if (cmdDefMap.empty())
|
||||
{
|
||||
if (cmdDefMap.empty()) {
|
||||
func = FuncRequest::unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
string const name2 = trim(name);
|
||||
|
||||
CmdDefMap::const_iterator pos = cmdDefMap.find(name2);
|
||||
|
||||
if (pos == cmdDefMap.end())
|
||||
{
|
||||
func = FuncRequest::unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pos->second->locked)
|
||||
{
|
||||
if (lockSet.find(name2) != lockSet.end()) {
|
||||
func = FuncRequest::noaction;
|
||||
return false;
|
||||
}
|
||||
|
||||
pos->second->locked = true;
|
||||
func = pos->second->func;
|
||||
CmdDefMap::const_iterator pos = cmdDefMap.find(name2);
|
||||
|
||||
if (pos == cmdDefMap.end()) {
|
||||
func = FuncRequest::unknown;
|
||||
return false;
|
||||
}
|
||||
|
||||
lockSet.insert(name2);
|
||||
func = pos->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CmdDef::release(string const & name)
|
||||
{
|
||||
if (cmdDefMap.empty())
|
||||
return;
|
||||
|
||||
string const name2 = trim(name);
|
||||
|
||||
CmdDefMap::const_iterator pos = cmdDefMap.find(name2);
|
||||
|
||||
if (pos == cmdDefMap.end())
|
||||
return;
|
||||
|
||||
pos->second->locked = false;
|
||||
lockSet.erase(name2);
|
||||
}
|
||||
|
||||
CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name,
|
||||
@ -193,9 +181,7 @@ CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name,
|
||||
return CmdDefInvalid;
|
||||
}
|
||||
|
||||
boost::shared_ptr<CmdDefInfo> info;
|
||||
info.reset(new CmdDefInfo(func));
|
||||
cmdDefMap[name2] = info;
|
||||
cmdDefMap[name2] = func;
|
||||
|
||||
return CmdDefOk;
|
||||
}
|
||||
|
24
src/CmdDef.h
24
src/CmdDef.h
@ -16,30 +16,18 @@
|
||||
|
||||
#include "support/strfwd.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/// Creates command definitions
|
||||
class CmdDef {
|
||||
private:
|
||||
/// information for a definition
|
||||
struct CmdDefInfo {
|
||||
CmdDefInfo(FuncRequest const & f): func(f), locked(false) {}
|
||||
/// the expanded FuncRequest
|
||||
FuncRequest func;
|
||||
/// to avoid recursive calls
|
||||
bool locked;
|
||||
};
|
||||
|
||||
|
||||
/// type for map between a macro name and its info
|
||||
typedef std::map<std::string, boost::shared_ptr<CmdDefInfo> > CmdDefMap;
|
||||
|
||||
typedef std::map<std::string, FuncRequest> CmdDefMap;
|
||||
/// type for a set containing all locked definitions
|
||||
typedef std::set<std::string> LockSet;
|
||||
public:
|
||||
|
||||
/// Parse a def file
|
||||
@ -72,10 +60,12 @@ private:
|
||||
* @param name internal recursion level
|
||||
*/
|
||||
newCmdDefResult newCmdDef(std::string const & name,
|
||||
std::string const & def);
|
||||
std::string const & def);
|
||||
|
||||
///
|
||||
CmdDefMap cmdDefMap;
|
||||
///
|
||||
LockSet lockSet;
|
||||
};
|
||||
|
||||
/// Implementation is in LyX.cpp
|
||||
|
@ -2398,8 +2398,7 @@ string const LyXRC::getDescription(LyXRCTags tag)
|
||||
break;
|
||||
|
||||
case RC_DEFFILE:
|
||||
//FIXME: fix description.
|
||||
str = _("Command definition file.");
|
||||
str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
|
||||
break;
|
||||
|
||||
case RC_DEFAULT_LANGUAGE:
|
||||
|
Loading…
Reference in New Issue
Block a user