]> git.lyx.org Git - features.git/commitdiff
simplify Lexer use a bit
authorAndré Pönitz <poenitz@gmx.net>
Wed, 2 Apr 2008 22:14:45 +0000 (22:14 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 2 Apr 2008 22:14:45 +0000 (22:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24098 a592a061-630c-0410-9148-cb99ea01b6c8

49 files changed:
src/Buffer.cpp
src/CmdDef.cpp
src/ConverterCache.cpp
src/Encoding.cpp
src/Font.cpp
src/KeyMap.cpp
src/LaTeXFeatures.cpp
src/Language.cpp
src/Layout.cpp
src/LayoutFile.cpp
src/Lexer.cpp
src/Lexer.h
src/LyX.cpp
src/LyXFunc.cpp
src/LyXRC.cpp
src/Makefile.am
src/ModuleList.cpp
src/ParagraphParameters.cpp
src/Text.cpp
src/Text3.cpp
src/TextClass.cpp
src/ToolbarBackend.cpp
src/Trans.cpp
src/frontends/qt4/GuiLog.cpp
src/frontends/qt4/Menus.cpp
src/insets/ExternalTemplate.cpp
src/insets/InsetBox.cpp
src/insets/InsetBranch.cpp
src/insets/InsetCommand.cpp
src/insets/InsetERT.cpp
src/insets/InsetExternal.cpp
src/insets/InsetFloat.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetLayout.cpp
src/insets/InsetListings.cpp
src/insets/InsetNewline.cpp
src/insets/InsetNewpage.cpp
src/insets/InsetNote.cpp
src/insets/InsetSpace.cpp
src/insets/InsetTabular.cpp
src/insets/InsetVSpace.cpp
src/insets/InsetWrap.cpp
src/lyxled/LayoutEditor.cpp [new file with mode: 0644]
src/lyxled/LayoutEditor.h [new file with mode: 0644]
src/lyxled/Makefile.am [new file with mode: 0644]
src/lyxled/lyxled.pro [new file with mode: 0644]
src/lyxled/main.cpp [new file with mode: 0644]
src/lyxled/ui/MainWindowUi.ui [new file with mode: 0644]
src/mathed/MathParser.cpp

index 9994d3ade6cab325645cf91b8faa974a1d06060e..5f4fd995df57aee62e96d3d2974176008aafe42e 100644 (file)
@@ -657,7 +657,7 @@ bool Buffer::readString(string const & s)
 
        // remove dummy empty par
        paragraphs().clear();
-       Lexer lex(0, 0);
+       Lexer lex;
        istringstream is(s);
        lex.setStream(is);
        FileName const name = FileName::tempName();
@@ -705,7 +705,7 @@ bool Buffer::readFile(FileName const & filename)
 
        // remove dummy empty par
        paragraphs().clear();
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setFile(fname);
        if (readFile(lex, fname) != success)
                return false;
index f04a8d907db684deecd4dcd448cc98400eedb87d..2a3158c3dd9d2c2c7ea2e25fb96356b688df2eb0 100644 (file)
@@ -35,7 +35,7 @@ enum CmdDefTags {
        BN_DEFINE
 };
 
-keyword_item cmdDefTags[] = {
+LexerKeyword cmdDefTags[] = {
        { "\\def_file", BN_DEFFILE },
        { "\\define", BN_DEFINE }
 };
@@ -45,9 +45,7 @@ keyword_item cmdDefTags[] = {
 
 bool CmdDef::read(string const & def_file)
 {
-       const int cmdDefCount = sizeof(cmdDefTags) / sizeof(keyword_item);
-
-       Lexer lexrc(cmdDefTags, cmdDefCount);
+       Lexer lexrc(cmdDefTags);
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
 
index 972746df162fb6a433f12a3d7fe0bd05080e88b0..2f0a946fd32a212deef34b73091ca2cf2ea6ce4b 100644 (file)
@@ -107,7 +107,7 @@ void ConverterCache::Impl::readIndex()
        time_t const now = current_time();
        FileName const index(addName(cache_dir.absFilename(), "index"));
        ifstream is(index.toFilesystemEncoding().c_str());
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setStream(is);
        while (lex.isOK()) {
                if (!lex.next(true))
index 3aa31d0099ab9a771afa860f54b42203706677cf..5812410357858bd2753dd641929976c1e39466af 100644 (file)
@@ -467,7 +467,7 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
 {
        // We must read the symbolsfile first, because the Encoding
        // constructor depends on it.
-       Lexer symbolslex(0, 0);
+       Lexer symbolslex;
        symbolslex.setFile(symbolsfile);
        while (symbolslex.isOK()) {
                char_type symbol;
@@ -525,15 +525,14 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
        enum Encodingtags {
                et_encoding = 1,
                et_end,
-               et_last
        };
 
-       struct keyword_item encodingtags[et_last - 1] = {
+       struct LexerKeyword encodingtags[] = {
                { "encoding", et_encoding },
                { "end", et_end }
        };
 
-       Lexer lex(encodingtags, et_last - 1);
+       Lexer lex(encodingtags);
        lex.setFile(encfile);
        while (lex.isOK()) {
                switch (lex.lex()) {
index 94549dac3938fa4ff0d6c301a137bea6468bb783..7a9849b8298d1b3d1550918e06abf5941eb3f5f8 100644 (file)
@@ -664,7 +664,7 @@ string Font::toString(bool const toggle) const
 bool Font::fromString(string const & data, bool & toggle)
 {
        istringstream is(data);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(is);
 
        int nset = 0;
index d1c7040c7d0c83dfe8fa491a20edd3392910386a..847f98c23b5f21d04a6bbadf188bd99c51ac3cf9 100644 (file)
@@ -125,7 +125,7 @@ enum BindTags {
        BN_UNBIND,
 };
 
-keyword_item bindTags[] = {
+LexerKeyword bindTags[] = {
        { "\\bind", BN_BIND },
        { "\\bind_file", BN_BINDFILE },
        { "\\unbind", BN_UNBIND },
@@ -136,9 +136,7 @@ keyword_item bindTags[] = {
 
 bool KeyMap::read(string const & bind_file, KeyMap * unbind_map)
 {
-       const int bindCount = sizeof(bindTags) / sizeof(keyword_item);
-
-       Lexer lexrc(bindTags, bindCount);
+       Lexer lexrc(bindTags);
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
 
index 641e99eb7db1576a4154f769a1a8f7865ad90b03..a6ce6c3391b03c5fe1a615c71bf9dce0596d7a16 100644 (file)
@@ -237,7 +237,7 @@ void LaTeXFeatures::require(set<string> const & names)
 
 void LaTeXFeatures::getAvailable()
 {
-       Lexer lex(0, 0);
+       Lexer lex;
        support::FileName const real_file = libFileSearch("", "packages.lst");
 
        if (real_file.empty())
index 59694b9c508c678b51be40f548c0fdc74260c4b1..ce5b2367777f1b3a78234f68a60f8da9ca72c653 100644 (file)
@@ -45,7 +45,7 @@ void Languages::read(FileName const & filename)
                              encodings.fromLyXName("iso8859-1"),
                              "latex", "");
 
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setFile(filename);
        while (lex.isOK()) {
                string lang;
index e368f23bbda0e821d3928b0f58538e5290a9e577..05efa9c38713959f12013061090443b696edaeb3 100644 (file)
@@ -134,7 +134,7 @@ Layout::Layout()
 bool Layout::read(Lexer & lexrc, TextClass const & tclass)
 {
        // This table is sorted alphabetically [asierra 30March96]
-       keyword_item layoutTags[] = {
+       LexerKeyword layoutTags[] = {
                { "align",          LT_ALIGN },
                { "alignpossible",  LT_ALIGNPOSSIBLE },
                { "bottomsep",      LT_BOTTOMSEP },
@@ -191,7 +191,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
 
        bool error = false;
        bool finished = false;
-       lexrc.pushTable(layoutTags, LT_INTITLE);
+       lexrc.pushTable(layoutTags);
        // parse style section
        while (!finished && lexrc.isOK() && !error) {
                int le = lexrc.lex();
@@ -515,7 +515,7 @@ enum AlignTags {
 
 void Layout::readAlign(Lexer & lexrc)
 {
-       keyword_item alignTags[] = {
+       LexerKeyword alignTags[] = {
                { "block",  AT_BLOCK },
                { "center", AT_CENTER },
                { "layout", AT_LAYOUT },
@@ -553,7 +553,7 @@ void Layout::readAlign(Lexer & lexrc)
 
 void Layout::readAlignPossible(Lexer & lexrc)
 {
-       keyword_item alignTags[] = {
+       LexerKeyword alignTags[] = {
                { "block",  AT_BLOCK },
                { "center", AT_CENTER },
                { "layout", AT_LAYOUT },
@@ -561,9 +561,9 @@ void Layout::readAlignPossible(Lexer & lexrc)
                { "right",  AT_RIGHT }
        };
 
-       lexrc.pushTable(alignTags, AT_LAYOUT);
+       lexrc.pushTable(alignTags);
        alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
-       int lineno = lexrc.getLineNo();
+       int lineno = lexrc.lineNumber();
        do {
                int le = lexrc.lex();
                switch (le) {
@@ -589,7 +589,7 @@ void Layout::readAlignPossible(Lexer & lexrc)
                        alignpossible |= LYX_ALIGN_LAYOUT;
                        break;
                }
-       } while (lineno == lexrc.getLineNo());
+       } while (lineno == lexrc.lineNumber());
        lexrc.popTable();
 }
 
@@ -610,7 +610,7 @@ enum LabelTypeTags {
 
 void Layout::readLabelType(Lexer & lexrc)
 {
-       keyword_item labelTypeTags[] = {
+       LexerKeyword labelTypeTags[] = {
        { "bibliography",             LA_BIBLIO },
        { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
        { "counter",                  LA_COUNTER },
@@ -666,7 +666,7 @@ void Layout::readLabelType(Lexer & lexrc)
 }
 
 
-static keyword_item endlabelTypeTags[] =
+static LexerKeyword endlabelTypeTags[] =
 {
        { "box",        END_LABEL_BOX },
        { "filled_box", END_LABEL_FILLED_BOX },
@@ -700,7 +700,7 @@ void Layout::readEndLabelType(Lexer & lexrc)
 
 void Layout::readMargin(Lexer & lexrc)
 {
-       keyword_item marginTags[] = {
+       LexerKeyword marginTags[] = {
                { "dynamic",           MARGIN_DYNAMIC },
                { "first_dynamic",     MARGIN_FIRST_DYNAMIC },
                { "manual",            MARGIN_MANUAL },
@@ -732,7 +732,7 @@ void Layout::readMargin(Lexer & lexrc)
 
 void Layout::readLatexType(Lexer & lexrc)
 {
-       keyword_item latexTypeTags[] = {
+       LexerKeyword latexTypeTags[] = {
                { "bib_environment",  LATEX_BIB_ENVIRONMENT },
                { "command",          LATEX_COMMAND },
                { "environment",      LATEX_ENVIRONMENT },
@@ -773,7 +773,7 @@ enum SpacingTags {
 
 void Layout::readSpacing(Lexer & lexrc)
 {
-       keyword_item spacingTags[] = {
+       LexerKeyword spacingTags[] = {
                {"double",  ST_SPACING_DOUBLE },
                {"onehalf", ST_SPACING_ONEHALF },
                {"other",   ST_OTHER },
index 0680f33f02386d153a33798675131f5fe4b012eb..42b74fc62bb145727baf93760bbb5e00b7abed4f 100644 (file)
@@ -84,7 +84,7 @@ LayoutFile &
 // Reads LyX textclass definitions according to textclass config file
 bool LayoutFileList::read()
 {
-       Lexer lex(0, 0);
+       Lexer lex;
        FileName const real_file = libFileSearch("", "textclass.lst");
        LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\'');
 
index fd9a1f362c302ce3460d7a2f076a6ab5c05c685b..530e4f12f041e72ebe24a927b74e15845b03d1d0 100644 (file)
@@ -45,7 +45,7 @@ namespace lyx {
 class Lexer::Pimpl {
 public:
        ///
-       Pimpl(keyword_item * tab, int num);
+       Pimpl(LexerKeyword * tab, int num);
        ///
        string const getString() const;
        ///
@@ -55,7 +55,7 @@ public:
        ///
        void printTable(ostream & os);
        ///
-       void pushTable(keyword_item * tab, int num);
+       void pushTable(LexerKeyword * tab, int num);
        ///
        void popTable();
        ///
@@ -89,7 +89,7 @@ public:
        ///
        string name;
        ///
-       keyword_item * table;
+       LexerKeyword * table;
        ///
        int no_items;
        ///
@@ -116,10 +116,10 @@ private:
                PushedTable()
                        : table_elem(0), table_siz(0) {}
                ///
-               PushedTable(keyword_item * ki, int siz)
+               PushedTable(LexerKeyword * ki, int siz)
                        : table_elem(ki), table_siz(siz) {}
                ///
-               keyword_item * table_elem;
+               LexerKeyword * table_elem;
                ///
                int table_siz;
        };
@@ -132,10 +132,10 @@ private:
 namespace {
 
 class CompareTags
-       : public binary_function<keyword_item, keyword_item, bool> {
+       : public binary_function<LexerKeyword, LexerKeyword, bool> {
 public:
        // used by lower_bound, sort and sorted
-       bool operator()(keyword_item const & a, keyword_item const & b) const
+       bool operator()(LexerKeyword const & a, LexerKeyword const & b) const
        {
                // we use the ascii version, because in turkish, 'i'
                // is not the lowercase version of 'I', and thus
@@ -147,7 +147,7 @@ public:
 } // end of anon namespace
 
 
-Lexer::Pimpl::Pimpl(keyword_item * tab, int num)
+Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num)
        : is(&fb_), table(tab), no_items(num),
          status(0), lineno(0), commentChar('#')
 {
@@ -204,7 +204,7 @@ void Lexer::Pimpl::verifyTable()
 }
 
 
-void Lexer::Pimpl::pushTable(keyword_item * tab, int num)
+void Lexer::Pimpl::pushTable(LexerKeyword * tab, int num)
 {
        PushedTable tmppu(table, no_items);
        pushed.push(tmppu);
@@ -482,8 +482,8 @@ bool Lexer::Pimpl::next(bool esc /* = false */)
 
 int Lexer::Pimpl::search_kw(char const * const tag) const
 {
-       keyword_item search_tag = { tag, 0 };
-       keyword_item * res =
+       LexerKeyword search_tag = { tag, 0 };
+       LexerKeyword * res =
                lower_bound(table, table + no_items,
                            search_tag, CompareTags());
        // use the compare_ascii_no_case instead of compare_no_case,
@@ -611,11 +611,17 @@ void Lexer::Pimpl::pushToken(string const & pt)
 //
 //////////////////////////////////////////////////////////////////////
 
-Lexer::Lexer(keyword_item * tab, int num)
-       : pimpl_(new Pimpl(tab, num))
+Lexer::Lexer()
+       : pimpl_(new Pimpl(0, 0))
 {}
 
 
+void Lexer::init(LexerKeyword * tab, int num)
+{
+        pimpl_ = new Pimpl(tab, num);
+}
+
+
 Lexer::~Lexer()
 {
        delete pimpl_;
@@ -628,13 +634,13 @@ bool Lexer::isOK() const
 }
 
 
-void Lexer::setLineNo(int l)
+void Lexer::setLineNumber(int l)
 {
        pimpl_->lineno = l;
 }
 
 
-int Lexer::getLineNo() const
+int Lexer::lineNumber() const
 {
        return pimpl_->lineno;
 }
@@ -646,7 +652,7 @@ istream & Lexer::getStream()
 }
 
 
-void Lexer::pushTable(keyword_item * tab, int num)
+void Lexer::pushTable(LexerKeyword * tab, int num)
 {
        pimpl_->pushTable(tab, num);
 }
index 46355905b4c7a32f7aa7b97fa99c95015ae088b9..c537eabfec1d099a53c2ab2263e59834b7430ff9 100644 (file)
@@ -24,14 +24,21 @@ namespace lyx {
 
 namespace support { class FileName; }
 
-///
-struct keyword_item {
-       ///
+class PushPopHelper;
+
+/** A helper structure to describe a keyword for the Lexer.
+       Usually used bundled in C style arrays and passed to the 
+       Lexer using a LexerKeywordTable object.
+*/
+struct LexerKeyword
+{
+       /// the string to be recognized
        char const * tag;
-       ///
+       /// a corresponding numerical id
        int code;
 };
 
+
 /** Generalized simple lexical analizer.
        Use the method isOK() to check if there is still data available
        for lexing. Use one of the the operators void* or ! to test if
@@ -53,10 +60,15 @@ struct keyword_item {
 
     @see LyXRC.cpp for an example of usage.
   */
-class Lexer {
+class Lexer
+{
 public:
-       ///
-       Lexer(keyword_item *, int);
+       /// initialize Lexer with no special keywords.
+       Lexer(); 
+       /// initialize Lexer with a bunch of keywords
+       template<int N> Lexer(LexerKeyword (&table)[N])
+               : pimpl_(0) { init(table, N); }
+
        ///
        ~Lexer();
 
@@ -73,7 +85,7 @@ public:
        };
 
        /// stream is open and end of stream is not reached
-       /// FIXME: test also if pushTok is not empty
+       /// FIXME: test also if pushToken is not empty
        /// FIXME: the method should be renamed to something like
        ///        dataAvailable(), in order to reflect the real behavior
        bool isOK() const;
@@ -91,7 +103,7 @@ public:
        ///
        std::istream & getStream();
        /// Danger! Don't use it unless you know what you are doing.
-       void setLineNo(int l);
+       void setLineNumber(int l);
        /// Change the character that begins a comment. Default is '#'
        void setCommentChar(char c);
 
@@ -111,8 +123,8 @@ public:
        /// Push a token, that next token got from lyxlex.
        void pushToken(std::string const &);
 
-       ///
-       int getLineNo() const;
+       /// return the current line number
+       int lineNumber() const;
 
        ///
        int getInteger() const;
@@ -139,7 +151,8 @@ public:
        bool eatLine();
 
        /// Pushes a token list on a stack and replaces it with a new one.
-       void pushTable(keyword_item *, int);
+       template<int N> void pushTable(LexerKeyword (&table)[N])
+               { pushTable(table, N); }
 
        /** Pops a token list into void and replaces it with the one now
            on top of the stack.
@@ -173,10 +186,17 @@ public:
        static std::string const quoteString(std::string const &);
 
 private:
-       /// noncopiable
+       /// noncopyable
        Lexer(Lexer const &);
        void operator=(Lexer const &);
 
+       ///
+       friend class PushPopHelper;
+
+       ///
+       void init(LexerKeyword *, int);
+       void pushTable(LexerKeyword *, int);
+
        ///
        class Pimpl;
        ///
@@ -192,14 +212,18 @@ private:
     exceptions.
     @author Lgb
 */
-class PushPopHelper {
+class PushPopHelper
+{
 public:
        ///
-       PushPopHelper(Lexer & lexrc, keyword_item * i, int s) : lex(lexrc) {
+       PushPopHelper(Lexer & lexrc, LexerKeyword * i, int s)
+               : lex(lexrc)
+       {
                lex.pushTable(i, s);
        }
        ///
-       ~PushPopHelper() {
+       ~PushPopHelper()
+       {
                lex.popTable();
        }
        ///
index 552b51181b8da3f501dd619a86712ea862efb4dd..7dc438a5c8fe4d75e04383d027635aef03741c83 100644 (file)
@@ -979,7 +979,7 @@ bool LyX::readRcFile(string const & name)
 // Read the ui file `name'
 bool LyX::readUIFile(string const & name, bool include)
 {
-       enum Uitags {
+       enum {
                ui_menuset = 1,
                ui_toolbars,
                ui_toolbarset,
@@ -987,7 +987,7 @@ bool LyX::readUIFile(string const & name, bool include)
                ui_last
        };
 
-       struct keyword_item uitags[ui_last - 1] = {
+       struct LexerKeyword uitags[] = {
                { "include", ui_include },
                { "menuset", ui_menuset },
                { "toolbars", ui_toolbars },
@@ -1027,7 +1027,7 @@ bool LyX::readUIFile(string const & name, bool include)
        uifiles.push_back(name);
 
        LYXERR(Debug::INIT, "Found " << name << " in " << ui_path);
-       Lexer lex(uitags, ui_last - 1);
+       Lexer lex(uitags);
        lex.setFile(ui_path);
        if (!lex.isOK()) {
                lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
index 4804728f981a498316868539bb3565730d3366f6..2b5be3b4da27c3fae8913c587c90d2c344d619c3 100644 (file)
@@ -1487,7 +1487,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        Buffer defaults(fname);
 
                        istringstream ss(argument);
-                       Lexer lex(0,0);
+                       Lexer lex;
                        lex.setStream(ss);
                        int const unknown_tokens = defaults.readHeader(lex);
 
@@ -1515,7 +1515,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        cur.recordUndoFullDocument();
                        
                        istringstream ss(argument);
-                       Lexer lex(0,0);
+                       Lexer lex;
                        lex.setStream(ss);
                        int const unknown_tokens = buffer->readHeader(lex);
 
index 28ce4cfaafca2ada71c642e6a1e2d1eb52fc8992..2a189d8b72464308b9d96d05dabbd0e4a0457825 100644 (file)
@@ -50,7 +50,7 @@ namespace os = support::os;
 namespace {
 
 // when adding something to this array keep it sorted!
-keyword_item lyxrcTags[] = {
+LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
        { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
        { "\\alternate_language", LyXRC::RC_ALT_LANG },
@@ -184,7 +184,7 @@ keyword_item lyxrcTags[] = {
        { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
 };
 
-const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
+const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
 
 } // namespace anon
 
@@ -334,7 +334,7 @@ void oldFontFormat(string & family, string & foundry)
 
 int LyXRC::read(FileName const & filename)
 {
-       Lexer lexrc(lyxrcTags, lyxrcCount);
+       Lexer lexrc(lyxrcTags);
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
 
@@ -349,7 +349,7 @@ int LyXRC::read(FileName const & filename)
 
 int LyXRC::read(istream & is)
 {
-       Lexer lexrc(lyxrcTags, lyxrcCount);
+       Lexer lexrc(lyxrcTags);
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
 
index 4826fe822636055376842d590907ce548c94e6e5..3ee351240f6fe339eafc61f3a87a0b2eca4e14f3 100644 (file)
@@ -8,7 +8,7 @@ MAINTAINERCLEANFILES += $(srcdir)/config.h.in
 
 AM_CPPFLAGS += $(PCH_FLAGS) -I$(top_srcdir)/src $(BOOST_INCLUDES)
 
-SUBDIRS = support frontends tex2lyx client .
+SUBDIRS = support frontends tex2lyx client lyxled .
 
 EXTRA_DIST = config.h.in \
        Section.h \
index 14e2917159bddeeea7fb184ad714221ed823c6a5..b22f48d8e62972c51b9027afa7c1f7b27108a9bd 100644 (file)
@@ -90,7 +90,7 @@ bool ModuleList::load()
                return false;
        }
 
-       Lexer lex(0, 0);
+       Lexer lex;
        if (!lex.setFile(real_file)) {
                lyxerr << "ModuleList::load():"
                                "lyxlex was not able to set file: "
index 00b990c7c9414a3ebce731c03e044dad233afd21..88dd6c69990e5f7ddb19df9c2a04beb84ac139b2 100644 (file)
@@ -172,7 +172,7 @@ void ParagraphParameters::leftIndent(Length const & li)
 void ParagraphParameters::read(string str, bool merge)
 {
        istringstream is(str);
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setStream(is);
        read(lex, merge);
 }
index 8b7457108de3a337874d9f052424b36594cabb8a..48d34f76c0a6cdc57d80f8448630041d63df277b 100644 (file)
@@ -135,10 +135,10 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                par.params().read(lex);
 
        } else if (token == "\\end_layout") {
-               LYXERR0("Solitary \\end_layout in line " << lex.getLineNo() << "\n"
+               LYXERR0("Solitary \\end_layout in line " << lex.lineNumber() << "\n"
                       << "Missing \\begin_layout ?");
        } else if (token == "\\end_inset") {
-               LYXERR0("Solitary \\end_inset in line " << lex.getLineNo() << "\n"
+               LYXERR0("Solitary \\end_inset in line " << lex.lineNumber() << "\n"
                       << "Missing \\begin_inset ?");
        } else if (token == "\\begin_inset") {
                Inset * inset = readInset(lex, buf);
@@ -277,7 +277,7 @@ void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex,
                    || token == "\\end_deeper") {
                        lex.pushToken(token);
                        lyxerr << "Paragraph ended in line "
-                              << lex.getLineNo() << "\n"
+                              << lex.lineNumber() << "\n"
                               << "Missing \\end_layout.\n";
                        break;
                }
index 17b86373236de81b595e899cc200599cb1a34502..28ae7995fa5cd9bdca5ec8ad9c442498cd2716f3 100644 (file)
@@ -154,7 +154,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
                {
                        InsetMathHull * formula = new InsetMathHull;
                        istringstream is(to_utf8(sel));
-                       Lexer lex(0, 0);
+                       Lexer lex;
                        lex.setStream(is);
                        formula->read(lex);
                        if (formula->getType() == hullNone)
index 3c2afbce3f93c267041c37ee55c9370ec4c0a206..2d79a2b75528d5b9b270c40057afd6974a4762af 100644 (file)
@@ -183,7 +183,7 @@ enum TextClassTags {
 
 namespace {
 
-       keyword_item textClassTags[] = {
+       LexerKeyword textClassTags[] = {
                { "addtopreamble",   TC_ADDTOPREAMBLE },
                { "classoptions",    TC_CLASSOPTIONS },
                { "columns",         TC_COLUMNS },
@@ -249,7 +249,7 @@ bool TextClass::read(FileName const & filename, ReadType rt)
                        "LabelType No_Label\n"
                        "End";
                istringstream ss(s);
-               Lexer lex(textClassTags, sizeof(textClassTags) / sizeof(textClassTags[0]));
+               Lexer lex(textClassTags);
                lex.setStream(ss);
                Layout lay;
                lay.setName(emptylayout_);
@@ -260,9 +260,8 @@ bool TextClass::read(FileName const & filename, ReadType rt)
                };
                layoutlist_.push_back(lay);
        }
-       Lexer lexrc(textClassTags,
-               sizeof(textClassTags) / sizeof(textClassTags[0]));
 
+       Lexer lexrc(textClassTags);
        lexrc.setFile(filename);
        ReturnValues retval = read(lexrc, rt);
        
@@ -291,8 +290,7 @@ bool TextClass::validate(std::string const & str)
 
 bool TextClass::read(std::string const & str, ReadType rt) 
 {
-       Lexer lexrc(textClassTags,
-               sizeof(textClassTags) / sizeof(textClassTags[0]));
+       Lexer lexrc(textClassTags);
        istringstream is(str);
        lexrc.setStream(is);
        ReturnValues retval = read(lexrc, rt);
@@ -622,7 +620,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
 
 void TextClass::readTitleType(Lexer & lexrc)
 {
-       keyword_item titleTypeTags[] = {
+       LexerKeyword titleTypeTags[] = {
                { "commandafter", TITLE_COMMAND_AFTER },
                { "environment", TITLE_ENVIRONMENT }
        };
@@ -649,7 +647,7 @@ void TextClass::readTitleType(Lexer & lexrc)
 
 void TextClass::readOutputType(Lexer & lexrc)
 {
-       keyword_item outputTypeTags[] = {
+       LexerKeyword outputTypeTags[] = {
                { "docbook", DOCBOOK },
                { "latex", LATEX },
                { "literate", LITERATE }
@@ -687,7 +685,7 @@ enum ClassOptionsTags {
 
 void TextClass::readClassOptions(Lexer & lexrc)
 {
-       keyword_item classOptionsTags[] = {
+       LexerKeyword classOptionsTags[] = {
                {"end", CO_END },
                {"fontsize", CO_FONTSIZE },
                {"header", CO_HEADER },
@@ -695,7 +693,7 @@ void TextClass::readClassOptions(Lexer & lexrc)
                {"pagestyle", CO_PAGESTYLE }
        };
 
-       lexrc.pushTable(classOptionsTags, CO_END);
+       lexrc.pushTable(classOptionsTags);
        bool getout = false;
        while (!getout && lexrc.isOK()) {
                int le = lexrc.lex();
@@ -746,7 +744,7 @@ enum FloatTags {
 
 void TextClass::readFloat(Lexer & lexrc)
 {
-       keyword_item floatTags[] = {
+       LexerKeyword floatTags[] = {
                { "end", FT_END },
                { "extension", FT_EXT },
                { "guiname", FT_NAME },
@@ -758,7 +756,7 @@ void TextClass::readFloat(Lexer & lexrc)
                { "type", FT_TYPE }
        };
 
-       lexrc.pushTable(floatTags, FT_END);
+       lexrc.pushTable(floatTags);
 
        string type;
        string placement;
@@ -858,7 +856,7 @@ enum CounterTags {
 
 void TextClass::readCounter(Lexer & lexrc)
 {
-       keyword_item counterTags[] = {
+       LexerKeyword counterTags[] = {
                { "end", CT_END },
                { "labelstring", CT_LABELSTRING },
                { "labelstringappendix", CT_LABELSTRING_APPENDIX },
@@ -866,7 +864,7 @@ void TextClass::readCounter(Lexer & lexrc)
                { "within", CT_WITHIN }
        };
 
-       lexrc.pushTable(counterTags, CT_END);
+       lexrc.pushTable(counterTags);
 
        docstring name;
        docstring within;
index a406cb48ab25691453095343bb5f001bdf0874a6..419f0518f4008bf2e39b41078d1a4c8a2fa53fa7 100644 (file)
@@ -49,6 +49,12 @@ private:
 ToolbarBackend toolbarbackend;
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ToolbarItem
+//
+/////////////////////////////////////////////////////////////////////////
+
 ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
        : type_(type), func_(func), label_(label)
 {
@@ -74,7 +80,7 @@ void ToolbarInfo::add(ToolbarItem const & item)
 
 ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 {
-       enum tooltags {
+       enum {
                TO_COMMAND = 1,
                TO_ENDTOOLBAR,
                TO_SEPARATOR,
@@ -83,10 +89,9 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                TO_TABLEINSERT,
                TO_POPUPMENU,
                TO_ICONPALETTE,
-               TO_LAST
        };
 
-       struct keyword_item toolTags[TO_LAST - 1] = {
+       struct LexerKeyword toolTags[] = {
                { "end", TO_ENDTOOLBAR },
                { "iconpalette", TO_ICONPALETTE },
                { "item", TO_COMMAND },
@@ -118,7 +123,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
        bool quit = false;
 
-       lex.pushTable(toolTags, TO_LAST - 1);
+       lex.pushTable(toolTags);
 
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
@@ -197,6 +202,12 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ToolbarBackend
+//
+/////////////////////////////////////////////////////////////////////////
+
 
 ToolbarBackend::ToolbarBackend()
 {
@@ -206,13 +217,12 @@ ToolbarBackend::ToolbarBackend()
 
 void ToolbarBackend::readToolbars(Lexer & lex)
 {
-       enum tooltags {
+       enum {
                TO_TOOLBAR = 1,
                TO_ENDTOOLBARSET,
-               TO_LAST
        };
 
-       struct keyword_item toolTags[TO_LAST - 1] = {
+       struct LexerKeyword toolTags[] = {
                { "end", TO_ENDTOOLBARSET },
                { "toolbar", TO_TOOLBAR }
        };
@@ -223,7 +233,7 @@ void ToolbarBackend::readToolbars(Lexer & lex)
                       << lex.getString() << '\'');
        }
 
-       lex.pushTable(toolTags, TO_LAST - 1);
+       lex.pushTable(toolTags);
 
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
index 241a9c958e232064977a86365acb6c4b6084fd0a..2c25db7039b842c791655b31ca85d4f32d1ca406 100644 (file)
@@ -169,20 +169,11 @@ bool Trans::isDefined() const
 }
 
 
-enum kmaptags_ {
+enum {
        KCOMB = 1,
        KMOD,
        KMAP,
        KXMOD,
-       K_LAST
-};
-
-
-struct keyword_item kmapTags[K_LAST - 1] = {
-       {"\\kcomb", KCOMB },
-       { "\\kmap", KMAP },
-       { "\\kmod", KMOD },
-       { "\\kxmod", KXMOD }
 };
 
 
@@ -387,12 +378,19 @@ docstring const Trans::process(char_type c, TransManager & k)
 
 int Trans::load(string const & language)
 {
+       struct LexerKeyword kmapTags[] = {
+               {"\\kcomb", KCOMB },
+               { "\\kmap", KMAP },
+               { "\\kmod", KMOD },
+               { "\\kxmod", KXMOD }
+       };
+
        FileName const filename = libFileSearch("kbd", language, "kmap");
        if (filename.empty())
                return -1;
 
        freeKeymap();
-       Lexer lex(kmapTags, K_LAST - 1);
+       Lexer lex(kmapTags);
        lex.setFile(filename);
 
        int const res = load(lex);
index a02544dda085eef396505ca1b3f3f8d210fddc50..f415c9af09694112778f7cbd59f3195f3b987426 100644 (file)
@@ -133,7 +133,7 @@ void GuiLog::updateContents()
 bool GuiLog::initialiseParams(string const & data)
 {
        istringstream is(data);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(is);
 
        string logtype, logfile;
index 4496ff744cde32eafba840685e2133df014bb685..7867d4a1e9f3530941c28f4939278f0a3a1386e1 100644 (file)
@@ -379,11 +379,10 @@ void MenuDefinition::read(Lexer & lex)
                md_floatlistinsert,
                md_floatinsert,
                md_pasterecent,
-               md_toolbars,
-               md_last
+               md_toolbars
        };
 
-       struct keyword_item menutags[md_last - 1] = {
+       struct LexerKeyword menutags[] = {
                { "bookmarks", md_bookmarks },
                { "branches", md_branches },
                { "charstyles", md_charstyles },
@@ -408,7 +407,7 @@ void MenuDefinition::read(Lexer & lex)
                { "viewformats", md_viewformats }
        };
 
-       lex.pushTable(menutags, md_last - 1);
+       lex.pushTable(menutags);
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
 
@@ -1274,8 +1273,8 @@ void Menus::Impl::macxMenuBarInit(GuiView * view, QMenuBar * qmb)
 }
 
 
-void Menus::Impl::expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
-                        Buffer const * buf) const
+void Menus::Impl::expand(MenuDefinition const & frommenu,
+       MenuDefinition & tomenu, Buffer const * buf) const
 {
        if (!tomenu.empty())
                tomenu.clear();
@@ -1393,23 +1392,25 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
        return (*it);
 }
 
+
 /////////////////////////////////////////////////////////////////////
-// Menus implementation
+//
+// Menus 
+//
 /////////////////////////////////////////////////////////////////////
 
-Menus::Menus(): d(new Impl) {}
+Menus::Menus() : d(new Impl) {}
 
 
 void Menus::read(Lexer & lex)
 {
        enum Menutags {
-               md_menu = 1,
+               md_menu,
                md_menubar,
                md_endmenuset,
-               md_last
        };
 
-       struct keyword_item menutags[md_last - 1] = {
+       struct LexerKeyword menutags[] = {
                { "end", md_endmenuset },
                { "menu", md_menu },
                { "menubar", md_menubar }
@@ -1421,7 +1422,7 @@ void Menus::read(Lexer & lex)
                       << lex.getString() << '\'' << endl;
        }
 
-       lex.pushTable(menutags, md_last - 1);
+       lex.pushTable(menutags);
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
 
index f3884f91d6acf8d5237420bd91e4b10ad6074f73..73a115484d575bf25b8ced646626570f13e3cab5 100644 (file)
@@ -236,21 +236,21 @@ void TemplateManager::readTemplates(FileName const & path)
 {
        PathChanger p(path);
 
-       enum TemplateTags {
+       enum {
                TM_PREAMBLEDEF = 1,
                TM_PREAMBLEDEF_END,
                TM_TEMPLATE,
                TM_TEMPLATE_END
        };
 
-       keyword_item templatetags[] = {
+       LexerKeyword templatetags[] = {
                { "preambledef", TM_PREAMBLEDEF },
                { "preambledefend", TM_PREAMBLEDEF_END },
                { "template", TM_TEMPLATE },
                { "templateend", TM_TEMPLATE_END }
        };
 
-       Lexer lex(templatetags, TM_TEMPLATE_END);
+       Lexer lex(templatetags);
 
        FileName const filename = libFileSearch("", "external_templates");
        if (filename.empty() || !lex.setFile(filename)) {
@@ -311,7 +311,7 @@ void add(vector<TransformID> & ids, string const & name)
 
 void Template::readTemplate(Lexer & lex)
 {
-       enum TemplateOptionTags {
+       enum {
                TO_GUINAME = 1,
                TO_HELPTEXT,
                TO_INPUTFORMAT,
@@ -322,7 +322,7 @@ void Template::readTemplate(Lexer & lex)
                TO_END
        };
 
-       keyword_item templateoptiontags[] = {
+       LexerKeyword templateoptiontags[] = {
                { "automaticproduction", TO_AUTOMATIC },
                { "filefilter", TO_FILTER },
                { "format", TO_FORMAT },
@@ -480,7 +480,7 @@ void Template::Format::readFormat(Lexer & lex)
                FO_END
        };
 
-       keyword_item formattags[] = {
+       LexerKeyword formattags[] = {
                { "formatend", FO_END },
                { "option", FO_OPTION },
                { "preamble", FO_PREAMBLE },
index 549fdacb832e037f8515ac841fd3df05c4008dd9..254f9ea840b4c84e825e6152df8b5f843cd2d314 100644 (file)
@@ -523,7 +523,7 @@ void InsetBox::string2params(string const & in, InsetBoxParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index 6770189fa19c46fb3949a2ea44f0924258f51b6e..33397b71aaf43354a00cd5cc2d9be7727d0ea4d4 100644 (file)
@@ -281,7 +281,7 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index 6a3a382e55f868f58c4f42c2748950cc3f2ccc58..a7bb9955e3b6448c969edc7e1bb63cc19ebd6e0f 100644 (file)
@@ -198,7 +198,7 @@ bool InsetCommand::string2params(string const & name, string const & in,
                return false;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string n;
index 68147e20d5386065bc185928adfee2964e6879cb..137cc76a5f5437fadd00e1640f936b7dd06f9e3f 100644 (file)
@@ -197,7 +197,7 @@ InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
                return status;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index daddd7134ad53a15791ea5aff46167d6c945e08c..1d525157462db6a39c9520b244aab640493fb926 100644 (file)
@@ -264,7 +264,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                EX_END
        };
 
-       keyword_item external_tags[] = {
+       LexerKeyword external_tags[] = {
                { "\\end_inset",     EX_END },
                { "boundingBox",     EX_BOUNDINGBOX },
                { "clip",            EX_CLIP },
@@ -883,7 +883,7 @@ void InsetExternal::string2params(string const & in, Buffer const & buffer,
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index d201a29194fb240f947202cbe722b37b5cf2cdad..a5657821fa81e6bee62d0f43c4c151bfdf402c56 100644 (file)
@@ -452,7 +452,7 @@ void InsetFloat::string2params(string const & in, InsetFloatParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index 39e2019e0d06080c93c054c42eb5fd779a39f874..8b0b212631baa492d431fae92b00a598d07a7545 100644 (file)
@@ -961,7 +961,7 @@ void InsetGraphics::string2params(string const & in, Buffer const & buffer,
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index 900881764999652e943c0921b78d7da58145bfc8..4a0c35d02c0a95d39d548b348885d544791cb0e1 100644 (file)
@@ -39,7 +39,7 @@ InsetLayout::InsetLayout() :
 
 
 enum InsetLayoutTags {
-       IL_FONT = 1,
+       IL_FONT,
        IL_BGCOLOR,
        IL_DECORATION,
        IL_FREESPACING,
@@ -78,7 +78,7 @@ bool InsetLayout::read(Lexer & lexrc)
 {
        name_ = support::subst(lexrc.getDocString(), '_', ' ');
 
-       keyword_item elementTags[] = {
+       LexerKeyword elementTags[] = {
                { "bgcolor", IL_BGCOLOR },
                { "decoration", IL_DECORATION },
                { "end", IL_END },
@@ -99,7 +99,7 @@ bool InsetLayout::read(Lexer & lexrc)
                { "requires", IL_REQUIRES }
        };
 
-       lexrc.pushTable(elementTags, IL_END);
+       lexrc.pushTable(elementTags);
 
        FontInfo font = inherit_font;
        labelfont_ = inherit_font;
index 348e620b355441f838d52fa9acc0cfe75a05bc86..d8a06da9c6e11b3e737b487431c332e28f89de64 100644 (file)
@@ -313,7 +313,7 @@ void InsetListings::string2params(string const & in,
        if (in.empty())
                return;
        istringstream data(in);
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setStream(data);
        // discard "listings", which is only used to determine inset
        lex.next();
index 72f7e1370999042f364f799b79349801025edcd8..40ac72ef4ea55a18ff16de473523ca4642a9b62d 100644 (file)
@@ -269,7 +269,7 @@ void InsetNewline::string2params(string const & in, InsetNewlineParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index e7b9b0523a2ac251187ef7da76a9a5a23b16de43..aa9fe900d5262b371369dd820aad0775b4730fce 100644 (file)
@@ -272,7 +272,7 @@ void InsetNewpage::string2params(string const & in, InsetNewpageParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index 85aa740bc1aaa391b6d682f7117113f0ca836199..c764f801ee9ea5494587160c56ee4e395f80dbc9 100644 (file)
@@ -368,7 +368,7 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index f71c0cc10e3d8d34e72822d3aa6cbc0a606baba7..a7ada6dc47ed5bd4c585430ef6eb94905af6452c 100644 (file)
@@ -530,7 +530,7 @@ void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index e2c4bef099950daa413ecafba8a1b97f685476bd..e24a8095bc0779ac76a9c337c1ab326b34cf78f4 100644 (file)
@@ -4840,7 +4840,7 @@ void InsetTabular::completionPosAndDim(Cursor const & cur, int & x, int & y,
 void InsetTabular::string2params(string const & in, InsetTabular & inset)
 {
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        if (in.empty())
index b8c5b12e52abbc757a0993911631b305a675cf9e..c233eb8d1efebbed200d12e1c218fa6bb962bf7b 100644 (file)
@@ -255,7 +255,7 @@ void InsetVSpace::string2params(string const & in, VSpace & vspace)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
index df23f0c493293d4418da42aa65b3836edd7fadfc..a9f92cedc27714061916675735cc9cc28363c77c 100644 (file)
@@ -267,7 +267,7 @@ void InsetWrap::string2params(string const & in, InsetWrapParams & params)
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;
diff --git a/src/lyxled/LayoutEditor.cpp b/src/lyxled/LayoutEditor.cpp
new file mode 100644 (file)
index 0000000..660c7f9
--- /dev/null
@@ -0,0 +1,126 @@
+
+#include "LayoutEditor.h"
+
+#include "ui_MainWindowUi.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QList>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include <QString>
+#include <QTreeView>
+
+
+namespace lyx {
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutTree
+//
+/////////////////////////////////////////////////////////////////////////
+
+LayoutTree::LayoutTree(QWidget * parent) 
+       : QTreeView(parent)
+{}
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutEditor
+//
+/////////////////////////////////////////////////////////////////////////
+
+LayoutEditor::LayoutEditor(QWidget * parent) 
+       : QWidget(parent)
+{}
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// MainWindow
+//
+/////////////////////////////////////////////////////////////////////////
+
+MainWindow::MainWindow()
+{
+       ui_ = new Ui::MainWindow;
+       ui_->setupUi(this);
+
+       model_ = new QStandardItemModel(this);
+       view_ = new LayoutTree(this);
+       view_->setModel(model_);
+       //setCentralWidget(view_);
+
+       ui_->dockLayoutTree->setWidget(view_);
+}
+
+
+MainWindow::~MainWindow()
+{
+       delete ui_;
+}
+
+static bool isInsensitivelyEqual(QString const & s1, QString const & s2)
+{
+       return s1.compare(s2, Qt::CaseInsensitive) == 0;
+}
+
+void MainWindow::loadLayoutFile(QString const & fileName)
+{
+       loadLayoutFile(fileName, model_->invisibleRootItem());
+       view_->expandAll();
+}
+
+
+void MainWindow::loadLayoutFile(QString const & fileName,
+       QStandardItem * parent)
+{
+       QFile file(fileName);
+#if 0
+       file.open(QIODevice::ReadOnly);
+       QString contents = file.readAll();
+       file.close();
+       qDebug() << "contents: " << contents;
+#endif
+
+       file.open(QIODevice::ReadOnly);
+
+       QTextStream ts(&file);
+       while (!ts.atEnd()) {
+               QList<QStandardItem *> row;
+               QString code;
+               ts >> code;
+               //qDebug() << "CODE: " << code;
+               if (code.startsWith('#')) {
+                       QString line = code + ' ' + ts.readLine();
+                       //row.append(new QStandardItem("Comment"));
+                       //row.append(new QStandardItem(code + ' ' + ts.readLine()));
+                       //parent->appendRow(row);
+               } else if (isInsensitivelyEqual(code, "Input")) {
+                       QString inputFile;
+                       ts >> inputFile;
+                       QStandardItem * item = new QStandardItem(inputFile);
+                       row.append(item);
+                       parent->appendRow(row);
+                       inputFile = fileName.left(fileName.lastIndexOf('/')) + '/' + inputFile;
+                       qDebug() << "INPUT: " << inputFile;
+                       loadLayoutFile(inputFile, item);
+               } else if (isInsensitivelyEqual(code, "Style")) {
+                       QString style;
+                       ts >> style;
+                       //while (!ts.atEnd() && !isInsensitivelyEqual(code, "EndStyle"))
+                       //      ts >> code;
+                       QStandardItem * item = new QStandardItem(style);
+                       row.append(item);
+                       parent->appendRow(row);
+               } else {
+                       //row.append(new QStandardItem(code));
+                       //parent->appendRow(row);
+               }
+       }
+       
+       file.close();
+}
+
+} // namespace lyx
diff --git a/src/lyxled/LayoutEditor.h b/src/lyxled/LayoutEditor.h
new file mode 100644 (file)
index 0000000..9a9eab8
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef LAYOUTEDITOR_H
+#define LAYOUTEDITOR_H
+
+#include <QMainWindow>
+#include <QObject>
+#include <QTreeView>
+#include <QWidget>
+
+class QStandardItem;
+class QStandardItemModel;
+
+namespace Ui { class MainWindow; }
+
+namespace lyx {
+
+class LayoutTree;
+class LayoutEditor;
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutTree
+//
+/////////////////////////////////////////////////////////////////////////
+
+class LayoutTree : public QTreeView
+{
+       Q_OBJECT
+
+public:
+       LayoutTree(QWidget * parent);
+};
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutTree
+//
+/////////////////////////////////////////////////////////////////////////
+
+class LayoutEditor : public QWidget
+{
+       Q_OBJECT
+
+public:
+       LayoutEditor(QWidget * parent);
+};
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// MainWindow
+//
+/////////////////////////////////////////////////////////////////////////
+
+class MainWindow : public QMainWindow
+{
+       Q_OBJECT
+
+public:
+       MainWindow();
+       ~MainWindow();
+
+       void loadLayoutFile(QString const & file);
+
+public:
+       void loadLayoutFile(QString const & file, QStandardItem * parent);
+
+       Ui::MainWindow * ui_;
+       LayoutTree * view_;
+       QStandardItemModel * model_;
+};
+
+} // namespace lyx
+
+#endif // LAYOUTEDITOR_H
diff --git a/src/lyxled/Makefile.am b/src/lyxled/Makefile.am
new file mode 100644 (file)
index 0000000..51c45d9
--- /dev/null
@@ -0,0 +1,66 @@
+include $(top_srcdir)/config/common.am
+
+BUILT_SOURCES = $(MOCEDFILES)
+#BUILT_SOURCES = $(UIFILES:%.ui=ui_%.h)
+#BUILT_SOURCES += Resources.cpp Resources.qrc
+
+CLEANFILES += $(BUILT_SOURCES)
+
+#########################  Qt stuff  #############################
+# Use _() for localization instead of tr() or trUtf8()
+UIC4FLAGS=-tr lyx::qt_
+
+ui_%.h: ui/%.ui
+       $(UIC4) $(UIC4FLAGS) $< -o $@
+
+MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp)
+
+%_moc.cpp: %.h
+       $(MOC4) -o $@ $<
+
+#Resources.qrc: Makefile
+#      echo "<!DOCTYPE RCC><RCC version='1.0'><qresource>" > $@
+#      find $(top_srcdir)/lib/images -name '*.png' \
+#              | sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
+#              >> $@
+#      echo "</qresource></RCC>" >> $@
+#
+#Resources.cpp: Resources.qrc
+#      $(RCC4) $< -name Resources -o $@
+
+
+#########################  LIBRARIES  #############################
+
+bin_PROGRAMS = lyxled
+
+lyxled_LDADD = $(QT4_LIB)
+lyxled_DEPENDENCIES = $(MOCEDFILES)
+
+AM_CPPFLAGS += \
+       $(QT4_CPPFLAGS) \
+       -UQT_NO_KEYWORDS \
+       -I$(top_srcdir)/src \
+       $(QT4_INCLUDES)
+
+SOURCEFILES = \
+       main.cpp \
+       LayoutEditor.cpp \
+       LayoutEditor_moc.cpp
+
+NOMOCHEADER = 
+
+MOCHEADER = \
+       LayoutEditor.h
+
+UIFILES = 
+
+lyxled_SOURCES = \
+       $(SOURCEFILES) \
+       $(MOCEDFILES) \
+       $(MOCHEADER) \
+       $(NOMOCHEADER)
+
+EXTRA_DIST = ui/compile_uic.sh $(UIFILES:%=ui/%)
+#EXTRA_DIST = pch.h ui/compile_uic.sh $(UIFILES:%=ui/%)
+#BUILT_SOURCES += $(PCH_FILE)
+#AM_CPPFLAGS += $(PCH_FLAGS)
diff --git a/src/lyxled/lyxled.pro b/src/lyxled/lyxled.pro
new file mode 100644 (file)
index 0000000..6256563
--- /dev/null
@@ -0,0 +1,16 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Tue Apr 1 00:17:55 2008
+######################################################################
+
+TEMPLATE = app
+TARGET = lyxled
+DEPENDPATH += .
+INCLUDEPATH += .
+
+HEADERS += LayoutEditor.h
+
+SOURCES += \
+       LayoutEditor.cpp \
+       main.cpp
+
+FORMS += ui/MainWindowUi.ui
diff --git a/src/lyxled/main.cpp b/src/lyxled/main.cpp
new file mode 100644 (file)
index 0000000..736aab4
--- /dev/null
@@ -0,0 +1,18 @@
+
+#include "LayoutEditor.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+       QApplication app(argc, argv);
+       lyx::MainWindow led;
+       QStringList args = app.arguments();
+       args.append("/data/lyx/trunk/lib/layouts/amsart.layout");
+       for (int i = 1; i != args.size(); ++i) {
+               led.loadLayoutFile(args[i]);
+       }
+       led.show();
+       return app.exec();
+}
+
diff --git a/src/lyxled/ui/MainWindowUi.ui b/src/lyxled/ui/MainWindowUi.ui
new file mode 100644 (file)
index 0000000..08e95a7
--- /dev/null
@@ -0,0 +1,80 @@
+<ui version="4.0" >
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget" />
+  <widget class="QMenuBar" name="menubar" >
+   <property name="geometry" >
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile" >
+    <property name="title" >
+     <string>File</string>
+    </property>
+    <addaction name="actionNew_Layout" />
+    <addaction name="actionOpen_Layout" />
+    <addaction name="actionRecent_Layouts" />
+    <addaction name="separator" />
+    <addaction name="actionSave_Layout" />
+    <addaction name="actionSave_As" />
+    <addaction name="separator" />
+    <addaction name="actionQuit" />
+   </widget>
+   <addaction name="menuFile" />
+  </widget>
+  <widget class="QStatusBar" name="statusbar" />
+  <widget class="QDockWidget" name="dockLayoutTree" >
+   <attribute name="dockWidgetArea" >
+    <number>1</number>
+   </attribute>
+   <widget class="QWidget" name="dockWidgetContents" />
+  </widget>
+  <action name="actionNew_Layout" >
+   <property name="text" >
+    <string>New Layout</string>
+   </property>
+  </action>
+  <action name="actionOpen_Layout" >
+   <property name="text" >
+    <string>Open Layout</string>
+   </property>
+  </action>
+  <action name="actionRecent_Layouts" >
+   <property name="text" >
+    <string>Recent Layouts</string>
+   </property>
+  </action>
+  <action name="actionSave_Layout" >
+   <property name="text" >
+    <string>Save Layout</string>
+   </property>
+  </action>
+  <action name="actionSave_As" >
+   <property name="text" >
+    <string>Save As</string>
+   </property>
+  </action>
+  <action name="actionQuit" >
+   <property name="text" >
+    <string>Quit</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 1f7db010c182063042b2dc03fa3dc2a3fef08e88..4a24b3f2ba5c948ee2e817c369ca9017fecb94ad 100644 (file)
@@ -378,7 +378,7 @@ private:
 
 
 Parser::Parser(Lexer & lexer)
-       : lineno_(lexer.getLineNo()), pos_(0)
+       : lineno_(lexer.lineNumber()), pos_(0)
 {
        tokenize(lexer.getStream());
        lexer.eatLine();