From 807682efd3d4c7019156ef4a6555b05a7885300c Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 15 Apr 2003 02:28:53 +0000 Subject: [PATCH] include ui support from Angus git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6812 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/lyx_main.C | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 7095b7bbd9..1dae5ac703 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-04-15 John Levon + + From Angus Leeming + + * lyx_main.C: handle Include in .ui files + 2003-04-15 John Levon * MenuBackend.C: make the doc files length shorter diff --git a/src/lyx_main.C b/src/lyx_main.C index ba26292687..d365a0d280 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -673,14 +673,29 @@ void LyX::readUIFile(string const & name) enum Uitags { ui_menuset = 1, ui_toolbar, + ui_include, ui_last }; struct keyword_item uitags[ui_last - 1] = { + { "include", ui_include }, { "menuset", ui_menuset }, { "toolbar", ui_toolbar } }; + // Ensure that a file is read only once (prevents include loops) + static std::list uifiles; + std::list::const_iterator it = uifiles.begin(); + std::list::const_iterator end = uifiles.end(); + it = std::find(it, end, name); + if (it != end) { + lyxerr[Debug::INIT] << "UI file '" << name + << "' has been read already. " + << "Is this an include loop?" + << endl; + return; + } + lyxerr[Debug::INIT] << "About to read " << name << "..." << endl; string const ui_path = LibFileSearch("ui", name, "ui"); @@ -690,6 +705,7 @@ void LyX::readUIFile(string const & name) showFileError(name); return; } + uifiles.push_back(name); lyxerr[Debug::INIT] << "Found " << name << " in " << ui_path << endl; @@ -705,6 +721,12 @@ void LyX::readUIFile(string const & name) while (lex.isOK()) { switch (lex.lex()) { + case ui_include: { + lex.next(true); + string const file = lex.getString(); + readUIFile(file); + break; + } case ui_menuset: menubackend.read(lex); break; -- 2.39.2