File indexing completed on 2024-04-14 15:17:41
0001 /*************************************************************************** 0002 latexcmd.h 0003 ---------- 0004 date : Jul 25 2005 0005 version : 0.20 0006 copyright : (C) 2005 by Holger Danielsson 0007 email : holger.danielsson@t-online.de 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 // kommandos mit weiteren Parametern 0020 0021 #ifndef LATEXCMD_H 0022 #define LATEXCMD_H 0023 0024 #include <QObject> 0025 #include <QStringList> 0026 #include <QMap> 0027 0028 #include <kconfig.h> 0029 0030 class KileInfo; 0031 0032 namespace KileDocument 0033 { 0034 0035 const int MaxEnvAttr = 8; 0036 const int MaxCmdAttr = 5; 0037 0038 enum CmdAttribute { 0039 CmdAttrNone = 0, // unknown 0040 CmdAttrAmsmath = 1, CmdAttrMath = 2, CmdAttrList = 4, CmdAttrTabular = 8, CmdAttrVerbatim = 16, // environments 0041 CmdAttrLabel = 32, CmdAttrReference = 64, CmdAttrCitations = 128, CmdAttrIncludes = 256, // commands 0042 CmdAttrBibliographies = 512 //commands - continue 0043 }; 0044 0045 class LatexCmdAttributes 0046 { 0047 public: 0048 bool standard; 0049 CmdAttribute type; 0050 bool starred; 0051 bool cr; 0052 bool mathmode; 0053 bool displaymathmode; 0054 QString tabulator; 0055 QString option; 0056 QString parameter; 0057 }; 0058 0059 class LatexCommands : public QObject 0060 { 0061 Q_OBJECT 0062 0063 public: 0064 LatexCommands(KConfig *config, KileInfo *info); 0065 ~LatexCommands() {}; 0066 0067 QString envGroupName() { 0068 return m_envGroupName; 0069 } 0070 QString cmdGroupName() { 0071 return m_cmdGroupName; 0072 } 0073 QString configString(const LatexCmdAttributes &attr,bool env); 0074 0075 bool isMathEnv(const QString &name); 0076 bool isListEnv(const QString &name) { 0077 return isType(name,'l'); 0078 } 0079 bool isTabularEnv(const QString &name) { 0080 return isType(name,'t'); 0081 } 0082 bool isVerbatimEnv(const QString &name) { 0083 return isType(name,'v'); 0084 } 0085 0086 bool isLabelCmd(const QString &name) { 0087 return isType(name,'L'); 0088 } 0089 bool isReferenceCmd(const QString &name) { 0090 return isType(name,'R'); 0091 } 0092 bool isCitationCmd(const QString &name) { 0093 return isType(name,'C'); 0094 } 0095 bool isInputCmd(const QString &name) { 0096 return isType(name,'I'); 0097 } 0098 0099 bool isStarredEnv(const QString &name); 0100 bool isCrEnv(const QString &name); 0101 bool isMathModeEnv(const QString &name); 0102 bool isDisplaymathModeEnv(const QString &name); 0103 bool needsMathMode(const QString &name); 0104 QString getTabulator(const QString &name); 0105 0106 void commandList(QStringList &list, uint attr, bool userdefined); 0107 bool commandAttributes(const QString &name, LatexCmdAttributes &attr); 0108 0109 void resetCommands(); 0110 0111 private: 0112 0113 KConfig *m_config; 0114 KileInfo *m_ki; 0115 0116 QString m_envGroupName, m_cmdGroupName; 0117 QMap<QString,QString> m_latexCommands; 0118 0119 void addUserCommands(const QString &name, QStringList &list); 0120 void insert(const QStringList &list); 0121 0122 QString getValue(const QString &name); 0123 0124 0125 bool isUserDefined(const QString &name); 0126 bool isType(const QString &name, QChar ch); 0127 QString getAttrAt(const QString &name, int index); 0128 QChar getAttrChar(CmdAttribute attr); 0129 CmdAttribute getCharAttr(QChar ch); 0130 0131 }; 0132 0133 0134 } 0135 0136 #endif